ILIAS  release_8 Revision v8.24
ilTestSequence Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 28 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 114 of file class.ilTestSequence.php.

115 {
116 $this->active_id = $active_id;
117 $this->pass = $pass;
118 $this->isRandomTest = $randomtest;
119 $this->sequencedata = array(
120 "sequence" => array(),
121 "postponed" => array(),
122 "hidden" => array()
123 );
124
125 $this->alreadyCheckedQuestions = array();
126 $this->newlyCheckedQuestion = null;
127
128 $this->optionalQuestions = array();
129 $this->answeringOptionalQuestionsConfirmed = false;
130
131 $this->considerHiddenQuestionsEnabled = false;
132 $this->considerOptionalQuestionsEnabled = true;
133 }

References $active_id, and $pass.

Member Function Documentation

◆ clearHiddenQuestions()

ilTestSequence::clearHiddenQuestions ( )

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

774 {
775 $this->sequencedata["hidden"] = array();
776 }

Referenced by ilLOTestQuestionAdapter\hideQuestions().

+ Here is the caller graph for this function:

◆ clearOptionalQuestions()

ilTestSequence::clearOptionalQuestions ( )

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

845 {
846 $this->optionalQuestions = array();
847 }

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

+ Here is the caller graph for this function:

◆ createNewSequence()

ilTestSequence::createNewSequence (   $max,
  $shuffle 
)

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

141 {
142 $newsequence = array();
143 if ($max > 0) {
144 for ($i = 1; $i <= $max; $i++) {
145 array_push($newsequence, $i);
146 }
147 if ($shuffle) {
148 $newsequence = $this->pcArrayShuffle($newsequence);
149 }
150 }
151 $this->sequencedata["sequence"] = $newsequence;
152 }
pcArrayShuffle($array)
Shuffles the values of a given array.
$i
Definition: metadata.php:41

References $i, and pcArrayShuffle().

+ Here is the call graph for this function:

◆ ensureQuestionNotInSequence()

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

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

572 {
573 $questionKey = array_search($questionId, $this->questions);
574
575 if ($questionKey === false) {
576 return $sequence;
577 }
578
579 $sequenceKey = array_search($questionKey, $sequence);
580
581 if ($sequenceKey === false) {
582 return $sequence;
583 }
584
585 unset($sequence[$sequenceKey]);
586
587 return $sequence;
588 }

Referenced by getCorrectedSequence().

+ Here is the caller graph for this function:

◆ getActiveId()

ilTestSequence::getActiveId ( )

Implements ilTestSequenceSummaryProvider.

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

135 : int
136 {
137 return $this->active_id;
138 }

References $active_id.

◆ getCorrectedSequence()

ilTestSequence::getCorrectedSequence ( )
protected

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

591 {
592 $correctedsequence = $this->sequencedata["sequence"];
593 if (!$this->isConsiderHiddenQuestionsEnabled()) {
594 if (is_array($this->sequencedata["hidden"])) {
595 foreach ($this->sequencedata["hidden"] as $question_id) {
596 $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $question_id);
597 }
598 }
599 }
601 foreach ($this->optionalQuestions as $questionId) {
602 $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $questionId);
603 }
604 }
605 if (is_array($this->sequencedata["postponed"])) {
606 foreach ($this->sequencedata["postponed"] as $question_id) {
607 $foundsequence = array_search($question_id, $this->questions);
608 if ($foundsequence !== false) {
609 $sequencekey = array_search($foundsequence, $correctedsequence);
610 if ($sequencekey !== false) {
611 unset($correctedsequence[$sequencekey]);
612 array_push($correctedsequence, $foundsequence);
613 }
614 }
615 }
616 }
617 return array_values($correctedsequence);
618 }
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 625 of file class.ilTestSequence.php.

626 {
627 $correctedsequence = $this->getCorrectedSequence();
628 if (count($correctedsequence)) {
629 return reset($correctedsequence);
630 } else {
631 return false;
632 }
633 }

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

636 {
637 $correctedsequence = $this->getCorrectedSequence();
638 if (count($correctedsequence)) {
639 return end($correctedsequence);
640 } else {
641 return false;
642 }
643 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getNextSequence()

ilTestSequence::getNextSequence (   $sequence)

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

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

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

839 : array
840 {
842 }

References $optionalQuestions.

◆ getOrderedSequence()

ilTestSequence::getOrderedSequence ( )

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

516 : array
517 {
518 $sequenceKeys = array();
519
520 foreach (array_keys($this->questions) as $sequenceKey) {
521 if ($this->isHiddenSequence($sequenceKey) && !$this->isConsiderHiddenQuestionsEnabled()) {
522 continue;
523 }
524
525 /* Doesn't seem to ever work, commenting out for future forensic
526 if ($this->isSequenceOptional($sequenceKey) && !$this->isConsiderOptionalQuestionsEnabled()) {
527 continue;
528 }
529 */
530
531 $sequenceKeys[] = $sequenceKey;
532 }
533
534 return $sequenceKeys;
535 }

References isConsiderHiddenQuestionsEnabled(), and isHiddenSequence().

+ Here is the call graph for this function:

◆ getOrderedSequenceQuestions()

ilTestSequence::getOrderedSequenceQuestions ( )

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

537 : array
538 {
539 $questions = array();
540
541 foreach ($this->questions as $questionId) {
542 if ($this->isHiddenQuestion($questionId) && !$this->isConsiderHiddenQuestionsEnabled()) {
543 continue;
544 }
545
546 if ($this->isQuestionOptional($questionId) && !$this->isConsiderOptionalQuestionsEnabled()) {
547 continue;
548 }
549
550 $questions[] = $questionId;
551 }
552
553 return $questions;
554 }
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 745 of file class.ilTestSequence.php.

745 : int
746 {
747 return $this->pass;
748 }

References $pass.

◆ getPositionOfSequence()

ilTestSequence::getPositionOfSequence (   $sequence)

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

501 {
502 $correctedsequence = $this->getCorrectedSequence();
503 $sequencekey = array_search($sequence, $correctedsequence);
504 if ($sequencekey !== false) {
505 return $sequencekey + 1;
506 } else {
507 return "";
508 }
509 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getPreviousSequence()

ilTestSequence::getPreviousSequence (   $sequence)

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

659 {
660 $correctedsequence = $this->getCorrectedSequence();
661 $sequencekey = array_search($sequence, $correctedsequence);
662 if ($sequencekey !== false) {
663 $prevsequencekey = $sequencekey - 1;
664 if (($prevsequencekey >= 0) && (array_key_exists($prevsequencekey, $correctedsequence))) {
665 return $correctedsequence[$prevsequencekey];
666 }
667 }
668 return false;
669 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getQuestionForSequence()

ilTestSequence::getQuestionForSequence (   $sequence)

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

691 {
692 if ($sequence < 1) {
693 return false;
694 }
695 if (array_key_exists($sequence, $this->questions)) {
696 return $this->questions[$sequence];
697 } else {
698 return false;
699 }
700 }

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

+ Here is the caller graph for this function:

◆ getQuestionIds()

ilTestSequence::getQuestionIds ( )

Implements ilTestQuestionSequence.

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

814 : array
815 {
816 return array_values($this->questions);
817 }

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

621 {
622 return array_search($question_id, $this->questions);
623 }

Referenced by isNextQuestionPresented().

+ Here is the caller graph for this function:

◆ getSequenceSummary()

ilTestSequence::getSequenceSummary (   $obligationsFilterEnabled = false)

Implements ilTestSequenceSummaryProvider.

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

702 : array
703 {
704 $correctedsequence = $this->getCorrectedSequence();
705 $result_array = array();
706 include_once "./Modules/Test/classes/class.ilObjTest.php";
707 $solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
708 $key = 1;
709 foreach ($correctedsequence as $sequence) {
710 $question = ilObjTest::_instanciateQuestion($this->getQuestionForSequence($sequence));
711 if (is_object($question)) {
712 $worked_through = $question->_isWorkedThrough($this->active_id, $question->getId(), $this->pass);
713 $solved = 0;
714 if (array_key_exists($question->getId(), $solved_questions)) {
715 $solved = $solved_questions[$question->getId()]["solved"];
716 }
717 $is_postponed = $this->isPostponedQuestion($question->getId());
718
719 $row = array(
720 "nr" => "$key",
721 "title" => $question->getTitle(),
722 "qid" => $question->getId(),
723 "presented" => $this->isQuestionPresented($question->getId()),
724 "visited" => $worked_through,
725 "solved" => (($solved) ? "1" : "0"),
726 "description" => $question->getComment(),
727 "points" => $question->getMaximumPoints(),
728 "worked_through" => $worked_through,
729 "postponed" => $is_postponed,
730 "sequence" => $sequence,
731 "obligatory" => ilObjTest::isQuestionObligatory($question->getId()),
732 'isAnswered' => $question->isAnswered($this->active_id, $this->pass)
733 );
734
735 if (!$obligationsFilterEnabled || $row['obligatory']) {
736 array_push($result_array, $row);
737 }
738
739 $key++;
740 }
741 }
742 return $result_array;
743 }
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)
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, ilObjTest\_getSolvedQuestions(), ilObjTest\_instanciateQuestion(), getCorrectedSequence(), getQuestionForSequence(), isPostponedQuestion(), and ilObjTest\isQuestionObligatory().

+ Here is the call graph for this function:

◆ getUserQuestionCount()

ilTestSequence::getUserQuestionCount ( )

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

511 : int
512 {
513 return count($this->getCorrectedSequence());
514 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getUserSequence()

ilTestSequence::getUserSequence ( )

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

557 {
558 return $this->getCorrectedSequence();
559 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequence::getUserSequenceQuestions ( )

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

561 : array
562 {
563 $seq = $this->getCorrectedSequence();
564 $found = array();
565 foreach ($seq as $sequence) {
566 array_push($found, $this->getQuestionForSequence($sequence));
567 }
568 return $found;
569 }

References getCorrectedSequence(), and getQuestionForSequence().

+ Here is the call graph for this function:

◆ hasHiddenQuestions()

ilTestSequence::hasHiddenQuestions ( )

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

764 : bool
765 {
766 if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]) > 0)) {
767 return true;
768 } else {
769 return false;
770 }
771 }

◆ hasOptionalQuestions()

ilTestSequence::hasOptionalQuestions ( )

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

834 : bool
835 {
836 return (bool) count($this->optionalQuestions);
837 }

◆ hasSequence()

ilTestSequence::hasSequence ( )

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

755 : bool
756 {
757 if ((is_array($this->sequencedata["sequence"])) && (count($this->sequencedata["sequence"]) > 0)) {
758 return true;
759 } else {
760 return false;
761 }
762 }

◆ hasStarted()

ilTestSequence::hasStarted ( ilTestSession  $testSession)

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

795 : bool
796 {
797 if ($testSession->getLastSequence() < 1) {
798 return false;
799 }
800
801 // WTF ?? heard about tests with only one question !?
802 if ($testSession->getLastSequence() == $this->getFirstSequence()) {
803 return false;
804 }
805
806 return true;
807 }

References ilTestSession\getLastSequence().

+ Here is the call graph for this function:

◆ hideCorrectAnsweredQuestions()

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

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

779 {
780 if ($activeId > 0) {
781 $result = $testOBJ->getTestResult($activeId, $pass, true);
782
783 foreach ($result as $sequence => $question) {
784 if (is_numeric($sequence)) {
785 if ($question['reached'] == $question['max']) {
786 $this->hideQuestion($question['qid']);
787 }
788 }
789 }
790
791 $this->saveToDb();
792 }
793 }
& getTestResult( $active_id, $pass=null, bool $ordered_sequence=false, bool $considerHiddenQuestions=true, bool $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, ilObjTest\getTestResult(), hideQuestion(), and saveToDb().

+ Here is the call graph for this function:

◆ hideQuestion()

ilTestSequence::hideQuestion (   $question_id)

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

373 {
374 if (!$this->isHiddenQuestion($question_id)) {
375 array_push($this->sequencedata["hidden"], intval($question_id));
376 }
377 }

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

446 {
447 if (!$this->isHiddenSequence($sequence)) {
448 if (array_key_exists($sequence, $this->questions)) {
449 if (!is_array($this->sequencedata["hidden"])) {
450 $this->sequencedata["hidden"] = array();
451 }
452 array_push($this->sequencedata["hidden"], intval($this->questions[$sequence]));
453 }
454 }
455 }

References isHiddenSequence().

+ Here is the call graph for this function:

◆ isAnsweringOptionalQuestionsConfirmed()

ilTestSequence::isAnsweringOptionalQuestionsConfirmed ( )
Returns
boolean

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

868 : bool
869 {
871 }

References $answeringOptionalQuestionsConfirmed.

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

+ Here is the caller graph for this function:

◆ isConsiderHiddenQuestionsEnabled()

ilTestSequence::isConsiderHiddenQuestionsEnabled ( )
Returns
boolean

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

884 : bool
885 {
887 }

References $considerHiddenQuestionsEnabled.

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

+ Here is the caller graph for this function:

◆ isConsiderOptionalQuestionsEnabled()

ilTestSequence::isConsiderOptionalQuestionsEnabled ( )
Returns
boolean

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

900 : bool
901 {
903 }

References $considerOptionalQuestionsEnabled.

Referenced by getCorrectedSequence(), and getOrderedSequenceQuestions().

+ Here is the caller graph for this function:

◆ isHiddenQuestion()

ilTestSequence::isHiddenQuestion (   $question_id)

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

391 : bool
392 {
393 if (!is_array($this->sequencedata["hidden"])) {
394 return false;
395 }
396 if (!in_array($question_id, $this->sequencedata["hidden"])) {
397 return false;
398 } else {
399 return true;
400 }
401 }

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

+ Here is the caller graph for this function:

◆ isHiddenSequence()

ilTestSequence::isHiddenSequence (   $sequence)

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

418 : bool
419 {
420 if (!array_key_exists($sequence, $this->questions)) {
421 return false;
422 }
423 if (!is_array($this->sequencedata["hidden"])) {
424 return false;
425 }
426 if (!in_array($this->questions[$sequence], $this->sequencedata["hidden"])) {
427 return false;
428 } else {
429 return true;
430 }
431 }

Referenced by getOrderedSequence(), and hideSequence().

+ Here is the caller graph for this function:

◆ isNextQuestionPresented()

ilTestSequence::isNextQuestionPresented (   $questionId)

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

469 : bool
470 {
471 $nextQstId = $this->getQuestionForSequence(
472 $this->getNextSequence($this->getSequenceForQuestion($questionId))
473 );
474
475 if (!$nextQstId) {
476 return false;
477 }
478
479 if ($this->newlyPresentedQuestion == $nextQstId) {
480 return true;
481 }
482
483 if (in_array($nextQstId, $this->alreadyPresentedQuestions)) {
484 return true;
485 }
486
487 return false;
488 }
getSequenceForQuestion($question_id)

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

+ Here is the call graph for this function:

◆ isPostponedQuestion()

ilTestSequence::isPostponedQuestion (   $question_id)

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

379 : bool
380 {
381 if (!is_array($this->sequencedata["postponed"])) {
382 return false;
383 }
384 if (!in_array($question_id, $this->sequencedata["postponed"])) {
385 return false;
386 } else {
387 return true;
388 }
389 }

Referenced by getSequenceSummary(), and postponeQuestion().

+ Here is the caller graph for this function:

◆ isPostponedSequence()

ilTestSequence::isPostponedSequence (   $sequence)

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

403 : bool
404 {
405 if (!array_key_exists($sequence, $this->questions)) {
406 return false;
407 }
408 if (!is_array($this->sequencedata["postponed"])) {
409 return false;
410 }
411 if (!in_array($this->questions[$sequence], $this->sequencedata["postponed"])) {
412 return false;
413 } else {
414 return true;
415 }
416 }

Referenced by postponeSequence().

+ Here is the caller graph for this function:

◆ isQuestionChecked()

ilTestSequence::isQuestionChecked (   $questionId)

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

495 : bool
496 {
497 return isset($this->alreadyCheckedQuestions[$questionId]);
498 }

◆ isQuestionOptional()

ilTestSequence::isQuestionOptional (   $questionId)

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

829 : bool
830 {
831 return isset($this->optionalQuestions[$questionId]);
832 }

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

+ Here is the caller graph for this function:

◆ isQuestionPresented()

ilTestSequence::isQuestionPresented (   $questionId)

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

462 : bool
463 {
464 return (
465 $this->newlyPresentedQuestion == $questionId || in_array($questionId, $this->alreadyPresentedQuestions)
466 );
467 }

◆ loadCheckedQuestions()

ilTestSequence::loadCheckedQuestions ( )
private

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

235 {
236 global $DIC;
237 $ilDB = $DIC['ilDB'];
238
239 $res = $ilDB->queryF(
240 "SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
241 array('integer','integer'),
242 array($this->active_id, $this->pass)
243 );
244
245 while ($row = $ilDB->fetchAssoc($res)) {
246 $this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
247 }
248 }
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69

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.

Definition at line 181 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 250 of file class.ilTestSequence.php.

251 {
252 global $DIC;
253 $ilDB = $DIC['ilDB'];
254
255 $res = $ilDB->queryF(
256 "SELECT question_fi FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s",
257 array('integer','integer'),
258 array($this->active_id, $this->pass)
259 );
260
261 while ($row = $ilDB->fetchAssoc($res)) {
262 $this->optionalQuestions[ $row['question_fi'] ] = $row['question_fi'];
263 }
264 }

References $DIC, $ilDB, and $res.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ loadPresentedQuestions()

ilTestSequence::loadPresentedQuestions ( )
protected

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

220 {
221 global $DIC; /* @var ILIAS\DI\Container $DIC */
222
223 $res = $DIC->database()->queryF(
224 "SELECT question_fi FROM tst_seq_qst_presented WHERE active_fi = %s AND pass = %s",
225 array('integer','integer'),
226 array($this->active_id, $this->pass)
227 );
228
229 while ($row = $DIC->database()->fetchAssoc($res)) {
230 $this->alreadyPresentedQuestions[ $row['question_fi'] ] = $row['question_fi'];
231 }
232 }

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

158 {
159 global $DIC;
160 $ilDB = $DIC['ilDB'];
161
162 $this->questions = array();
163
164 $result = $ilDB->queryF(
165 "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",
166 array('integer'),
167 array($this->active_id)
168 );
169
170 $index = 1;
171
172 // TODO bheyser: There might be "sequence" gaps which lead to issues with tst_sequence when deleting/adding questions before any participant starts the test
173 while ($data = $ilDB->fetchAssoc($result)) {
174 $this->questions[$index++] = $data["question_fi"];
175 }
176 }
$index
Definition: metadata.php:145

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

◆ loadQuestionSequence()

ilTestSequence::loadQuestionSequence ( )
private

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

190 {
191 global $DIC;
192 $ilDB = $DIC['ilDB'];
193 $result = $ilDB->queryF(
194 "SELECT * FROM tst_sequence WHERE active_fi = %s AND pass = %s",
195 array('integer','integer'),
196 array($this->active_id, $this->pass)
197 );
198 if ($result->numRows()) {
199 $row = $ilDB->fetchAssoc($result);
200 $this->sequencedata = array(
201 "sequence" => unserialize($row["sequence"]),
202 "postponed" => unserialize($row["postponed"]),
203 "hidden" => unserialize($row["hidden"])
204 );
205 if (!is_array($this->sequencedata["sequence"])) {
206 $this->sequencedata["sequence"] = array();
207 }
208 if (!is_array($this->sequencedata["postponed"])) {
209 $this->sequencedata["postponed"] = array();
210 }
211 if (!is_array($this->sequencedata["hidden"])) {
212 $this->sequencedata["hidden"] = array();
213 }
214
215 $this->setAnsweringOptionalQuestionsConfirmed((bool) $row['ans_opt_confirmed']);
216 }
217 }
setAnsweringOptionalQuestionsConfirmed($answeringOptionalQuestionsConfirmed)

References $DIC, $ilDB, 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 809 of file class.ilTestSequence.php.

809 : bool
810 {
811 return $this->getFirstSequence() !== false;
812 }

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

679 : array
680 {
681 $keys = array_keys($array);
682 shuffle($keys);
683 $result = array();
684 foreach ($keys as $key) {
685 $result[$key] = $array[$key];
686 }
687 return $result;
688 }
$keys
Definition: metadata.php:204

References ILIAS\LTI\ToolProvider\$key, and $keys.

Referenced by createNewSequence().

+ Here is the caller graph for this function:

◆ postponeQuestion()

ilTestSequence::postponeQuestion (   $question_id)

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

366 {
367 if (!$this->isPostponedQuestion($question_id)) {
368 array_push($this->sequencedata["postponed"], intval($question_id));
369 }
370 }

References isPostponedQuestion().

+ Here is the call graph for this function:

◆ postponeSequence()

ilTestSequence::postponeSequence (   $sequence)

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

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

References isPostponedSequence().

+ Here is the call graph for this function:

◆ questionExists()

ilTestSequence::questionExists (   $questionId)

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

819 : bool
820 {
821 return in_array($questionId, $this->questions);
822 }

◆ reorderOptionalQuestionsToSequenceEnd()

ilTestSequence::reorderOptionalQuestionsToSequenceEnd ( )

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

850 {
851 $optionalSequenceKeys = array();
852
853 foreach ($this->sequencedata['sequence'] as $index => $sequenceKey) {
854 if ($this->isQuestionOptional($this->getQuestionForSequence($sequenceKey))) {
855 $optionalSequenceKeys[$index] = $sequenceKey;
856 unset($this->sequencedata['sequence'][$index]);
857 }
858 }
859
860 foreach ($optionalSequenceKeys as $index => $sequenceKey) {
861 $this->sequencedata['sequence'][$index] = $sequenceKey;
862 }
863 }

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

+ Here is the call graph for this function:

◆ saveNewlyCheckedQuestion()

ilTestSequence::saveNewlyCheckedQuestion ( )
private

@global ilDBInterface $ilDB

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

327 {
328 if ((int) $this->newlyCheckedQuestion) {
329 global $DIC;
330 $ilDB = $DIC['ilDB'];
331
332 $ilDB->replace('tst_seq_qst_checked', array(
333 'active_fi' => array('integer', $this->active_id),
334 'pass' => array('integer', $this->pass),
335 'question_fi' => array('integer', (int) $this->newlyCheckedQuestion)
336 ), array());
337 }
338 }

References $DIC, and $ilDB.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveNewlyPresentedQuestion()

ilTestSequence::saveNewlyPresentedQuestion ( )
protected

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

311 {
312 if ($this->newlyPresentedQuestion) {
313 global $DIC; /* @var ILIAS\DI\Container $DIC */
314
315 $DIC->database()->replace('tst_seq_qst_presented', array(
316 'active_fi' => array('integer', $this->active_id),
317 'pass' => array('integer', $this->pass),
318 'question_fi' => array('integer', $this->newlyPresentedQuestion)
319 ), array());
320 }
321 }

References $DIC.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveOptionalQuestions()

ilTestSequence::saveOptionalQuestions ( )
private

@global ilDBInterface $ilDB

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

344 {
345 global $DIC;
346 $ilDB = $DIC['ilDB'];
347
348 $NOT_IN_questions = $ilDB->in('question_fi', $this->optionalQuestions, true, 'integer');
349
350 $ilDB->queryF(
351 "DELETE FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s AND $NOT_IN_questions",
352 array('integer', 'integer'),
353 array($this->active_id, $this->pass)
354 );
355
356 foreach ($this->optionalQuestions as $questionId) {
357 $ilDB->replace('tst_seq_qst_optional', array(
358 'active_fi' => array('integer', $this->active_id),
359 'pass' => array('integer', $this->pass),
360 'question_fi' => array('integer', (int) $questionId)
361 ), array());
362 }
363 }

References $DIC, and $ilDB.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveQuestionSequence()

ilTestSequence::saveQuestionSequence ( )
private

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

280 {
281 global $DIC;
282 $ilDB = $DIC['ilDB'];
283
284 $postponed = null;
285 if ((is_array($this->sequencedata["postponed"])) && (count($this->sequencedata["postponed"]))) {
286 $postponed = serialize($this->sequencedata["postponed"]);
287 }
288 $hidden = null;
289 if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]))) {
290 $hidden = serialize($this->sequencedata["hidden"]);
291 }
292
293 $affectedRows = $ilDB->manipulateF(
294 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
295 array('integer','integer'),
296 array($this->active_id, $this->pass)
297 );
298
299 $affectedRows = $ilDB->insert("tst_sequence", array(
300 "active_fi" => array("integer", $this->active_id),
301 "pass" => array("integer", $this->pass),
302 "sequence" => array("clob", serialize($this->sequencedata["sequence"])),
303 "postponed" => array("text", $postponed),
304 "hidden" => array("text", $hidden),
305 "tstamp" => array("integer", time()),
306 'ans_opt_confirmed' => array('integer', (int) $this->isAnsweringOptionalQuestionsConfirmed())
307 ));
308 }

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

272 {
273 $this->saveQuestionSequence();
276 $this->saveOptionalQuestions();
277 }
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 876 of file class.ilTestSequence.php.

877 {
878 $this->answeringOptionalQuestionsConfirmed = $answeringOptionalQuestionsConfirmed;
879 }

References $answeringOptionalQuestionsConfirmed.

Referenced by loadQuestionSequence().

+ Here is the caller graph for this function:

◆ setConsiderHiddenQuestionsEnabled()

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

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

893 {
894 $this->considerHiddenQuestionsEnabled = $considerHiddenQuestionsEnabled;
895 }

References $considerHiddenQuestionsEnabled.

◆ setConsiderOptionalQuestionsEnabled()

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

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

909 {
910 $this->considerOptionalQuestionsEnabled = $considerOptionalQuestionsEnabled;
911 }

References $considerOptionalQuestionsEnabled.

◆ setPass()

ilTestSequence::setPass (   $pass)

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

751 {
752 $this->pass = $pass;
753 }

References $pass.

◆ setQuestionChecked()

ilTestSequence::setQuestionChecked (   $questionId)

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

491 {
492 $this->newlyCheckedQuestion = $questionId;
493 }

◆ setQuestionOptional()

ilTestSequence::setQuestionOptional (   $questionId)

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

825 {
826 $this->optionalQuestions[$questionId] = $questionId;
827 }

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

+ Here is the caller graph for this function:

◆ setQuestionPresented()

ilTestSequence::setQuestionPresented (   $questionId)

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

458 {
459 $this->newlyPresentedQuestion = $questionId;
460 }

Field Documentation

◆ $active_id

ilTestSequence::$active_id

◆ $alreadyCheckedQuestions

ilTestSequence::$alreadyCheckedQuestions
protected

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

◆ $alreadyPresentedQuestions

ilTestSequence::$alreadyPresentedQuestions = array()
protected

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

◆ $answeringOptionalQuestionsConfirmed

ilTestSequence::$answeringOptionalQuestionsConfirmed
private

◆ $considerHiddenQuestionsEnabled

ilTestSequence::$considerHiddenQuestionsEnabled
private

◆ $considerOptionalQuestionsEnabled

ilTestSequence::$considerOptionalQuestionsEnabled
private

◆ $isRandomTest

ilTestSequence::$isRandomTest

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

◆ $newlyCheckedQuestion

ilTestSequence::$newlyCheckedQuestion
protected

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

◆ $newlyPresentedQuestion

ilTestSequence::$newlyPresentedQuestion = 0
protected

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

◆ $optionalQuestions

ilTestSequence::$optionalQuestions
protected

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

Referenced by getOptionalQuestions().

◆ $pass

◆ $questions

ilTestSequence::$questions

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

Referenced by getOrderedSequenceQuestions().

◆ $sequencedata

ilTestSequence::$sequencedata

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


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