ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 

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 ()
 ilDBInterface $ilDB More...
 
 saveOptionalQuestions ()
 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 public

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

References $active_id, and $pass.

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  }

Member Function Documentation

◆ clearHiddenQuestions()

ilTestSequence::clearHiddenQuestions ( )

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

Referenced by ilLOTestQuestionAdapter\hideQuestions().

762  {
763  $this->sequencedata["hidden"] = array();
764  }
+ Here is the caller graph for this function:

◆ clearOptionalQuestions()

ilTestSequence::clearOptionalQuestions ( )

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

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

833  {
834  $this->optionalQuestions = array();
835  }
+ Here is the caller graph for this function:

◆ createNewSequence()

ilTestSequence::createNewSequence (   $max,
  $shuffle 
)

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

References $i, and pcArrayShuffle().

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  }
$i
Definition: disco.tpl.php:19
pcArrayShuffle($array)
Shuffles the values of a given array.
+ Here is the call graph for this function:

◆ ensureQuestionNotInSequence()

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

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

Referenced by getCorrectedSequence().

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  }
+ Here is the caller graph for this function:

◆ getActiveId()

ilTestSequence::getActiveId ( )

Implements ilTestSequenceSummaryProvider.

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

References $active_id.

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

◆ getCorrectedSequence()

ilTestSequence::getCorrectedSequence ( )
protected

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

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

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

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  }
588  if (!$this->isConsiderOptionalQuestionsEnabled()) {
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)
+ 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.

References getCorrectedSequence().

Referenced by hasStarted(), and openQuestionExists().

614  {
615  $correctedsequence = $this->getCorrectedSequence();
616  if (count($correctedsequence)) {
617  return reset($correctedsequence);
618  } else {
619  return false;
620  }
621  }
+ 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.

References getCorrectedSequence().

624  {
625  $correctedsequence = $this->getCorrectedSequence();
626  if (count($correctedsequence)) {
627  return end($correctedsequence);
628  } else {
629  return false;
630  }
631  }
+ Here is the call graph for this function:

◆ getNextSequence()

ilTestSequence::getNextSequence (   $sequence)

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

References getCorrectedSequence().

Referenced by isNextQuestionPresented().

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

References $optionalQuestions.

828  {
830  }

◆ getOrderedSequence()

ilTestSequence::getOrderedSequence ( )

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

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

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  }
+ Here is the call graph for this function:

◆ getOrderedSequenceQuestions()

ilTestSequence::getOrderedSequenceQuestions ( )

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

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

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  }
isQuestionOptional($questionId)
isHiddenQuestion($question_id)
+ Here is the call graph for this function:

◆ getPass()

ilTestSequence::getPass ( )

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

References $pass.

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

◆ getPositionOfSequence()

ilTestSequence::getPositionOfSequence (   $sequence)

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

References getCorrectedSequence().

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  }
+ Here is the call graph for this function:

◆ getPreviousSequence()

ilTestSequence::getPreviousSequence (   $sequence)

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

References getCorrectedSequence().

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  }
+ Here is the call graph for this function:

◆ getQuestionForSequence()

ilTestSequence::getQuestionForSequence (   $sequence)

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

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

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  }
+ Here is the caller graph for this function:

◆ getQuestionIds()

ilTestSequence::getQuestionIds ( )

Implements ilTestQuestionSequence.

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

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

803  {
804  return array_values($this->questions);
805  }
+ Here is the caller graph for this function:

◆ getSequenceForQuestion()

ilTestSequence::getSequenceForQuestion (   $question_id)

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

Referenced by isNextQuestionPresented().

609  {
610  return array_search($question_id, $this->questions);
611  }
+ Here is the caller graph for this function:

◆ getSequenceSummary()

ilTestSequence::getSequenceSummary (   $obligationsFilterEnabled = false)

Implements ilTestSequenceSummaryProvider.

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

References $key, $pass, $row, ilObjTest\_getSolvedQuestions(), ilObjTest\_instanciateQuestion(), getCorrectedSequence(), getQuestionForSequence(), isPostponedQuestion(), ilObjTest\isQuestionObligatory(), and isQuestionPresented().

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  }
isPostponedQuestion($question_id)
isQuestionPresented($questionId)
getQuestionForSequence($sequence)
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static isQuestionObligatory($question_id)
checks wether the question with given id is marked as obligatory or not
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
$row
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getUserQuestionCount()

ilTestSequence::getUserQuestionCount ( )

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

References getCorrectedSequence().

502  {
503  return count($this->getCorrectedSequence());
504  }
+ Here is the call graph for this function:

◆ getUserSequence()

ilTestSequence::getUserSequence ( )

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

References getCorrectedSequence().

545  {
546  return $this->getCorrectedSequence();
547  }
+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequence::getUserSequenceQuestions ( )

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

References getCorrectedSequence(), and getQuestionForSequence().

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  }
getQuestionForSequence($sequence)
+ 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.

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

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

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

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
hideQuestion($question_id)
saveToDb()
Saves the sequence data for a given pass to the database.
& 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...
+ Here is the call graph for this function:

◆ hideQuestion()

ilTestSequence::hideQuestion (   $question_id)

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

References isHiddenQuestion().

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

363  {
364  if (!$this->isHiddenQuestion($question_id)) {
365  array_push($this->sequencedata["hidden"], intval($question_id));
366  }
367  }
isHiddenQuestion($question_id)
+ 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.

References isHiddenSequence().

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  }
+ 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().

857  {
859  }
+ 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().

873  {
875  }
+ 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().

