ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilTestSequence Class Reference

Test sequence handler. More...

+ Inheritance diagram for ilTestSequence:
+ Collaboration diagram for ilTestSequence:

Public Member Functions

 __construct (protected ilDBInterface $db, protected int $active_id, protected int $pass, protected GeneralQuestionPropertiesRepository $questionrepository)
 ilTestSequence constructor More...
 
 getActiveId ()
 
 createNewSequence (int $max, bool $shuffle)
 
 loadQuestions ()
 Loads the question mapping. More...
 
 loadFromDb ()
 Loads the sequence data for a given active id. More...
 
 saveToDb ()
 Saves the sequence data for a given pass to the database. More...
 
 postponeQuestion (int $question_id)
 
 hideQuestion (int $question_id)
 
 isPostponedQuestion (int $question_id)
 
 isHiddenQuestion (int $question_id)
 
 isPostponedSequence (int $sequence)
 
 isHiddenSequence (int $sequence)
 
 postponeSequence (int $sequence)
 
 hideSequence (int $sequence)
 
 setQuestionPresented (int $question_id)
 
 isQuestionPresented (int $question_id)
 
 isNextQuestionPresented (int $question_id)
 
 setQuestionChecked (int $question_id)
 
 isQuestionChecked (int $question_id)
 
 getPositionOfSequence (int $sequence)
 
 getUserQuestionCount ()
 
 getOrderedSequence ()
 
 getOrderedSequenceQuestions ()
 
 getUserSequence ()
 
 getUserSequenceQuestions ()
 
 getSequenceForQuestion (int $question_id)
 
 getFirstSequence ()
 
 getLastSequence ()
 
 getNextSequence (int $sequence)
 
 getPreviousSequence (int $sequence)
 
 pcArrayShuffle (array $array)
 Shuffles the values of a given array. More...
 
 getQuestionForSequence (int $sequence)
 
 getSequenceSummary ()
 
 getPass ()
 
 setPass (int $pass)
 
 hasSequence ()
 
 hasHiddenQuestions ()
 
 clearHiddenQuestions ()
 
 hasStarted (ilTestSession $testSession)
 
 openQuestionExists ()
 
 getQuestionIds ()
 
 questionExists (int $question_id)
 
 setQuestionOptional (int $question_id)
 
 isQuestionOptional (int $question_id)
 
 hasOptionalQuestions ()
 
 getOptionalQuestions ()
 
 clearOptionalQuestions ()
 
 reorderOptionalQuestionsToSequenceEnd ()
 
 isAnsweringOptionalQuestionsConfirmed ()
 
 setAnsweringOptionalQuestionsConfirmed (bool $answeringOptionalQuestionsConfirmed)
 
 isConsiderHiddenQuestionsEnabled ()
 
 setConsiderHiddenQuestionsEnabled (bool $considerHiddenQuestionsEnabled)
 
 isConsiderOptionalQuestionsEnabled ()
 
 setConsiderOptionalQuestionsEnabled (bool $considerOptionalQuestionsEnabled)
 

Data Fields

array $sequencedata
 An array containing the sequence data. More...
 
array $questions
 The mapping of the sequence numbers to the questions. More...
 

Protected Member Functions

 loadPresentedQuestions ()
 
 saveNewlyPresentedQuestion ()
 
 getCorrectedSequence ()
 

Protected Attributes

array $alreadyPresentedQuestions = []
 
int $newlyPresentedQuestion = 0
 
array $alreadyCheckedQuestions = []
 
int $newlyCheckedQuestion = null
 
array $optionalQuestions = []
 

Private Member Functions

 loadQuestionSequence ()
 
 loadCheckedQuestions ()
 
 loadOptionalQuestions ()
 
 saveQuestionSequence ()
 
 saveNewlyCheckedQuestion ()
 
 saveOptionalQuestions ()
 
 ensureQuestionNotInSequence (array $sequence, int $question_id)
 

Private Attributes

bool $answeringOptionalQuestionsConfirmed = false
 
bool $considerHiddenQuestionsEnabled = false
 
bool $considerOptionalQuestionsEnabled = true
 

Detailed Description

Test sequence handler.

This class manages the sequence settings for a given user

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$ \

Definition at line 32 of file class.ilTestSequence.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSequence::__construct ( protected ilDBInterface  $db,
protected int  $active_id,
protected int  $pass,
protected GeneralQuestionPropertiesRepository  $questionrepository 
)

ilTestSequence constructor

The constructor takes possible arguments an creates an instance of the ilTestSequence object.

Definition at line 66 of file class.ilTestSequence.php.

71  {
72  $this->sequencedata = [
73  "sequence" => [],
74  "postponed" => [],
75  "hidden" => []
76  ];
77  }

Member Function Documentation

◆ clearHiddenQuestions()

ilTestSequence::clearHiddenQuestions ( )

Definition at line 671 of file class.ilTestSequence.php.

Referenced by ilLOTestQuestionAdapter\hideQuestions().

671  : void
672  {
673  $this->sequencedata["hidden"] = [];
674  }
+ Here is the caller graph for this function:

◆ clearOptionalQuestions()

ilTestSequence::clearOptionalQuestions ( )

Definition at line 732 of file class.ilTestSequence.php.

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

732  : void
733  {
734  $this->optionalQuestions = [];
735  }
+ Here is the caller graph for this function:

◆ createNewSequence()

ilTestSequence::createNewSequence ( int  $max,
bool  $shuffle 
)

Definition at line 84 of file class.ilTestSequence.php.

References pcArrayShuffle().

84  : void
85  {
86  $newsequence = [];
87  if ($max > 0) {
88  for ($i = 1; $i <= $max; $i++) {
89  $newsequence[] = $i;
90  }
91  if ($shuffle) {
92  $newsequence = $this->pcArrayShuffle($newsequence);
93  }
94  }
95  $this->sequencedata["sequence"] = $newsequence;
96  }
pcArrayShuffle(array $array)
Shuffles the values of a given array.
+ Here is the call graph for this function:

◆ ensureQuestionNotInSequence()

ilTestSequence::ensureQuestionNotInSequence ( array  $sequence,
int  $question_id 
)
private

Definition at line 478 of file class.ilTestSequence.php.

Referenced by getCorrectedSequence().

478  : array
479  {
480  $question_key = array_search($question_id, $this->questions);
481 
482  if ($question_key === false) {
483  return $sequence;
484  }
485 
486  $sequence_key = array_search($question_key, $sequence);
487 
488  if ($sequence_key === false) {
489  return $sequence;
490  }
491 
492  unset($sequence[$sequence_key]);
493 
494  return $sequence;
495  }
+ Here is the caller graph for this function:

◆ getActiveId()

ilTestSequence::getActiveId ( )

Implements ilTestSequenceSummaryProvider.

Definition at line 79 of file class.ilTestSequence.php.

79  : int
80  {
81  return $this->active_id;
82  }

◆ getCorrectedSequence()

ilTestSequence::getCorrectedSequence ( )
protected

Definition at line 497 of file class.ilTestSequence.php.

References ensureQuestionNotInSequence(), isConsiderHiddenQuestionsEnabled(), and isConsiderOptionalQuestionsEnabled().

Referenced by getFirstSequence(), getLastSequence(), getNextSequence(), getPositionOfSequence(), getPreviousSequence(), getSequenceSummary(), getUserQuestionCount(), getUserSequence(), and getUserSequenceQuestions().

497  : array
498  {
499  $corrected_sequence = $this->sequencedata["sequence"];
501  && is_array($this->sequencedata["hidden"])) {
502  foreach ($this->sequencedata["hidden"] as $question_id) {
503  $corrected_sequence = $this->ensureQuestionNotInSequence($corrected_sequence, $question_id);
504  }
505  }
506  if (!$this->isConsiderOptionalQuestionsEnabled()) {
507  foreach ($this->optionalQuestions as $question_id) {
508  $corrected_sequence = $this->ensureQuestionNotInSequence($corrected_sequence, $question_id);
509  }
510  }
511  if (is_array($this->sequencedata["postponed"])) {
512  foreach ($this->sequencedata["postponed"] as $question_id) {
513  $found_sequence = array_search($question_id, $this->questions);
514  if ($found_sequence === false) {
515  continue;
516  }
517  $sequence_key = array_search($found_sequence, $corrected_sequence);
518  if ($sequence_key !== false) {
519  unset($corrected_sequence[$sequence_key]);
520  $corrected_sequence[] = $found_sequence;
521  }
522  }
523  }
524  return array_values($corrected_sequence);
525  }
ensureQuestionNotInSequence(array $sequence, int $question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFirstSequence()

ilTestSequence::getFirstSequence ( )

Definition at line 532 of file class.ilTestSequence.php.

References getCorrectedSequence().

Referenced by hasStarted(), and openQuestionExists().

532  : int
533  {
534  $correctedsequence = $this->getCorrectedSequence();
535  if (count($correctedsequence)) {
536  return reset($correctedsequence);
537  }
538 
539  return 0;
540  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastSequence()

ilTestSequence::getLastSequence ( )

Definition at line 542 of file class.ilTestSequence.php.

References getCorrectedSequence().

542  : int
543  {
544  $correctedsequence = $this->getCorrectedSequence();
545  if (count($correctedsequence)) {
546  return end($correctedsequence);
547  }
548 
549  return 0;
550  }
+ Here is the call graph for this function:

◆ getNextSequence()

ilTestSequence::getNextSequence ( int  $sequence)

Definition at line 552 of file class.ilTestSequence.php.

References getCorrectedSequence().

Referenced by isNextQuestionPresented().

552  : int
553  {
554  $corrected_sequence = $this->getCorrectedSequence();
555  $sequence_key = array_search($sequence, $corrected_sequence);
556  if ($sequence_key !== false) {
557  $next_sequence_key = $sequence_key + 1;
558  if (array_key_exists($next_sequence_key, $corrected_sequence)) {
559  return $corrected_sequence[$next_sequence_key];
560  }
561  }
562  return 0;
563  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOptionalQuestions()

ilTestSequence::getOptionalQuestions ( )

Definition at line 727 of file class.ilTestSequence.php.

References $optionalQuestions.

727  : array
728  {
730  }

◆ getOrderedSequence()

ilTestSequence::getOrderedSequence ( )

Definition at line 429 of file class.ilTestSequence.php.

References isConsiderHiddenQuestionsEnabled(), and isHiddenSequence().

429  : array
430  {
431  $sequenceKeys = [];
432 
433  foreach (array_keys($this->questions) as $sequenceKey) {
434  if ($this->isHiddenSequence($sequenceKey) && !$this->isConsiderHiddenQuestionsEnabled()) {
435  continue;
436  }
437 
438  $sequenceKeys[] = $sequenceKey;
439  }
440 
441  return $sequenceKeys;
442  }
isHiddenSequence(int $sequence)
+ Here is the call graph for this function:

◆ getOrderedSequenceQuestions()

ilTestSequence::getOrderedSequenceQuestions ( )

Definition at line 444 of file class.ilTestSequence.php.

References $questions, isConsiderHiddenQuestionsEnabled(), isConsiderOptionalQuestionsEnabled(), isHiddenQuestion(), and isQuestionOptional().

444  : array
445  {
446  $questions = [];
447 
448  foreach ($this->questions as $questionId) {
449  if ($this->isHiddenQuestion($questionId) && !$this->isConsiderHiddenQuestionsEnabled()) {
450  continue;
451  }
452 
453  if ($this->isQuestionOptional($questionId) && !$this->isConsiderOptionalQuestionsEnabled()) {
454  continue;
455  }
456 
457  $questions[] = $questionId;
458  }
459 
460  return $questions;
461  }
isHiddenQuestion(int $question_id)
array $questions
The mapping of the sequence numbers to the questions.
isQuestionOptional(int $question_id)
+ Here is the call graph for this function:

◆ getPass()

ilTestSequence::getPass ( )

Definition at line 643 of file class.ilTestSequence.php.

643  : int
644  {
645  return $this->pass;
646  }

◆ getPositionOfSequence()

ilTestSequence::getPositionOfSequence ( int  $sequence)

Definition at line 414 of file class.ilTestSequence.php.

References getCorrectedSequence().

414  : int
415  {
416  $corrected_sequence = $this->getCorrectedSequence();
417  $sequence_key = array_search($sequence, $corrected_sequence);
418  if ($sequence_key !== false) {
419  return $sequence_key + 1;
420  }
421  return 0;
422  }
+ Here is the call graph for this function:

◆ getPreviousSequence()

ilTestSequence::getPreviousSequence ( int  $sequence)

Definition at line 565 of file class.ilTestSequence.php.

References getCorrectedSequence().

565  : int
566  {
567  $correctedsequence = $this->getCorrectedSequence();
568  $sequencekey = array_search($sequence, $correctedsequence);
569  if ($sequencekey !== false) {
570  $prevsequencekey = $sequencekey - 1;
571  if (($prevsequencekey >= 0) && (array_key_exists($prevsequencekey, $correctedsequence))) {
572  return $correctedsequence[$prevsequencekey];
573  }
574  }
575 
576  return 0;
577  }
+ Here is the call graph for this function:

◆ getQuestionForSequence()

ilTestSequence::getQuestionForSequence ( int  $sequence)

Definition at line 593 of file class.ilTestSequence.php.

References null.

Referenced by getSequenceSummary(), getUserSequenceQuestions(), isNextQuestionPresented(), and reorderOptionalQuestionsToSequenceEnd().

593  : ?int
594  {
595  if ($sequence < 1) {
596  return null;
597  }
598  if (array_key_exists($sequence, $this->questions)) {
599  return $this->questions[$sequence];
600  }
601 
602  return null;
603  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getQuestionIds()

ilTestSequence::getQuestionIds ( )

Implements ilTestQuestionSequence.

Definition at line 695 of file class.ilTestSequence.php.

Referenced by ilLOTestQuestionAdapter\hideQuestions(), ilLOTestQuestionAdapter\setQuestionsOptional(), ilLOTestQuestionAdapter\updateRandomQuestions(), and ilLOTestQuestionAdapter\updateSeparateTestQuestions().

695  : array
696  {
697  return array_values($this->questions);
698  }
+ Here is the caller graph for this function:

◆ getSequenceForQuestion()

ilTestSequence::getSequenceForQuestion ( int  $question_id)

Definition at line 527 of file class.ilTestSequence.php.

References null.

Referenced by isNextQuestionPresented().

527  : ?int
528  {
529  return array_search($question_id, $this->questions) ?: null;
530  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getSequenceSummary()

ilTestSequence::getSequenceSummary ( )

Implements ilTestSequenceSummaryProvider.

Definition at line 605 of file class.ilTestSequence.php.

References ilObjTest\_getSolvedQuestions(), getCorrectedSequence(), getQuestionForSequence(), assQuestion\instantiateQuestion(), isPostponedQuestion(), and isQuestionPresented().

605  : array
606  {
607  $correctedsequence = $this->getCorrectedSequence();
608  $result_array = [];
609  $solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
610  $key = 1;
611  foreach ($correctedsequence as $sequence) {
612  $question = assQuestion::instantiateQuestion($this->getQuestionForSequence($sequence));
613  if (is_object($question)) {
614  $worked_through = $this->questionrepository->lookupResultRecordExist($this->active_id, $question->getId(), $this->pass);
615  $solved = 0;
616  if (array_key_exists($question->getId(), $solved_questions)) {
617  $solved = $solved_questions[$question->getId()]["solved"];
618  }
619  $is_postponed = $this->isPostponedQuestion($question->getId());
620 
621  $result_array[] = [
622  'nr' => $key,
623  'title' => $question->getTitleForHTMLOutput(),
624  'qid' => $question->getId(),
625  'presented' => $this->isQuestionPresented($question->getId()),
626  'visited' => $worked_through,
627  'solved' => (($solved) ? "1" : "0"),
628  'description' => $question->getComment(),
629  'points' => $question->getMaximumPoints(),
630  'worked_through' => $worked_through,
631  'postponed' => $is_postponed,
632  'sequence' => $sequence,
633  'isAnswered' => $question->isAnswered($this->active_id, $this->pass),
634  'has_authorized_answer' => $question->authorizedSolutionExists($this->active_id, $this->pass)
635  ];
636 
637  $key++;
638  }
639  }
640  return $result_array;
641  }
getQuestionForSequence(int $sequence)
isPostponedQuestion(int $question_id)
static instantiateQuestion(int $question_id)
isQuestionPresented(int $question_id)
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
+ Here is the call graph for this function:

◆ getUserQuestionCount()

ilTestSequence::getUserQuestionCount ( )

Definition at line 424 of file class.ilTestSequence.php.

References getCorrectedSequence().

424  : int
425  {
426  return count($this->getCorrectedSequence());
427  }
+ Here is the call graph for this function:

◆ getUserSequence()

ilTestSequence::getUserSequence ( )

Definition at line 463 of file class.ilTestSequence.php.

References getCorrectedSequence().

463  : array
464  {
465  return $this->getCorrectedSequence();
466  }
+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequence::getUserSequenceQuestions ( )

Definition at line 468 of file class.ilTestSequence.php.

References getCorrectedSequence(), and getQuestionForSequence().

468  : array
469  {
470  $seq = $this->getCorrectedSequence();
471  $found = [];
472  foreach ($seq as $sequence) {
473  $found[] = $this->getQuestionForSequence($sequence);
474  }
475  return $found;
476  }
getQuestionForSequence(int $sequence)
+ Here is the call graph for this function:

◆ hasHiddenQuestions()

ilTestSequence::hasHiddenQuestions ( )

Definition at line 662 of file class.ilTestSequence.php.

662  : bool
663  {
664  if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]) > 0)) {
665  return true;
666  }
667 
668  return false;
669  }

◆ hasOptionalQuestions()

ilTestSequence::hasOptionalQuestions ( )

Definition at line 722 of file class.ilTestSequence.php.

722  : bool
723  {
724  return (bool) count($this->optionalQuestions);
725  }

◆ hasSequence()

ilTestSequence::hasSequence ( )

Definition at line 653 of file class.ilTestSequence.php.

653  : bool
654  {
655  if ((is_array($this->sequencedata["sequence"])) && (count($this->sequencedata["sequence"]) > 0)) {
656  return true;
657  }
658 
659  return false;
660  }

◆ hasStarted()

ilTestSequence::hasStarted ( ilTestSession  $testSession)

Definition at line 676 of file class.ilTestSequence.php.

References getFirstSequence(), and ilTestSession\getLastSequence().

676  : bool
677  {
678  if ($testSession->getLastSequence() < 1) {
679  return false;
680  }
681 
682  // WTF ?? heard about tests with only one question !?
683  if ($testSession->getLastSequence() == $this->getFirstSequence()) {
684  return false;
685  }
686 
687  return true;
688  }
+ Here is the call graph for this function:

◆ hideQuestion()

ilTestSequence::hideQuestion ( int  $question_id)

Definition at line 287 of file class.ilTestSequence.php.

References isHiddenQuestion().

Referenced by ilLOTestQuestionAdapter\hideQuestions().

287  : void
288  {
289  if (!$this->isHiddenQuestion($question_id)) {
290  $this->sequencedata["hidden"][] = $question_id;
291  }
292  }
isHiddenQuestion(int $question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hideSequence()

ilTestSequence::hideSequence ( int  $sequence)

Definition at line 359 of file class.ilTestSequence.php.

References ILIAS\Repository\int(), and isHiddenSequence().

359  : void
360  {
361  if (!$this->isHiddenSequence($sequence)) {
362  if (array_key_exists($sequence, $this->questions)) {
363  if (!is_array($this->sequencedata["hidden"])) {
364  $this->sequencedata["hidden"] = [];
365  }
366  $this->sequencedata["hidden"][] = (int) $this->questions[$sequence];
367  }
368  }
369  }
isHiddenSequence(int $sequence)
+ Here is the call graph for this function:

◆ isAnsweringOptionalQuestionsConfirmed()

ilTestSequence::isAnsweringOptionalQuestionsConfirmed ( )

Definition at line 753 of file class.ilTestSequence.php.

References $answeringOptionalQuestionsConfirmed.

Referenced by saveQuestionSequence(), and ilTestVirtualSequence\wasAnsweredInThisPass().

753  : bool
754  {
756  }
bool $answeringOptionalQuestionsConfirmed
+ Here is the caller graph for this function:

◆ isConsiderHiddenQuestionsEnabled()

ilTestSequence::isConsiderHiddenQuestionsEnabled ( )

Definition at line 765 of file class.ilTestSequence.php.

References $considerHiddenQuestionsEnabled.

Referenced by getCorrectedSequence(), getOrderedSequence(), and getOrderedSequenceQuestions().

765  : bool
766  {
768  }
+ Here is the caller graph for this function:

◆ isConsiderOptionalQuestionsEnabled()

ilTestSequence::isConsiderOptionalQuestionsEnabled ( )

Definition at line 775 of file class.ilTestSequence.php.

References $considerOptionalQuestionsEnabled.

Referenced by getCorrectedSequence(), and getOrderedSequenceQuestions().

775  : bool
776  {
778  }
bool $considerOptionalQuestionsEnabled
+ Here is the caller graph for this function:

◆ isHiddenQuestion()

ilTestSequence::isHiddenQuestion ( int  $question_id)

Definition at line 306 of file class.ilTestSequence.php.

Referenced by getOrderedSequenceQuestions(), hideQuestion(), and ilTestVirtualSequence\wasAnsweredInThisPass().

306  : bool
307  {
308  if (!is_array($this->sequencedata["hidden"])) {
309  return false;
310  }
311  if (!in_array($question_id, $this->sequencedata["hidden"])) {
312  return false;
313  }
314 
315  return true;
316  }
+ Here is the caller graph for this function:

◆ isHiddenSequence()

ilTestSequence::isHiddenSequence ( int  $sequence)

Definition at line 333 of file class.ilTestSequence.php.

Referenced by getOrderedSequence(), and hideSequence().

333  : bool
334  {
335  if (!array_key_exists($sequence, $this->questions)) {
336  return false;
337  }
338  if (!is_array($this->sequencedata["hidden"])) {
339  return false;
340  }
341  if (!in_array($this->questions[$sequence], $this->sequencedata["hidden"])) {
342  return false;
343  }
344  return true;
345  }
+ Here is the caller graph for this function:

◆ isNextQuestionPresented()

ilTestSequence::isNextQuestionPresented ( int  $question_id)

Definition at line 383 of file class.ilTestSequence.php.

References getNextSequence(), getQuestionForSequence(), getSequenceForQuestion(), and null.

383  : bool
384  {
385  $next_question_id = $this->getQuestionForSequence(
386  $this->getNextSequence($this->getSequenceForQuestion($question_id)) ?? 0
387  );
388 
389  if ($next_question_id === null) {
390  return false;
391  }
392 
393  if ($this->newlyPresentedQuestion === $next_question_id) {
394  return true;
395  }
396 
397  if (in_array($next_question_id, $this->alreadyPresentedQuestions)) {
398  return true;
399  }
400 
401  return false;
402  }
getQuestionForSequence(int $sequence)
getSequenceForQuestion(int $question_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getNextSequence(int $sequence)
+ Here is the call graph for this function:

◆ isPostponedQuestion()

ilTestSequence::isPostponedQuestion ( int  $question_id)

Definition at line 294 of file class.ilTestSequence.php.

Referenced by getSequenceSummary(), and postponeQuestion().

294  : bool
295  {
296  if (!is_array($this->sequencedata["postponed"])) {
297  return false;
298  }
299  if (!in_array($question_id, $this->sequencedata["postponed"])) {
300  return false;
301  }
302 
303  return true;
304  }
+ Here is the caller graph for this function:

◆ isPostponedSequence()

ilTestSequence::isPostponedSequence ( int  $sequence)

Definition at line 318 of file class.ilTestSequence.php.

Referenced by postponeSequence().

318  : bool
319  {
320  if (!array_key_exists($sequence, $this->questions)) {
321  return false;
322  }
323  if (!is_array($this->sequencedata["postponed"])) {
324  return false;
325  }
326  if (!in_array($this->questions[$sequence], $this->sequencedata["postponed"])) {
327  return false;
328  }
329 
330  return true;
331  }
+ Here is the caller graph for this function:

◆ isQuestionChecked()

ilTestSequence::isQuestionChecked ( int  $question_id)

Definition at line 409 of file class.ilTestSequence.php.

409  : bool
410  {
411  return isset($this->alreadyCheckedQuestions[$question_id]);
412  }

◆ isQuestionOptional()

ilTestSequence::isQuestionOptional ( int  $question_id)

Definition at line 717 of file class.ilTestSequence.php.

Referenced by getOrderedSequenceQuestions(), reorderOptionalQuestionsToSequenceEnd(), and ilTestVirtualSequence\wasAnsweredInThisPass().

717  : bool
718  {
719  return isset($this->optionalQuestions[$question_id]);
720  }
+ Here is the caller graph for this function:

◆ isQuestionPresented()

ilTestSequence::isQuestionPresented ( int  $question_id)

Definition at line 376 of file class.ilTestSequence.php.

Referenced by getSequenceSummary().

376  : bool
377  {
378  return (
379  $this->newlyPresentedQuestion == $question_id || in_array($question_id, $this->alreadyPresentedQuestions)
380  );
381  }
+ Here is the caller graph for this function:

◆ loadCheckedQuestions()

ilTestSequence::loadCheckedQuestions ( )
private

Definition at line 172 of file class.ilTestSequence.php.

References $res.

Referenced by loadFromDb().

172  : void
173  {
174  $res = $this->db->queryF(
175  "SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
176  ['integer','integer'],
177  [$this->active_id, $this->pass]
178  );
179 
180  while ($row = $this->db->fetchAssoc($res)) {
181  $this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
182  }
183  }
$res
Definition: ltiservices.php:66
+ Here is the caller graph for this function:

◆ loadFromDb()

ilTestSequence::loadFromDb ( )

Loads the sequence data for a given active id.

Definition at line 122 of file class.ilTestSequence.php.

References loadCheckedQuestions(), loadOptionalQuestions(), loadPresentedQuestions(), and loadQuestionSequence().

Referenced by ilTestVirtualSequence\getTestSequence().

122  : void
123  {
124  $this->loadQuestionSequence();
125  $this->loadPresentedQuestions();
126  $this->loadCheckedQuestions();
127  $this->loadOptionalQuestions();
128  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadOptionalQuestions()

ilTestSequence::loadOptionalQuestions ( )
private

Definition at line 185 of file class.ilTestSequence.php.

References $res.

Referenced by loadFromDb().

185  : void
186  {
187  $res = $this->db->queryF(
188  "SELECT question_fi FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s",
189  ['integer','integer'],
190  [$this->active_id, $this->pass]
191  );
192 
193  while ($row = $this->db->fetchAssoc($res)) {
194  $this->optionalQuestions[ $row['question_fi'] ] = $row['question_fi'];
195  }
196  }
$res
Definition: ltiservices.php:66
+ Here is the caller graph for this function:

◆ loadPresentedQuestions()

ilTestSequence::loadPresentedQuestions ( )
protected

Definition at line 159 of file class.ilTestSequence.php.

References $res.

Referenced by loadFromDb().

159  : void
160  {
161  $res = $this->db->queryF(
162  "SELECT question_fi FROM tst_seq_qst_presented WHERE active_fi = %s AND pass = %s",
163  ['integer','integer'],
164  [$this->active_id, $this->pass]
165  );
166 
167  while ($row = $this->db->fetchAssoc($res)) {
168  $this->alreadyPresentedQuestions[ $row['question_fi'] ] = $row['question_fi'];
169  }
170  }
$res
Definition: ltiservices.php:66
+ Here is the caller graph for this function:

◆ loadQuestions()

ilTestSequence::loadQuestions ( )

Loads the question mapping.

Definition at line 101 of file class.ilTestSequence.php.

References $data.

101  : void
102  {
103  $this->questions = [];
104 
105  $result = $this->db->queryF(
106  "SELECT tst_test_question.* FROM tst_test_question, qpl_questions, tst_active WHERE tst_active.active_id = %s AND tst_test_question.test_fi = tst_active.test_fi AND qpl_questions.question_id = tst_test_question.question_fi ORDER BY tst_test_question.sequence",
107  ['integer'],
108  [$this->active_id]
109  );
110 
111  $index = 1;
112 
113  // TODO bheyser: There might be "sequence" gaps which lead to issues with tst_sequence when deleting/adding questions before any participant starts the test
114  while ($data = $this->db->fetchAssoc($result)) {
115  $this->questions[$index++] = $data["question_fi"];
116  }
117  }

◆ loadQuestionSequence()

ilTestSequence::loadQuestionSequence ( )
private

Definition at line 130 of file class.ilTestSequence.php.

References setAnsweringOptionalQuestionsConfirmed().

Referenced by loadFromDb().

130  : void
131  {
132  $result = $this->db->queryF(
133  "SELECT * FROM tst_sequence WHERE active_fi = %s AND pass = %s",
134  ['integer','integer'],
135  [$this->active_id, $this->pass]
136  );
137  if ($result->numRows()) {
138  $row = $this->db->fetchAssoc($result);
139  $this->sequencedata = [
140  "sequence" => unserialize($row["sequence"] ?? '', ['allowed_classes' => false]),
141  "postponed" => unserialize($row["postponed"] ?? '', ['allowed_classes' => false]),
142  "hidden" => unserialize($row["hidden"] ?? '', ['allowed_classes' => false])
143  ];
144 
145  if (!is_array($this->sequencedata["sequence"])) {
146  $this->sequencedata["sequence"] = [];
147  }
148  if (!is_array($this->sequencedata["postponed"])) {
149  $this->sequencedata["postponed"] = [];
150  }
151  if (!is_array($this->sequencedata["hidden"])) {
152  $this->sequencedata["hidden"] = [];
153  }
154 
155  $this->setAnsweringOptionalQuestionsConfirmed((bool) $row['ans_opt_confirmed']);
156  }
157  }
setAnsweringOptionalQuestionsConfirmed(bool $answeringOptionalQuestionsConfirmed)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openQuestionExists()

ilTestSequence::openQuestionExists ( )

Definition at line 690 of file class.ilTestSequence.php.

References getFirstSequence().

690  : bool
691  {
692  return $this->getFirstSequence() !== 0;
693  }
+ Here is the call graph for this function:

◆ pcArrayShuffle()

ilTestSequence::pcArrayShuffle ( array  $array)

Shuffles the values of a given array.

Definition at line 582 of file class.ilTestSequence.php.

Referenced by createNewSequence().

582  : array
583  {
584  $keys = array_keys($array);
585  shuffle($keys);
586  $result = [];
587  foreach ($keys as $key) {
588  $result[$key] = $array[$key];
589  }
590  return $result;
591  }
+ Here is the caller graph for this function:

◆ postponeQuestion()

ilTestSequence::postponeQuestion ( int  $question_id)

Definition at line 280 of file class.ilTestSequence.php.

References isPostponedQuestion().

280  : void
281  {
282  if (!$this->isPostponedQuestion($question_id)) {
283  $this->sequencedata["postponed"][] = $question_id;
284  }
285  }
isPostponedQuestion(int $question_id)
+ Here is the call graph for this function:

◆ postponeSequence()

ilTestSequence::postponeSequence ( int  $sequence)

Definition at line 347 of file class.ilTestSequence.php.

References ILIAS\Repository\int(), and isPostponedSequence().

347  : void
348  {
349  if (!$this->isPostponedSequence($sequence)) {
350  if (array_key_exists($sequence, $this->questions)) {
351  if (!is_array($this->sequencedata["postponed"])) {
352  $this->sequencedata["postponed"] = [];
353  }
354  $this->sequencedata["postponed"][] = (int) $this->questions[$sequence];
355  }
356  }
357  }
isPostponedSequence(int $sequence)
+ Here is the call graph for this function:

◆ questionExists()

ilTestSequence::questionExists ( int  $question_id)

Definition at line 700 of file class.ilTestSequence.php.

700  : bool
701  {
702  return in_array($question_id, $this->questions);
703  }

◆ reorderOptionalQuestionsToSequenceEnd()

ilTestSequence::reorderOptionalQuestionsToSequenceEnd ( )

Definition at line 737 of file class.ilTestSequence.php.

References getQuestionForSequence(), and isQuestionOptional().

737  : void
738  {
739  $optionalSequenceKeys = [];
740 
741  foreach ($this->sequencedata['sequence'] as $index => $sequenceKey) {
742  if ($this->isQuestionOptional($this->getQuestionForSequence($sequenceKey))) {
743  $optionalSequenceKeys[$index] = $sequenceKey;
744  unset($this->sequencedata['sequence'][$index]);
745  }
746  }
747 
748  foreach ($optionalSequenceKeys as $index => $sequenceKey) {
749  $this->sequencedata['sequence'][$index] = $sequenceKey;
750  }
751  }
getQuestionForSequence(int $sequence)
isQuestionOptional(int $question_id)
+ Here is the call graph for this function:

◆ saveNewlyCheckedQuestion()

ilTestSequence::saveNewlyCheckedQuestion ( )
private

Definition at line 250 of file class.ilTestSequence.php.

Referenced by saveToDb().

250  : void
251  {
252  if ((int) $this->newlyCheckedQuestion) {
253  $this->db->replace('tst_seq_qst_checked', [
254  'active_fi' => ['integer', $this->active_id],
255  'pass' => ['integer', $this->pass],
256  'question_fi' => ['integer', (int) $this->newlyCheckedQuestion]
257  ], []);
258  }
259  }
+ Here is the caller graph for this function:

◆ saveNewlyPresentedQuestion()

ilTestSequence::saveNewlyPresentedQuestion ( )
protected

Definition at line 239 of file class.ilTestSequence.php.

Referenced by saveToDb().

239  : void
240  {
241  if ($this->newlyPresentedQuestion) {
242  $this->db->replace('tst_seq_qst_presented', [
243  'active_fi' => ['integer', $this->active_id],
244  'pass' => ['integer', $this->pass],
245  'question_fi' => ['integer', $this->newlyPresentedQuestion]
246  ], []);
247  }
248  }
+ Here is the caller graph for this function:

◆ saveOptionalQuestions()

ilTestSequence::saveOptionalQuestions ( )
private

Definition at line 261 of file class.ilTestSequence.php.

Referenced by saveToDb().

261  : void
262  {
263  $NOT_IN_questions = $this->db->in('question_fi', $this->optionalQuestions, true, 'integer');
264 
265  $this->db->queryF(
266  "DELETE FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s AND $NOT_IN_questions",
267  ['integer', 'integer'],
268  [$this->active_id, $this->pass]
269  );
270 
271  foreach ($this->optionalQuestions as $questionId) {
272  $this->db->replace('tst_seq_qst_optional', [
273  'active_fi' => ['integer', $this->active_id],
274  'pass' => ['integer', $this->pass],
275  'question_fi' => ['integer', (int) $questionId]
276  ], []);
277  }
278  }
+ Here is the caller graph for this function:

◆ saveQuestionSequence()

ilTestSequence::saveQuestionSequence ( )
private

Definition at line 211 of file class.ilTestSequence.php.

References isAnsweringOptionalQuestionsConfirmed(), and null.

Referenced by saveToDb().

211  : void
212  {
213  $postponed = null;
214  if ((is_array($this->sequencedata["postponed"])) && (count($this->sequencedata["postponed"]))) {
215  $postponed = serialize($this->sequencedata["postponed"]);
216  }
217  $hidden = null;
218  if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]))) {
219  $hidden = serialize($this->sequencedata["hidden"]);
220  }
221 
222  $this->db->manipulateF(
223  "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
224  ['integer','integer'],
225  [$this->active_id, $this->pass]
226  );
227 
228  $this->db->insert("tst_sequence", [
229  "active_fi" => ["integer", $this->active_id],
230  "pass" => ["integer", $this->pass],
231  "sequence" => ["clob", serialize($this->sequencedata["sequence"])],
232  "postponed" => ["text", $postponed],
233  "hidden" => ["text", $hidden],
234  "tstamp" => ["integer", time()],
235  'ans_opt_confirmed' => ['integer', (int) $this->isAnsweringOptionalQuestionsConfirmed()]
236  ]);
237  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

ilTestSequence::saveToDb ( )

Saves the sequence data for a given pass to the database.

public

Definition at line 203 of file class.ilTestSequence.php.

References saveNewlyCheckedQuestion(), saveNewlyPresentedQuestion(), saveOptionalQuestions(), and saveQuestionSequence().

Referenced by ilLOTestQuestionAdapter\prepareTestPass().

203  : void
204  {
205  $this->saveQuestionSequence();
207  $this->saveNewlyCheckedQuestion();
208  $this->saveOptionalQuestions();
209  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnsweringOptionalQuestionsConfirmed()

ilTestSequence::setAnsweringOptionalQuestionsConfirmed ( bool  $answeringOptionalQuestionsConfirmed)

Definition at line 758 of file class.ilTestSequence.php.

References $answeringOptionalQuestionsConfirmed.

Referenced by loadQuestionSequence().

758  : void
759  {
760  $this->answeringOptionalQuestionsConfirmed = $answeringOptionalQuestionsConfirmed;
761  }
bool $answeringOptionalQuestionsConfirmed
+ Here is the caller graph for this function:

◆ setConsiderHiddenQuestionsEnabled()

ilTestSequence::setConsiderHiddenQuestionsEnabled ( bool  $considerHiddenQuestionsEnabled)

Definition at line 770 of file class.ilTestSequence.php.

References $considerHiddenQuestionsEnabled.

770  : void
771  {
772  $this->considerHiddenQuestionsEnabled = $considerHiddenQuestionsEnabled;
773  }

◆ setConsiderOptionalQuestionsEnabled()

ilTestSequence::setConsiderOptionalQuestionsEnabled ( bool  $considerOptionalQuestionsEnabled)

Definition at line 780 of file class.ilTestSequence.php.

References $considerOptionalQuestionsEnabled.

780  : void
781  {
782  $this->considerOptionalQuestionsEnabled = $considerOptionalQuestionsEnabled;
783  }
bool $considerOptionalQuestionsEnabled

◆ setPass()

ilTestSequence::setPass ( int  $pass)

Definition at line 648 of file class.ilTestSequence.php.

648  : void
649  {
650  $this->pass = $pass;
651  }

◆ setQuestionChecked()

ilTestSequence::setQuestionChecked ( int  $question_id)

Definition at line 404 of file class.ilTestSequence.php.

404  : void
405  {
406  $this->newlyCheckedQuestion = $question_id;
407  }

◆ setQuestionOptional()

ilTestSequence::setQuestionOptional ( int  $question_id)
Todo:
sk - 2023-05-22: These Optional Questions seem to be something related to the Object Oriented Course, but even asking around, we are actually unsure: Thus marked as to be checked.

Definition at line 712 of file class.ilTestSequence.php.

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

712  : void
713  {
714  $this->optionalQuestions[$question_id] = $question_id;
715  }
+ Here is the caller graph for this function:

◆ setQuestionPresented()

ilTestSequence::setQuestionPresented ( int  $question_id)

Definition at line 371 of file class.ilTestSequence.php.

371  : void
372  {
373  $this->newlyPresentedQuestion = $question_id;
374  }

Field Documentation

◆ $alreadyCheckedQuestions

array ilTestSequence::$alreadyCheckedQuestions = []
protected

Definition at line 49 of file class.ilTestSequence.php.

◆ $alreadyPresentedQuestions

array ilTestSequence::$alreadyPresentedQuestions = []
protected

Definition at line 43 of file class.ilTestSequence.php.

◆ $answeringOptionalQuestionsConfirmed

bool ilTestSequence::$answeringOptionalQuestionsConfirmed = false
private

◆ $considerHiddenQuestionsEnabled

bool ilTestSequence::$considerHiddenQuestionsEnabled = false
private

◆ $considerOptionalQuestionsEnabled

bool ilTestSequence::$considerOptionalQuestionsEnabled = true
private

◆ $newlyCheckedQuestion

int ilTestSequence::$newlyCheckedQuestion = null
protected

Definition at line 50 of file class.ilTestSequence.php.

◆ $newlyPresentedQuestion

int ilTestSequence::$newlyPresentedQuestion = 0
protected

Definition at line 44 of file class.ilTestSequence.php.

◆ $optionalQuestions

array ilTestSequence::$optionalQuestions = []
protected

Definition at line 54 of file class.ilTestSequence.php.

Referenced by getOptionalQuestions().

◆ $questions

array ilTestSequence::$questions

The mapping of the sequence numbers to the questions.

Definition at line 42 of file class.ilTestSequence.php.

Referenced by getOrderedSequenceQuestions().

◆ $sequencedata

array ilTestSequence::$sequencedata

An array containing the sequence data.

Definition at line 37 of file class.ilTestSequence.php.


The documentation for this class was generated from the following file: