ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilTestSequence Class Reference

Test sequence handler. More...

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

Public Member Functions

 __construct ($active_id, $pass, $randomtest)
 ilTestSequence constructor More...
 
 getActiveId ()
 
 createNewSequence ($max, $shuffle)
 
 loadQuestions (ilTestQuestionSetConfig $testQuestionSetConfig=null, $taxonomyFilterSelection=array())
 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 ($question_id)
 
 hideQuestion ($question_id)
 
 isPostponedQuestion ($question_id)
 
 isHiddenQuestion ($question_id)
 
 isPostponedSequence ($sequence)
 
 isHiddenSequence ($sequence)
 
 postponeSequence ($sequence)
 
 hideSequence ($sequence)
 
 setQuestionPresented ($questionId)
 
 isQuestionPresented ($questionId)
 
 isNextQuestionPresented ($questionId)
 
 setQuestionChecked ($questionId)
 
 isQuestionChecked ($questionId)
 
 getPositionOfSequence ($sequence)
 
 getUserQuestionCount ()
 
 getOrderedSequence ()
 
 getOrderedSequenceQuestions ()
 
 getUserSequence ()
 
 getUserSequenceQuestions ()
 
 getSequenceForQuestion ($question_id)
 
 getFirstSequence ()
 
 getLastSequence ()
 
 getNextSequence ($sequence)
 
 getPreviousSequence ($sequence)
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getQuestionForSequence ($sequence)
 
 getSequenceSummary ($obligationsFilterEnabled=false)
 
 getPass ()
 
 setPass ($pass)
 
 hasSequence ()
 
 hasHiddenQuestions ()
 
 clearHiddenQuestions ()
 
 hasStarted (ilTestSession $testSession)
 
 openQuestionExists ()
 
 getQuestionIds ()
 
 questionExists ($questionId)
 
 setQuestionOptional ($questionId)
 
 isQuestionOptional ($questionId)
 
 hasOptionalQuestions ()
 
 getOptionalQuestions ()
 
 clearOptionalQuestions ()
 
 reorderOptionalQuestionsToSequenceEnd ()
 
 isAnsweringOptionalQuestionsConfirmed ()
 
 setAnsweringOptionalQuestionsConfirmed ($answeringOptionalQuestionsConfirmed)
 
 isConsiderHiddenQuestionsEnabled ()
 
 setConsiderHiddenQuestionsEnabled ($considerHiddenQuestionsEnabled)
 
 isConsiderOptionalQuestionsEnabled ()
 
 setConsiderOptionalQuestionsEnabled ($considerOptionalQuestionsEnabled)
 
 getQuestionIds ()
 
 getActiveId ()
 
 getSequenceSummary ($obligationsFilterEnabled=false)
 

Data Fields

 $sequencedata
 
 $questions
 
 $active_id
 
 $pass
 
 $isRandomTest
 

Protected Member Functions

 loadPresentedQuestions ()
 
 saveNewlyPresentedQuestion ()
 
 getCorrectedSequence ()
 

Protected Attributes

 $alreadyPresentedQuestions = array()
 
 $newlyPresentedQuestion = 0
 
 $alreadyCheckedQuestions
 
 $newlyCheckedQuestion
 
 $optionalQuestions
 

Private Member Functions

 loadQuestionSequence ()
 
 loadCheckedQuestions ()
 
 loadOptionalQuestions ()
 
 saveQuestionSequence ()
 
 saveNewlyCheckedQuestion ()
 @global ilDBInterface $ilDB More...
 
 saveOptionalQuestions ()
 @global ilDBInterface $ilDB More...
 
 ensureQuestionNotInSequence ($sequence, $questionId)
 
 hideCorrectAnsweredQuestions (ilObjTest $testOBJ, $activeId, $pass)
 

Private Attributes

 $answeringOptionalQuestionsConfirmed
 
 $considerHiddenQuestionsEnabled
 
 $considerOptionalQuestionsEnabled
 

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 16 of file class.ilTestSequence.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSequence::__construct (   $active_id,
  $pass,
  $randomtest 
)

ilTestSequence constructor

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

Parameters
object$a_objectA reference to the test container object @access public

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

103 {
104 $this->active_id = $active_id;
105 $this->pass = $pass;
106 $this->isRandomTest = $randomtest;
107 $this->sequencedata = array(
108 "sequence" => array(),
109 "postponed" => array(),
110 "hidden" => array()
111 );
112
113 $this->alreadyCheckedQuestions = array();
114 $this->newlyCheckedQuestion = null;
115
116 $this->optionalQuestions = array();
117 $this->answeringOptionalQuestionsConfirmed = false;
118
119 $this->considerHiddenQuestionsEnabled = false;
120 $this->considerOptionalQuestionsEnabled = true;
121 }

References $active_id, and $pass.

Member Function Documentation

◆ clearHiddenQuestions()

ilTestSequence::clearHiddenQuestions ( )

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

762 {
763 $this->sequencedata["hidden"] = array();
764 }

Referenced by ilLOTestQuestionAdapter\hideQuestions().

+ Here is the caller graph for this function:

◆ clearOptionalQuestions()

ilTestSequence::clearOptionalQuestions ( )

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

833 {
834 $this->optionalQuestions = array();
835 }

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

+ Here is the caller graph for this function:

◆ createNewSequence()

ilTestSequence::createNewSequence (   $max,
  $shuffle 
)

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

129 {
130 $newsequence = array();
131 if ($max > 0) {
132 for ($i = 1; $i <= $max; $i++) {
133 array_push($newsequence, $i);
134 }
135 if ($shuffle) {
136 $newsequence = $this->pcArrayShuffle($newsequence);
137 }
138 }
139 $this->sequencedata["sequence"] = $newsequence;
140 }
pcArrayShuffle($array)
Shuffles the values of a given array.
$i
Definition: metadata.php:24

References $i, and pcArrayShuffle().

+ Here is the call graph for this function:

◆ ensureQuestionNotInSequence()

ilTestSequence::ensureQuestionNotInSequence (   $sequence,
  $questionId 
)
private

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

560 {
561 $questionKey = array_search($questionId, $this->questions);
562
563 if ($questionKey === false) {
564 return $sequence;
565 }
566
567 $sequenceKey = array_search($questionKey, $sequence);
568
569 if ($sequenceKey === false) {
570 return $sequence;
571 }
572
573 unset($sequence[$sequenceKey]);
574
575 return $sequence;
576 }

Referenced by getCorrectedSequence().

+ Here is the caller graph for this function:

◆ getActiveId()

ilTestSequence::getActiveId ( )

Implements ilTestSequenceSummaryProvider.

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

124 {
125 return $this->active_id;
126 }

References $active_id.

◆ getCorrectedSequence()

ilTestSequence::getCorrectedSequence ( )
protected

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

579 {
580 $correctedsequence = $this->sequencedata["sequence"];
581 if (!$this->isConsiderHiddenQuestionsEnabled()) {
582 if (is_array($this->sequencedata["hidden"])) {
583 foreach ($this->sequencedata["hidden"] as $question_id) {
584 $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $question_id);
585 }
586 }
587 }
589 foreach ($this->optionalQuestions as $questionId) {
590 $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $questionId);
591 }
592 }
593 if (is_array($this->sequencedata["postponed"])) {
594 foreach ($this->sequencedata["postponed"] as $question_id) {
595 $foundsequence = array_search($question_id, $this->questions);
596 if ($foundsequence !== false) {
597 $sequencekey = array_search($foundsequence, $correctedsequence);
598 if ($sequencekey !== false) {
599 unset($correctedsequence[$sequencekey]);
600 array_push($correctedsequence, $foundsequence);
601 }
602 }
603 }
604 }
605 return array_values($correctedsequence);
606 }
ensureQuestionNotInSequence($sequence, $questionId)

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFirstSequence()

ilTestSequence::getFirstSequence ( )

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

614 {
615 $correctedsequence = $this->getCorrectedSequence();
616 if (count($correctedsequence)) {
617 return reset($correctedsequence);
618 } else {
619 return false;
620 }
621 }

References getCorrectedSequence().

Referenced by openQuestionExists().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastSequence()

ilTestSequence::getLastSequence ( )

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

624 {
625 $correctedsequence = $this->getCorrectedSequence();
626 if (count($correctedsequence)) {
627 return end($correctedsequence);
628 } else {
629 return false;
630 }
631 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getNextSequence()

ilTestSequence::getNextSequence (   $sequence)

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

634 {
635 $correctedsequence = $this->getCorrectedSequence();
636 $sequencekey = array_search($sequence, $correctedsequence);
637 if ($sequencekey !== false) {
638 $nextsequencekey = $sequencekey + 1;
639 if (array_key_exists($nextsequencekey, $correctedsequence)) {
640 return $correctedsequence[$nextsequencekey];
641 }
642 }
643 return false;
644 }

References getCorrectedSequence().

Referenced by isNextQuestionPresented().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOptionalQuestions()

ilTestSequence::getOptionalQuestions ( )

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

828 {
830 }

References $optionalQuestions.

◆ getOrderedSequence()

ilTestSequence::getOrderedSequence ( )

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

507 {
508 $sequenceKeys = array();
509
510 foreach (array_keys($this->questions) as $sequenceKey) {
511 if ($this->isHiddenSequence($sequenceKey) && !$this->isConsiderHiddenQuestionsEnabled()) {
512 continue;
513 }
514
515 if ($this->isSequenceOptional($sequenceKey) && !$this->isConsiderOptionalQuestionsEnabled()) {
516 continue;
517 }
518
519 $sequenceKeys[] = $sequenceKey;
520 }
521
522 return $sequenceKeys;
523 }

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

+ Here is the call graph for this function:

◆ getOrderedSequenceQuestions()

ilTestSequence::getOrderedSequenceQuestions ( )

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

526 {
527 $questions = array();
528
529 foreach ($this->questions as $questionId) {
530 if ($this->isHiddenQuestion($questionId) && !$this->isConsiderHiddenQuestionsEnabled()) {
531 continue;
532 }
533
534 if ($this->isQuestionOptional($questionId) && !$this->isConsiderOptionalQuestionsEnabled()) {
535 continue;
536 }
537
538 $questions[] = $questionId;
539 }
540
541 return $questions;
542 }
isHiddenQuestion($question_id)
isQuestionOptional($questionId)

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

+ Here is the call graph for this function:

◆ getPass()

ilTestSequence::getPass ( )

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

734 {
735 return $this->pass;
736 }

References $pass.

◆ getPositionOfSequence()

ilTestSequence::getPositionOfSequence (   $sequence)

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

491 {
492 $correctedsequence = $this->getCorrectedSequence();
493 $sequencekey = array_search($sequence, $correctedsequence);
494 if ($sequencekey !== false) {
495 return $sequencekey + 1;
496 } else {
497 return "";
498 }
499 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getPreviousSequence()

ilTestSequence::getPreviousSequence (   $sequence)

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

647 {
648 $correctedsequence = $this->getCorrectedSequence();
649 $sequencekey = array_search($sequence, $correctedsequence);
650 if ($sequencekey !== false) {
651 $prevsequencekey = $sequencekey - 1;
652 if (($prevsequencekey >= 0) && (array_key_exists($prevsequencekey, $correctedsequence))) {
653 return $correctedsequence[$prevsequencekey];
654 }
655 }
656 return false;
657 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getQuestionForSequence()

ilTestSequence::getQuestionForSequence (   $sequence)

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

679 {
680 if ($sequence < 1) {
681 return false;
682 }
683 if (array_key_exists($sequence, $this->questions)) {
684 return $this->questions[$sequence];
685 } else {
686 return false;
687 }
688 }

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

+ Here is the caller graph for this function:

◆ getQuestionIds()

ilTestSequence::getQuestionIds ( )

Implements ilTestQuestionSequence.

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

803 {
804 return array_values($this->questions);
805 }

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

+ Here is the caller graph for this function:

◆ getSequenceForQuestion()

ilTestSequence::getSequenceForQuestion (   $question_id)

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

609 {
610 return array_search($question_id, $this->questions);
611 }

Referenced by isNextQuestionPresented().

+ Here is the caller graph for this function:

◆ getSequenceSummary()

ilTestSequence::getSequenceSummary (   $obligationsFilterEnabled = false)

Implements ilTestSequenceSummaryProvider.

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

691 {
692 $correctedsequence = $this->getCorrectedSequence();
693 $result_array = array();
694 include_once "./Modules/Test/classes/class.ilObjTest.php";
695 $solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
696 $key = 1;
697 foreach ($correctedsequence as $sequence) {
698 $question = &ilObjTest::_instanciateQuestion($this->getQuestionForSequence($sequence));
699 if (is_object($question)) {
700 $worked_through = $question->_isWorkedThrough($this->active_id, $question->getId(), $this->pass);
701 $solved = 0;
702 if (array_key_exists($question->getId(), $solved_questions)) {
703 $solved = $solved_questions[$question->getId()]["solved"];
704 }
705 $is_postponed = $this->isPostponedQuestion($question->getId());
706
707 $row = array(
708 "nr" => "$key",
709 "title" => $question->getTitle(),
710 "qid" => $question->getId(),
711 "presented" => $this->isQuestionPresented($question->getId()),
712 "visited" => $worked_through,
713 "solved" => (($solved)?"1":"0"),
714 "description" => $question->getComment(),
715 "points" => $question->getMaximumPoints(),
716 "worked_through" => $worked_through,
717 "postponed" => $is_postponed,
718 "sequence" => $sequence,
719 "obligatory" => ilObjTest::isQuestionObligatory($question->getId()),
720 'isAnswered' => $question->isAnswered($this->active_id, $this->pass)
721 );
722
723 if (!$obligationsFilterEnabled || $row['obligatory']) {
724 array_push($result_array, $row);
725 }
726
727 $key++;
728 }
729 }
730 return $result_array;
731 }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
static isQuestionObligatory($question_id)
checks wether the question with given id is marked as obligatory or not
getQuestionForSequence($sequence)
isPostponedQuestion($question_id)

References ilObjTest\_getSolvedQuestions(), ilObjTest\_instanciateQuestion(), getCorrectedSequence(), getQuestionForSequence(), isPostponedQuestion(), and ilObjTest\isQuestionObligatory().

+ Here is the call graph for this function:

◆ getUserQuestionCount()

ilTestSequence::getUserQuestionCount ( )

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

502 {
503 return count($this->getCorrectedSequence());
504 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getUserSequence()

ilTestSequence::getUserSequence ( )

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

545 {
546 return $this->getCorrectedSequence();
547 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequence::getUserSequenceQuestions ( )

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

550 {
551 $seq = $this->getCorrectedSequence();
552 $found = array();
553 foreach ($seq as $sequence) {
554 array_push($found, $this->getQuestionForSequence($sequence));
555 }
556 return $found;
557 }

References getCorrectedSequence(), and getQuestionForSequence().

+ Here is the call graph for this function:

◆ hasHiddenQuestions()

ilTestSequence::hasHiddenQuestions ( )

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

753 {
754 if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]) > 0)) {
755 return true;
756 } else {
757 return false;
758 }
759 }

◆ hasOptionalQuestions()

ilTestSequence::hasOptionalQuestions ( )

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

823 {
824 return (bool) count($this->optionalQuestions);
825 }

◆ hasSequence()

ilTestSequence::hasSequence ( )

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

744 {
745 if ((is_array($this->sequencedata["sequence"])) && (count($this->sequencedata["sequence"]) > 0)) {
746 return true;
747 } else {
748 return false;
749 }
750 }

◆ hasStarted()

ilTestSequence::hasStarted ( ilTestSession  $testSession)

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

784 {
785 if ($testSession->getLastSequence() < 1) {
786 return false;
787 }
788
789 // WTF ?? heard about tests with only one question !?
790 if ($testSession->getLastSequence() == $this->getFirstSequence()) {
791 return false;
792 }
793
794 return true;
795 }

References ilTestSession\getLastSequence().

+ Here is the call graph for this function:

◆ hideCorrectAnsweredQuestions()

ilTestSequence::hideCorrectAnsweredQuestions ( ilObjTest  $testOBJ,
  $activeId,
  $pass 
)
private

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

767 {
768 if ($activeId > 0) {
769 $result = $testOBJ->getTestResult($activeId, $pass, true);
770
771 foreach ($result as $sequence => $question) {
772 if (is_numeric($sequence)) {
773 if ($question['reached'] == $question['max']) {
774 $this->hideQuestion($question['qid']);
775 }
776 }
777 }
778
779 $this->saveToDb();
780 }
781 }
$result
& getTestResult($active_id, $pass=null, $ordered_sequence=false, $considerHiddenQuestions=true, $considerOptionalQuestions=true)
Calculates the results of a test for a given user and returns an array with all test results.
hideQuestion($question_id)
saveToDb()
Saves the sequence data for a given pass to the database.

References $pass, $result, ilObjTest\getTestResult(), hideQuestion(), and saveToDb().

+ Here is the call graph for this function:

◆ hideQuestion()

ilTestSequence::hideQuestion (   $question_id)

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

363 {
364 if (!$this->isHiddenQuestion($question_id)) {
365 array_push($this->sequencedata["hidden"], intval($question_id));
366 }
367 }

References isHiddenQuestion().

Referenced by hideCorrectAnsweredQuestions(), and ilLOTestQuestionAdapter\hideQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hideSequence()

ilTestSequence::hideSequence (   $sequence)

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

436 {
437 if (!$this->isHiddenSequence($sequence)) {
438 if (array_key_exists($sequence, $this->questions)) {
439 if (!is_array($this->sequencedata["hidden"])) {
440 $this->sequencedata["hidden"] = array();
441 }
442 array_push($this->sequencedata["hidden"], intval($this->questions[$sequence]));
443 }
444 }
445 }

References isHiddenSequence().

+ Here is the call graph for this function:

◆ isAnsweringOptionalQuestionsConfirmed()

ilTestSequence::isAnsweringOptionalQuestionsConfirmed ( )
Returns
boolean

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

References $answeringOptionalQuestionsConfirmed.

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

+ Here is the caller graph for this function:

◆ isConsiderHiddenQuestionsEnabled()

ilTestSequence::isConsiderHiddenQuestionsEnabled ( )
Returns
boolean

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

References $considerHiddenQuestionsEnabled.

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

+ Here is the caller graph for this function:

◆ isConsiderOptionalQuestionsEnabled()

ilTestSequence::isConsiderOptionalQuestionsEnabled ( )
Returns
boolean

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

References $considerOptionalQuestionsEnabled.

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

+ Here is the caller graph for this function:

◆ isHiddenQuestion()

ilTestSequence::isHiddenQuestion (   $question_id)

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

382 {
383 if (!is_array($this->sequencedata["hidden"])) {
384 return false;
385 }
386 if (!in_array($question_id, $this->sequencedata["hidden"])) {
387 return false;
388 } else {
389 return true;
390 }
391 }

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

+ Here is the caller graph for this function:

◆ isHiddenSequence()

ilTestSequence::isHiddenSequence (   $sequence)

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

409 {
410 if (!array_key_exists($sequence, $this->questions)) {
411 return false;
412 }
413 if (!is_array($this->sequencedata["hidden"])) {
414 return false;
415 }
416 if (!in_array($this->questions[$sequence], $this->sequencedata["hidden"])) {
417 return false;
418 } else {
419 return true;
420 }
421 }

Referenced by getOrderedSequence(), and hideSequence().

+ Here is the caller graph for this function:

◆ isNextQuestionPresented()

ilTestSequence::isNextQuestionPresented (   $questionId)

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

460 {
461 $nextQstId = $this->getQuestionForSequence(
462 $this->getNextSequence($this->getSequenceForQuestion($questionId))
463 );
464
465 if (!$nextQstId) {
466 return false;
467 }
468
469 if ($this->newlyPresentedQuestion == $nextQstId) {
470 return true;
471 }
472
473 if (in_array($nextQstId, $this->alreadyPresentedQuestions)) {
474 return true;
475 }
476
477 return false;
478 }
getSequenceForQuestion($question_id)

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

+ Here is the call graph for this function:

◆ isPostponedQuestion()

ilTestSequence::isPostponedQuestion (   $question_id)

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

370 {
371 if (!is_array($this->sequencedata["postponed"])) {
372 return false;
373 }
374 if (!in_array($question_id, $this->sequencedata["postponed"])) {
375 return false;
376 } else {
377 return true;
378 }
379 }

Referenced by getSequenceSummary(), and postponeQuestion().

+ Here is the caller graph for this function:

◆ isPostponedSequence()

ilTestSequence::isPostponedSequence (   $sequence)

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

394 {
395 if (!array_key_exists($sequence, $this->questions)) {
396 return false;
397 }
398 if (!is_array($this->sequencedata["postponed"])) {
399 return false;
400 }
401 if (!in_array($this->questions[$sequence], $this->sequencedata["postponed"])) {
402 return false;
403 } else {
404 return true;
405 }
406 }

Referenced by postponeSequence().

+ Here is the caller graph for this function:

◆ isQuestionChecked()

ilTestSequence::isQuestionChecked (   $questionId)

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

486 {
487 return isset($this->alreadyCheckedQuestions[$questionId]);
488 }

◆ isQuestionOptional()

ilTestSequence::isQuestionOptional (   $questionId)

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

818 {
819 return isset($this->optionalQuestions[$questionId]);
820 }

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

+ Here is the caller graph for this function:

◆ isQuestionPresented()

ilTestSequence::isQuestionPresented (   $questionId)

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

453 {
454 return (
455 $this->newlyPresentedQuestion == $questionId || in_array($questionId, $this->alreadyPresentedQuestions)
456 );
457 }

◆ loadCheckedQuestions()

ilTestSequence::loadCheckedQuestions ( )
private

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

225 {
226 global $DIC;
227 $ilDB = $DIC['ilDB'];
228
229 $res = $ilDB->queryF(
230 "SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
231 array('integer','integer'),
232 array($this->active_id, $this->pass)
233 );
234
235 while ($row = $ilDB->fetchAssoc($res)) {
236 $this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
237 }
238 }
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, and $res.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ loadFromDb()

ilTestSequence::loadFromDb ( )

Loads the sequence data for a given active id.

Returns
string The filesystem path of the certificate

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

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

+ Here is the call graph for this function:

◆ loadOptionalQuestions()

ilTestSequence::loadOptionalQuestions ( )
private

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

241 {
242 global $DIC;
243 $ilDB = $DIC['ilDB'];
244
245 $res = $ilDB->queryF(
246 "SELECT question_fi FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s",
247 array('integer','integer'),
248 array($this->active_id, $this->pass)
249 );
250
251 while ($row = $ilDB->fetchAssoc($res)) {
252 $this->optionalQuestions[ $row['question_fi'] ] = $row['question_fi'];
253 }
254 }

References $DIC, $ilDB, and $res.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ loadPresentedQuestions()

ilTestSequence::loadPresentedQuestions ( )
protected

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

210 {
211 global $DIC; /* @var ILIAS\DI\Container $DIC */
212
213 $res = $DIC->database()->queryF(
214 "SELECT question_fi FROM tst_seq_qst_presented WHERE active_fi = %s AND pass = %s",
215 array('integer','integer'),
216 array($this->active_id, $this->pass)
217 );
218
219 while ($row = $DIC->database()->fetchAssoc($res)) {
220 $this->alreadyPresentedQuestions[ $row['question_fi'] ] = $row['question_fi'];
221 }
222 }

References $DIC, and $res.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ loadQuestions()

ilTestSequence::loadQuestions ( ilTestQuestionSetConfig  $testQuestionSetConfig = null,
  $taxonomyFilterSelection = array() 
)

Loads the question mapping.

Reimplemented in ilTestSequenceRandomQuestionSet.

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

146 {
147 global $DIC;
148 $ilDB = $DIC['ilDB'];
149
150 $this->questions = array();
151
152 $result = $ilDB->queryF(
153 "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",
154 array('integer'),
155 array($this->active_id)
156 );
157
158 $index = 1;
159
160 // TODO bheyser: There might be "sequence" gaps which lead to issues with tst_sequence when deleting/adding questions before any participant starts the test
161 while ($data = $ilDB->fetchAssoc($result)) {
162 $this->questions[$index++] = $data["question_fi"];
163 }
164 }
$index
Definition: metadata.php:128
$data
Definition: storeScorm.php:23

References $data, $DIC, $ilDB, $index, and $result.

◆ loadQuestionSequence()

ilTestSequence::loadQuestionSequence ( )
private

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

180 {
181 global $DIC;
182 $ilDB = $DIC['ilDB'];
183 $result = $ilDB->queryF(
184 "SELECT * FROM tst_sequence WHERE active_fi = %s AND pass = %s",
185 array('integer','integer'),
186 array($this->active_id, $this->pass)
187 );
188 if ($result->numRows()) {
189 $row = $ilDB->fetchAssoc($result);
190 $this->sequencedata = array(
191 "sequence" => unserialize($row["sequence"]),
192 "postponed" => unserialize($row["postponed"]),
193 "hidden" => unserialize($row["hidden"])
194 );
195 if (!is_array($this->sequencedata["sequence"])) {
196 $this->sequencedata["sequence"] = array();
197 }
198 if (!is_array($this->sequencedata["postponed"])) {
199 $this->sequencedata["postponed"] = array();
200 }
201 if (!is_array($this->sequencedata["hidden"])) {
202 $this->sequencedata["hidden"] = array();
203 }
204
205 $this->setAnsweringOptionalQuestionsConfirmed((bool) $row['ans_opt_confirmed']);
206 }
207 }
setAnsweringOptionalQuestionsConfirmed($answeringOptionalQuestionsConfirmed)

References $DIC, $ilDB, $result, and setAnsweringOptionalQuestionsConfirmed().

Referenced by loadFromDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openQuestionExists()

ilTestSequence::openQuestionExists ( )

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

798 {
799 return $this->getFirstSequence() !== false;
800 }

References getFirstSequence().

+ Here is the call graph for this function:

◆ pcArrayShuffle()

ilTestSequence::pcArrayShuffle (   $array)

Shuffles the values of a given array.

Shuffles the values of a given array

Parameters
array$arrayAn array which should be shuffled @access public

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

668 {
669 $keys = array_keys($array);
670 shuffle($keys);
671 $result = array();
672 foreach ($keys as $key) {
673 $result[$key] = $array[$key];
674 }
675 return $result;
676 }
$keys
Definition: metadata.php:187

References $keys, and $result.

Referenced by createNewSequence().

+ Here is the caller graph for this function:

◆ postponeQuestion()

ilTestSequence::postponeQuestion (   $question_id)

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

356 {
357 if (!$this->isPostponedQuestion($question_id)) {
358 array_push($this->sequencedata["postponed"], intval($question_id));
359 }
360 }

References isPostponedQuestion().

+ Here is the call graph for this function:

◆ postponeSequence()

ilTestSequence::postponeSequence (   $sequence)

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

424 {
425 if (!$this->isPostponedSequence($sequence)) {
426 if (array_key_exists($sequence, $this->questions)) {
427 if (!is_array($this->sequencedata["postponed"])) {
428 $this->sequencedata["postponed"] = array();
429 }
430 array_push($this->sequencedata["postponed"], intval($this->questions[$sequence]));
431 }
432 }
433 }
isPostponedSequence($sequence)

References isPostponedSequence().

+ Here is the call graph for this function:

◆ questionExists()

ilTestSequence::questionExists (   $questionId)

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

808 {
809 return in_array($questionId, $this->questions);
810 }

◆ reorderOptionalQuestionsToSequenceEnd()

ilTestSequence::reorderOptionalQuestionsToSequenceEnd ( )

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

838 {
839 $optionalSequenceKeys = array();
840
841 foreach ($this->sequencedata['sequence'] as $index => $sequenceKey) {
842 if ($this->isQuestionOptional($this->getQuestionForSequence($sequenceKey))) {
843 $optionalSequenceKeys[$index] = $sequenceKey;
844 unset($this->sequencedata['sequence'][$index]);
845 }
846 }
847
848 foreach ($optionalSequenceKeys as $index => $sequenceKey) {
849 $this->sequencedata['sequence'][$index] = $sequenceKey;
850 }
851 }

References $index, getQuestionForSequence(), and isQuestionOptional().

+ Here is the call graph for this function:

◆ saveNewlyCheckedQuestion()

ilTestSequence::saveNewlyCheckedQuestion ( )
private

@global ilDBInterface $ilDB

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

317 {
318 if ((int) $this->newlyCheckedQuestion) {
319 global $DIC;
320 $ilDB = $DIC['ilDB'];
321
322 $ilDB->replace('tst_seq_qst_checked', array(
323 'active_fi' => array('integer', (int) $this->active_id),
324 'pass' => array('integer', (int) $this->pass),
325 'question_fi' => array('integer', (int) $this->newlyCheckedQuestion)
326 ), array());
327 }
328 }

References $DIC, and $ilDB.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveNewlyPresentedQuestion()

ilTestSequence::saveNewlyPresentedQuestion ( )
protected

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

301 {
302 if ((int) $this->newlyPresentedQuestion) {
303 global $DIC; /* @var ILIAS\DI\Container $DIC */
304
305 $DIC->database()->replace('tst_seq_qst_presented', array(
306 'active_fi' => array('integer', (int) $this->active_id),
307 'pass' => array('integer', (int) $this->pass),
308 'question_fi' => array('integer', (int) $this->newlyPresentedQuestion)
309 ), array());
310 }
311 }

References $DIC.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveOptionalQuestions()

ilTestSequence::saveOptionalQuestions ( )
private

@global ilDBInterface $ilDB

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

334 {
335 global $DIC;
336 $ilDB = $DIC['ilDB'];
337
338 $NOT_IN_questions = $ilDB->in('question_fi', $this->optionalQuestions, true, 'integer');
339
340 $ilDB->queryF(
341 "DELETE FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s AND $NOT_IN_questions",
342 array('integer', 'integer'),
343 array($this->active_id, $this->pass)
344 );
345
346 foreach ($this->optionalQuestions as $questionId) {
347 $ilDB->replace('tst_seq_qst_optional', array(
348 'active_fi' => array('integer', (int) $this->active_id),
349 'pass' => array('integer', (int) $this->pass),
350 'question_fi' => array('integer', (int) $questionId)
351 ), array());
352 }
353 }

References $DIC, and $ilDB.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveQuestionSequence()

ilTestSequence::saveQuestionSequence ( )
private

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

270 {
271 global $DIC;
272 $ilDB = $DIC['ilDB'];
273
274 $postponed = null;
275 if ((is_array($this->sequencedata["postponed"])) && (count($this->sequencedata["postponed"]))) {
276 $postponed = serialize($this->sequencedata["postponed"]);
277 }
278 $hidden = null;
279 if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]))) {
280 $hidden = serialize($this->sequencedata["hidden"]);
281 }
282
283 $affectedRows = $ilDB->manipulateF(
284 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
285 array('integer','integer'),
286 array($this->active_id, $this->pass)
287 );
288
289 $affectedRows = $ilDB->insert("tst_sequence", array(
290 "active_fi" => array("integer", $this->active_id),
291 "pass" => array("integer", $this->pass),
292 "sequence" => array("clob", serialize($this->sequencedata["sequence"])),
293 "postponed" => array("text", $postponed),
294 "hidden" => array("text", $hidden),
295 "tstamp" => array("integer", time()),
296 'ans_opt_confirmed' => array('integer', (int) $this->isAnsweringOptionalQuestionsConfirmed())
297 ));
298 }

References $DIC, $ilDB, and isAnsweringOptionalQuestionsConfirmed().

Referenced by saveToDb().

+ 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.

@access public

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

262 {
263 $this->saveQuestionSequence();
266 $this->saveOptionalQuestions();
267 }
saveNewlyCheckedQuestion()
@global ilDBInterface $ilDB
saveOptionalQuestions()
@global ilDBInterface $ilDB

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

Referenced by hideCorrectAnsweredQuestions(), and ilLOTestQuestionAdapter\prepareTestPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnsweringOptionalQuestionsConfirmed()

ilTestSequence::setAnsweringOptionalQuestionsConfirmed (   $answeringOptionalQuestionsConfirmed)
Parameters
boolean$answeringOptionalQuestionsConfirmed

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

865 {
866 $this->answeringOptionalQuestionsConfirmed = $answeringOptionalQuestionsConfirmed;
867 }

References $answeringOptionalQuestionsConfirmed.

Referenced by loadQuestionSequence().

+ Here is the caller graph for this function:

◆ setConsiderHiddenQuestionsEnabled()

ilTestSequence::setConsiderHiddenQuestionsEnabled (   $considerHiddenQuestionsEnabled)
Parameters
boolean$considerHiddenQuestionsEnabled

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

881 {
882 $this->considerHiddenQuestionsEnabled = $considerHiddenQuestionsEnabled;
883 }

References $considerHiddenQuestionsEnabled.

◆ setConsiderOptionalQuestionsEnabled()

ilTestSequence::setConsiderOptionalQuestionsEnabled (   $considerOptionalQuestionsEnabled)
Parameters
boolean$considerOptionalQuestionsEnabled

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

897 {
898 $this->considerOptionalQuestionsEnabled = $considerOptionalQuestionsEnabled;
899 }

References $considerOptionalQuestionsEnabled.

◆ setPass()

ilTestSequence::setPass (   $pass)

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

739 {
740 $this->pass = $pass;
741 }

References $pass.

◆ setQuestionChecked()

ilTestSequence::setQuestionChecked (   $questionId)

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

481 {
482 $this->newlyCheckedQuestion = $questionId;
483 }

◆ setQuestionOptional()

ilTestSequence::setQuestionOptional (   $questionId)

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

813 {
814 $this->optionalQuestions[$questionId] = $questionId;
815 }

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

+ Here is the caller graph for this function:

◆ setQuestionPresented()

ilTestSequence::setQuestionPresented (   $questionId)

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

448 {
449 $this->newlyPresentedQuestion = $questionId;
450 }

Field Documentation

◆ $active_id

ilTestSequence::$active_id

◆ $alreadyCheckedQuestions

ilTestSequence::$alreadyCheckedQuestions
protected

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

◆ $alreadyPresentedQuestions

ilTestSequence::$alreadyPresentedQuestions = array()
protected

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

◆ $answeringOptionalQuestionsConfirmed

ilTestSequence::$answeringOptionalQuestionsConfirmed
private

◆ $considerHiddenQuestionsEnabled

ilTestSequence::$considerHiddenQuestionsEnabled
private

◆ $considerOptionalQuestionsEnabled

ilTestSequence::$considerOptionalQuestionsEnabled
private

◆ $isRandomTest

ilTestSequence::$isRandomTest

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

◆ $newlyCheckedQuestion

ilTestSequence::$newlyCheckedQuestion
protected

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

◆ $newlyPresentedQuestion

ilTestSequence::$newlyPresentedQuestion = 0
protected

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

◆ $optionalQuestions

ilTestSequence::$optionalQuestions
protected

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

Referenced by getOptionalQuestions().

◆ $pass

◆ $questions

ilTestSequence::$questions

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

Referenced by getOrderedSequenceQuestions().

◆ $sequencedata

ilTestSequence::$sequencedata

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


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