889  {
891  }
+ Here is the caller graph for this function:

◆ isHiddenQuestion()

ilTestSequence::isHiddenQuestion (   $question_id)

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

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

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  }
+ Here is the caller graph for this function:

◆ isHiddenSequence()

ilTestSequence::isHiddenSequence (   $sequence)

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

Referenced by getOrderedSequence(), and hideSequence().

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  }
+ Here is the caller graph for this function:

◆ isNextQuestionPresented()

ilTestSequence::isNextQuestionPresented (   $questionId)

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

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

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)
getQuestionForSequence($sequence)
+ Here is the call graph for this function:

◆ isPostponedQuestion()

ilTestSequence::isPostponedQuestion (   $question_id)

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

Referenced by getSequenceSummary(), and postponeQuestion().

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  }
+ Here is the caller graph for this function:

◆ isPostponedSequence()

ilTestSequence::isPostponedSequence (   $sequence)

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

Referenced by postponeSequence().

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

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

818  {
819  return isset($this->optionalQuestions[$questionId]);
820  }
+ Here is the caller graph for this function:

◆ isQuestionPresented()

ilTestSequence::isQuestionPresented (   $questionId)

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

Referenced by getSequenceSummary().

453  {
454  return (
455  $this->newlyPresentedQuestion == $questionId || in_array($questionId, $this->alreadyPresentedQuestions)
456  );
457  }
+ Here is the caller graph for this function:

◆ loadCheckedQuestions()

ilTestSequence::loadCheckedQuestions ( )
private

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

References $DIC, $ilDB, $res, and $row.

Referenced by loadFromDb().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ 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().

172  {
173  $this->loadQuestionSequence();
174  $this->loadPresentedQuestions();
175  $this->loadCheckedQuestions();
176  $this->loadOptionalQuestions();
177  }
+ Here is the call graph for this function:

◆ loadOptionalQuestions()

ilTestSequence::loadOptionalQuestions ( )
private

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

References $DIC, $ilDB, $res, and $row.

Referenced by loadFromDb().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the caller graph for this function:

◆ loadPresentedQuestions()

ilTestSequence::loadPresentedQuestions ( )
protected

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

References $DIC, $res, and $row.

Referenced by loadFromDb().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
+ Here is the caller graph for this function:

◆ loadQuestions()

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

Loads the question mapping.

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

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

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  }
$result
global $DIC
Definition: saml.php:7
$index
Definition: metadata.php:60
global $ilDB
$data
Definition: bench.php:6

◆ loadQuestionSequence()

ilTestSequence::loadQuestionSequence ( )
private

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

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

Referenced by loadFromDb().

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  }
$result
global $DIC
Definition: saml.php:7
setAnsweringOptionalQuestionsConfirmed($answeringOptionalQuestionsConfirmed)
$row
global $ilDB
+ 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.

References getFirstSequence().

798  {
799  return $this->getFirstSequence() !== false;
800  }
+ 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 public

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

References $key, $keys, and $result.

Referenced by createNewSequence().

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  }
$result
$keys
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ postponeQuestion()

ilTestSequence::postponeQuestion (   $question_id)

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

References isPostponedQuestion().

356  {
357  if (!$this->isPostponedQuestion($question_id)) {
358  array_push($this->sequencedata["postponed"], intval($question_id));
359  }
360  }
isPostponedQuestion($question_id)
+ Here is the call graph for this function:

◆ postponeSequence()

ilTestSequence::postponeSequence (   $sequence)

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

References isPostponedSequence().

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

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

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  }
isQuestionOptional($questionId)
$index
Definition: metadata.php:60
getQuestionForSequence($sequence)
+ Here is the call graph for this function:

◆ saveNewlyCheckedQuestion()

ilTestSequence::saveNewlyCheckedQuestion ( )
private

ilDBInterface $ilDB

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

References $DIC, and $ilDB.

Referenced by saveToDb().

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  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ saveNewlyPresentedQuestion()

ilTestSequence::saveNewlyPresentedQuestion ( )
protected

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

References $DIC.

Referenced by saveToDb().

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  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ saveOptionalQuestions()

ilTestSequence::saveOptionalQuestions ( )
private

ilDBInterface $ilDB

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

References $DIC, and $ilDB.

Referenced by saveToDb().

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  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ saveQuestionSequence()

ilTestSequence::saveQuestionSequence ( )
private

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

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

Referenced by saveToDb().

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  }
global $DIC
Definition: saml.php:7
global $ilDB
+ 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 261 of file class.ilTestSequence.php.

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

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

262  {
263  $this->saveQuestionSequence();
265  $this->saveNewlyCheckedQuestion();
266  $this->saveOptionalQuestions();
267  }
saveOptionalQuestions()
ilDBInterface $ilDB
saveNewlyCheckedQuestion()
ilDBInterface $ilDB
+ 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.

References $answeringOptionalQuestionsConfirmed.

Referenced by loadQuestionSequence().

865  {
866  $this->answeringOptionalQuestionsConfirmed = $answeringOptionalQuestionsConfirmed;
867  }
+ Here is the caller graph for this function:

◆ setConsiderHiddenQuestionsEnabled()

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

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

References $considerHiddenQuestionsEnabled.

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

◆ setConsiderOptionalQuestionsEnabled()

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

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

References $considerOptionalQuestionsEnabled.

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

◆ setPass()

ilTestSequence::setPass (   $pass)

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

References $pass.

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

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

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

813  {
814  $this->optionalQuestions[$questionId] = $questionId;
815  }
+ 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: