ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 
 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

 getCorrectedSequence ()
 

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

 $alreadyCheckedQuestions
 
 $newlyCheckedQuestion
 
 $optionalQuestions
 
 $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 92 of file class.ilTestSequence.php.

93 {
94 $this->active_id = $active_id;
95 $this->pass = $pass;
96 $this->isRandomTest = $randomtest;
97 $this->sequencedata = array(
98 "sequence" => array(),
99 "postponed" => array(),
100 "hidden" => array()
101 );
102
103 $this->alreadyCheckedQuestions = array();
104 $this->newlyCheckedQuestion = null;
105
106 $this->optionalQuestions = array();
107 $this->answeringOptionalQuestionsConfirmed = false;
108
109 $this->considerHiddenQuestionsEnabled = false;
110 $this->considerOptionalQuestionsEnabled = true;
111 }

References $active_id, and $pass.

Member Function Documentation

◆ clearHiddenQuestions()

ilTestSequence::clearHiddenQuestions ( )

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

681 {
682 $this->sequencedata["hidden"] = array();
683 }

Referenced by ilLOTestQuestionAdapter\hideQuestions().

+ Here is the caller graph for this function:

◆ clearOptionalQuestions()

ilTestSequence::clearOptionalQuestions ( )

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

752 {
753 $this->optionalQuestions = array();
754 }

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

+ Here is the caller graph for this function:

◆ createNewSequence()

ilTestSequence::createNewSequence (   $max,
  $shuffle 
)

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

119 {
120 $newsequence = array();
121 if ($max > 0) {
122 for ($i = 1; $i <= $max; $i++) {
123 array_push($newsequence, $i);
124 }
125 if ($shuffle) {
126 $newsequence = $this->pcArrayShuffle($newsequence);
127 }
128 }
129 $this->sequencedata["sequence"] = $newsequence;
130 }
pcArrayShuffle($array)
Shuffles the values of a given array.
$i
Definition: disco.tpl.php:19

References $i, and pcArrayShuffle().

+ Here is the call graph for this function:

◆ ensureQuestionNotInSequence()

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

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

480 {
481 $questionKey = array_search($questionId, $this->questions);
482
483 if ($questionKey === false) {
484 return $sequence;
485 }
486
487 $sequenceKey = array_search($questionKey, $sequence);
488
489 if ($sequenceKey === false) {
490 return $sequence;
491 }
492
493 unset($sequence[$sequenceKey]);
494
495 return $sequence;
496 }

Referenced by getCorrectedSequence().

+ Here is the caller graph for this function:

◆ getActiveId()

ilTestSequence::getActiveId ( )

Implements ilTestSequenceSummaryProvider.

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

114 {
115 return $this->active_id;
116 }

References $active_id.

◆ getCorrectedSequence()

ilTestSequence::getCorrectedSequence ( )
protected

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

499 {
500 $correctedsequence = $this->sequencedata["sequence"];
501 if (!$this->isConsiderHiddenQuestionsEnabled()) {
502 if (is_array($this->sequencedata["hidden"])) {
503 foreach ($this->sequencedata["hidden"] as $question_id) {
504 $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $question_id);
505 }
506 }
507 }
509 foreach ($this->optionalQuestions as $questionId) {
510 $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $questionId);
511 }
512 }
513 if (is_array($this->sequencedata["postponed"])) {
514 foreach ($this->sequencedata["postponed"] as $question_id) {
515 $foundsequence = array_search($question_id, $this->questions);
516 if ($foundsequence !== false) {
517 $sequencekey = array_search($foundsequence, $correctedsequence);
518 if ($sequencekey !== false) {
519 unset($correctedsequence[$sequencekey]);
520 array_push($correctedsequence, $foundsequence);
521 }
522 }
523 }
524 }
525 return array_values($correctedsequence);
526 }
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 533 of file class.ilTestSequence.php.

534 {
535 $correctedsequence = $this->getCorrectedSequence();
536 if (count($correctedsequence)) {
537 return reset($correctedsequence);
538 } else {
539 return false;
540 }
541 }

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

544 {
545 $correctedsequence = $this->getCorrectedSequence();
546 if (count($correctedsequence)) {
547 return end($correctedsequence);
548 } else {
549 return false;
550 }
551 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getNextSequence()

ilTestSequence::getNextSequence (   $sequence)

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

554 {
555 $correctedsequence = $this->getCorrectedSequence();
556 $sequencekey = array_search($sequence, $correctedsequence);
557 if ($sequencekey !== false) {
558 $nextsequencekey = $sequencekey + 1;
559 if (array_key_exists($nextsequencekey, $correctedsequence)) {
560 return $correctedsequence[$nextsequencekey];
561 }
562 }
563 return false;
564 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getOptionalQuestions()

ilTestSequence::getOptionalQuestions ( )

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

747 {
749 }

References $optionalQuestions.

◆ getOrderedSequence()

ilTestSequence::getOrderedSequence ( )

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

427 {
428 $sequenceKeys = array();
429
430 foreach (array_keys($this->questions) as $sequenceKey) {
431 if ($this->isHiddenSequence($sequenceKey) && !$this->isConsiderHiddenQuestionsEnabled()) {
432 continue;
433 }
434
435 if ($this->isSequenceOptional($sequenceKey) && !$this->isConsiderOptionalQuestionsEnabled()) {
436 continue;
437 }
438
439 $sequenceKeys[] = $sequenceKey;
440 }
441
442 return $sequenceKeys;
443 }

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

+ Here is the call graph for this function:

◆ getOrderedSequenceQuestions()

ilTestSequence::getOrderedSequenceQuestions ( )

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

446 {
447 $questions = array();
448
449 foreach ($this->questions as $questionId) {
450 if ($this->isHiddenQuestion($questionId) && !$this->isConsiderHiddenQuestionsEnabled()) {
451 continue;
452 }
453
454 if ($this->isQuestionOptional($questionId) && !$this->isConsiderOptionalQuestionsEnabled()) {
455 continue;
456 }
457
458 $questions[] = $questionId;
459 }
460
461 return $questions;
462 }
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 652 of file class.ilTestSequence.php.

653 {
654 return $this->pass;
655 }

References $pass.

◆ getPositionOfSequence()

ilTestSequence::getPositionOfSequence (   $sequence)

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

411 {
412 $correctedsequence = $this->getCorrectedSequence();
413 $sequencekey = array_search($sequence, $correctedsequence);
414 if ($sequencekey !== false) {
415 return $sequencekey + 1;
416 } else {
417 return "";
418 }
419 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getPreviousSequence()

ilTestSequence::getPreviousSequence (   $sequence)

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

567 {
568 $correctedsequence = $this->getCorrectedSequence();
569 $sequencekey = array_search($sequence, $correctedsequence);
570 if ($sequencekey !== false) {
571 $prevsequencekey = $sequencekey - 1;
572 if (($prevsequencekey >= 0) && (array_key_exists($prevsequencekey, $correctedsequence))) {
573 return $correctedsequence[$prevsequencekey];
574 }
575 }
576 return false;
577 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getQuestionForSequence()

ilTestSequence::getQuestionForSequence (   $sequence)

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

599 {
600 if ($sequence < 1) {
601 return false;
602 }
603 if (array_key_exists($sequence, $this->questions)) {
604 return $this->questions[$sequence];
605 } else {
606 return false;
607 }
608 }

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

+ Here is the caller graph for this function:

◆ getQuestionIds()

ilTestSequence::getQuestionIds ( )

Implements ilTestQuestionSequence.

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

722 {
723 return array_values($this->questions);
724 }

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

529 {
530 return array_search($question_id, $this->questions);
531 }

◆ getSequenceSummary()

ilTestSequence::getSequenceSummary (   $obligationsFilterEnabled = false)

Implements ilTestSequenceSummaryProvider.

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

611 {
612 $correctedsequence = $this->getCorrectedSequence();
613 $result_array = array();
614 include_once "./Modules/Test/classes/class.ilObjTest.php";
615 $solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
616 $key = 1;
617 foreach ($correctedsequence as $sequence) {
618 $question =&ilObjTest::_instanciateQuestion($this->getQuestionForSequence($sequence));
619 if (is_object($question)) {
620 $worked_through = $question->_isWorkedThrough($this->active_id, $question->getId(), $this->pass);
621 $solved = 0;
622 if (array_key_exists($question->getId(), $solved_questions)) {
623 $solved = $solved_questions[$question->getId()]["solved"];
624 }
625 $is_postponed = $this->isPostponedQuestion($question->getId());
626
627 $row = array(
628 "nr" => "$key",
629 "title" => $question->getTitle(),
630 "qid" => $question->getId(),
631 "visited" => $worked_through,
632 "solved" => (($solved)?"1":"0"),
633 "description" => $question->getComment(),
634 "points" => $question->getMaximumPoints(),
635 "worked_through" => $worked_through,
636 "postponed" => $is_postponed,
637 "sequence" => $sequence,
638 "obligatory" => ilObjTest::isQuestionObligatory($question->getId()),
639 'isAnswered' => $question->isAnswered($this->active_id, $this->pass)
640 );
641
642 if (!$obligationsFilterEnabled || $row['obligatory']) {
643 array_push($result_array, $row);
644 }
645
646 $key++;
647 }
648 }
649 return $result_array;
650 }
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)
$key
Definition: croninfo.php:18

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

+ Here is the call graph for this function:

◆ getUserQuestionCount()

ilTestSequence::getUserQuestionCount ( )

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

422 {
423 return count($this->getCorrectedSequence());
424 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getUserSequence()

ilTestSequence::getUserSequence ( )

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

465 {
466 return $this->getCorrectedSequence();
467 }

References getCorrectedSequence().

+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequence::getUserSequenceQuestions ( )

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

470 {
471 $seq = $this->getCorrectedSequence();
472 $found = array();
473 foreach ($seq as $sequence) {
474 array_push($found, $this->getQuestionForSequence($sequence));
475 }
476 return $found;
477 }

References getCorrectedSequence(), and getQuestionForSequence().

+ Here is the call graph for this function:

◆ hasHiddenQuestions()

ilTestSequence::hasHiddenQuestions ( )

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

672 {
673 if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]) > 0)) {
674 return true;
675 } else {
676 return false;
677 }
678 }

◆ hasOptionalQuestions()

ilTestSequence::hasOptionalQuestions ( )

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

742 {
743 return (bool) count($this->optionalQuestions);
744 }

◆ hasSequence()

ilTestSequence::hasSequence ( )

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

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

◆ hasStarted()

ilTestSequence::hasStarted ( ilTestSession  $testSession)

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

703 {
704 if ($testSession->getLastSequence() < 1) {
705 return false;
706 }
707
708 // WTF ?? heard about tests with only one question !?
709 if ($testSession->getLastSequence() == $this->getFirstSequence()) {
710 return false;
711 }
712
713 return true;
714 }

References ilTestSession\getLastSequence().

+ Here is the call graph for this function:

◆ hideCorrectAnsweredQuestions()

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

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

686 {
687 if ($activeId > 0) {
688 $result = $testOBJ->getTestResult($activeId, $pass, true);
689
690 foreach ($result as $sequence => $question) {
691 if (is_numeric($sequence)) {
692 if ($question['reached'] == $question['max']) {
693 $this->hideQuestion($question['qid']);
694 }
695 }
696 }
697
698 $this->saveToDb();
699 }
700 }
$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 315 of file class.ilTestSequence.php.

316 {
317 if (!$this->isHiddenQuestion($question_id)) {
318 array_push($this->sequencedata["hidden"], intval($question_id));
319 }
320 }

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

389 {
390 if (!$this->isHiddenSequence($sequence)) {
391 if (array_key_exists($sequence, $this->questions)) {
392 if (!is_array($this->sequencedata["hidden"])) {
393 $this->sequencedata["hidden"] = array();
394 }
395 array_push($this->sequencedata["hidden"], intval($this->questions[$sequence]));
396 }
397 }
398 }

References isHiddenSequence().

+ Here is the call graph for this function:

◆ isAnsweringOptionalQuestionsConfirmed()

ilTestSequence::isAnsweringOptionalQuestionsConfirmed ( )
Returns
boolean

Definition at line 775 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 791 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 807 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 334 of file class.ilTestSequence.php.

335 {
336 if (!is_array($this->sequencedata["hidden"])) {
337 return false;
338 }
339 if (!in_array($question_id, $this->sequencedata["hidden"])) {
340 return false;
341 } else {
342 return true;
343 }
344 }

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

+ Here is the caller graph for this function:

◆ isHiddenSequence()

ilTestSequence::isHiddenSequence (   $sequence)

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

362 {
363 if (!array_key_exists($sequence, $this->questions)) {
364 return false;
365 }
366 if (!is_array($this->sequencedata["hidden"])) {
367 return false;
368 }
369 if (!in_array($this->questions[$sequence], $this->sequencedata["hidden"])) {
370 return false;
371 } else {
372 return true;
373 }
374 }

Referenced by getOrderedSequence(), and hideSequence().

+ Here is the caller graph for this function:

◆ isPostponedQuestion()

ilTestSequence::isPostponedQuestion (   $question_id)

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

323 {
324 if (!is_array($this->sequencedata["postponed"])) {
325 return false;
326 }
327 if (!in_array($question_id, $this->sequencedata["postponed"])) {
328 return false;
329 } else {
330 return true;
331 }
332 }

Referenced by getSequenceSummary(), and postponeQuestion().

+ Here is the caller graph for this function:

◆ isPostponedSequence()

ilTestSequence::isPostponedSequence (   $sequence)

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

347 {
348 if (!array_key_exists($sequence, $this->questions)) {
349 return false;
350 }
351 if (!is_array($this->sequencedata["postponed"])) {
352 return false;
353 }
354 if (!in_array($this->questions[$sequence], $this->sequencedata["postponed"])) {
355 return false;
356 } else {
357 return true;
358 }
359 }

Referenced by postponeSequence().

+ Here is the caller graph for this function:

◆ isQuestionChecked()

ilTestSequence::isQuestionChecked (   $questionId)

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

406 {
407 return isset($this->alreadyCheckedQuestions[$questionId]);
408 }

◆ isQuestionOptional()

ilTestSequence::isQuestionOptional (   $questionId)

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

737 {
738 return isset($this->optionalQuestions[$questionId]);
739 }

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

+ Here is the caller graph for this function:

◆ loadCheckedQuestions()

ilTestSequence::loadCheckedQuestions ( )
private

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

197 {
198 global $ilDB;
199
200 $res = $ilDB->queryF(
201 "SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
202 array('integer','integer'),
203 array($this->active_id, $this->pass)
204 );
205
206 while ($row = $ilDB->fetchAssoc($res)) {
207 $this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
208 }
209 }
foreach($_POST as $key=> $value) $res
global $ilDB

References $ilDB, $res, and $row.

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

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

+ Here is the call graph for this function:

◆ loadOptionalQuestions()

ilTestSequence::loadOptionalQuestions ( )
private

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

212 {
213 global $ilDB;
214
215 $res = $ilDB->queryF(
216 "SELECT question_fi FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s",
217 array('integer','integer'),
218 array($this->active_id, $this->pass)
219 );
220
221 while ($row = $ilDB->fetchAssoc($res)) {
222 $this->optionalQuestions[ $row['question_fi'] ] = $row['question_fi'];
223 }
224 }

References $ilDB, $res, and $row.

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

136 {
137 global $ilDB;
138
139 $this->questions = array();
140
141 $result = $ilDB->queryF(
142 "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",
143 array('integer'),
144 array($this->active_id)
145 );
146
147 $index = 1;
148
149 // TODO bheyser: There might be "sequence" gaps which lead to issues with tst_sequence when deleting/adding questions before any participant starts the test
150 while ($data = $ilDB->fetchAssoc($result)) {
151 $this->questions[$index++] = $data["question_fi"];
152 }
153 }
$index
Definition: metadata.php:60

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

◆ loadQuestionSequence()

ilTestSequence::loadQuestionSequence ( )
private

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

168 {
169 global $ilDB;
170 $result = $ilDB->queryF(
171 "SELECT * FROM tst_sequence WHERE active_fi = %s AND pass = %s",
172 array('integer','integer'),
173 array($this->active_id, $this->pass)
174 );
175 if ($result->numRows()) {
176 $row = $ilDB->fetchAssoc($result);
177 $this->sequencedata = array(
178 "sequence" => unserialize($row["sequence"]),
179 "postponed" => unserialize($row["postponed"]),
180 "hidden" => unserialize($row["hidden"])
181 );
182 if (!is_array($this->sequencedata["sequence"])) {
183 $this->sequencedata["sequence"] = array();
184 }
185 if (!is_array($this->sequencedata["postponed"])) {
186 $this->sequencedata["postponed"] = array();
187 }
188 if (!is_array($this->sequencedata["hidden"])) {
189 $this->sequencedata["hidden"] = array();
190 }
191
192 $this->setAnsweringOptionalQuestionsConfirmed((bool) $row['ans_opt_confirmed']);
193 }
194 }
setAnsweringOptionalQuestionsConfirmed($answeringOptionalQuestionsConfirmed)

References $ilDB, $result, $row, 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 716 of file class.ilTestSequence.php.

717 {
718 return $this->getFirstSequence() !== false;
719 }

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

588 {
589 $keys = array_keys($array);
590 shuffle($keys);
591 $result = array();
592 foreach ($keys as $key) {
593 $result[$key] = $array[$key];
594 }
595 return $result;
596 }
$keys

References $key, $keys, and $result.

Referenced by createNewSequence().

+ Here is the caller graph for this function:

◆ postponeQuestion()

ilTestSequence::postponeQuestion (   $question_id)

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

309 {
310 if (!$this->isPostponedQuestion($question_id)) {
311 array_push($this->sequencedata["postponed"], intval($question_id));
312 }
313 }

References isPostponedQuestion().

+ Here is the call graph for this function:

◆ postponeSequence()

ilTestSequence::postponeSequence (   $sequence)

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

377 {
378 if (!$this->isPostponedSequence($sequence)) {
379 if (array_key_exists($sequence, $this->questions)) {
380 if (!is_array($this->sequencedata["postponed"])) {
381 $this->sequencedata["postponed"] = array();
382 }
383 array_push($this->sequencedata["postponed"], intval($this->questions[$sequence]));
384 }
385 }
386 }
isPostponedSequence($sequence)

References isPostponedSequence().

+ Here is the call graph for this function:

◆ questionExists()

ilTestSequence::questionExists (   $questionId)

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

727 {
728 return in_array($questionId, $this->questions);
729 }

◆ reorderOptionalQuestionsToSequenceEnd()

ilTestSequence::reorderOptionalQuestionsToSequenceEnd ( )

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

757 {
758 $optionalSequenceKeys = array();
759
760 foreach ($this->sequencedata['sequence'] as $index => $sequenceKey) {
761 if ($this->isQuestionOptional($this->getQuestionForSequence($sequenceKey))) {
762 $optionalSequenceKeys[$index] = $sequenceKey;
763 unset($this->sequencedata['sequence'][$index]);
764 }
765 }
766
767 foreach ($optionalSequenceKeys as $index => $sequenceKey) {
768 $this->sequencedata['sequence'][$index] = $sequenceKey;
769 }
770 }

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

+ Here is the call graph for this function:

◆ saveNewlyCheckedQuestion()

ilTestSequence::saveNewlyCheckedQuestion ( )
private

@global ilDBInterface $ilDB

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

272 {
273 if ((int) $this->newlyCheckedQuestion) {
274 global $ilDB;
275
276 $ilDB->replace('tst_seq_qst_checked', array(
277 'active_fi' => array('integer', (int) $this->active_id),
278 'pass' => array('integer', (int) $this->pass),
279 'question_fi' => array('integer', (int) $this->newlyCheckedQuestion)
280 ), array());
281 }
282 }

References $ilDB.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveOptionalQuestions()

ilTestSequence::saveOptionalQuestions ( )
private

@global ilDBInterface $ilDB

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

288 {
289 global $ilDB;
290
291 $NOT_IN_questions = $ilDB->in('question_fi', $this->optionalQuestions, true, 'integer');
292
293 $ilDB->queryF(
294 "DELETE FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s AND $NOT_IN_questions",
295 array('integer', 'integer'),
296 array($this->active_id, $this->pass)
297 );
298
299 foreach ($this->optionalQuestions as $questionId) {
300 $ilDB->replace('tst_seq_qst_optional', array(
301 'active_fi' => array('integer', (int) $this->active_id),
302 'pass' => array('integer', (int) $this->pass),
303 'question_fi' => array('integer', (int) $questionId)
304 ), array());
305 }
306 }

References $ilDB.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ saveQuestionSequence()

ilTestSequence::saveQuestionSequence ( )
private

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

239 {
240 global $ilDB;
241
242 $postponed = null;
243 if ((is_array($this->sequencedata["postponed"])) && (count($this->sequencedata["postponed"]))) {
244 $postponed = serialize($this->sequencedata["postponed"]);
245 }
246 $hidden = null;
247 if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]))) {
248 $hidden = serialize($this->sequencedata["hidden"]);
249 }
250
251 $affectedRows = $ilDB->manipulateF(
252 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
253 array('integer','integer'),
254 array($this->active_id, $this->pass)
255 );
256
257 $affectedRows = $ilDB->insert("tst_sequence", array(
258 "active_fi" => array("integer", $this->active_id),
259 "pass" => array("integer", $this->pass),
260 "sequence" => array("clob", serialize($this->sequencedata["sequence"])),
261 "postponed" => array("text", $postponed),
262 "hidden" => array("text", $hidden),
263 "tstamp" => array("integer", time()),
264 'ans_opt_confirmed' => array('integer', (int) $this->isAnsweringOptionalQuestionsConfirmed())
265 ));
266 }

References $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 231 of file class.ilTestSequence.php.

232 {
233 $this->saveQuestionSequence();
235 $this->saveOptionalQuestions();
236 }
saveNewlyCheckedQuestion()
@global ilDBInterface $ilDB
saveOptionalQuestions()
@global ilDBInterface $ilDB

References saveNewlyCheckedQuestion(), 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 783 of file class.ilTestSequence.php.

784 {
785 $this->answeringOptionalQuestionsConfirmed = $answeringOptionalQuestionsConfirmed;
786 }

References $answeringOptionalQuestionsConfirmed.

Referenced by loadQuestionSequence().

+ Here is the caller graph for this function:

◆ setConsiderHiddenQuestionsEnabled()

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

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

800 {
801 $this->considerHiddenQuestionsEnabled = $considerHiddenQuestionsEnabled;
802 }

References $considerHiddenQuestionsEnabled.

◆ setConsiderOptionalQuestionsEnabled()

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

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

816 {
817 $this->considerOptionalQuestionsEnabled = $considerOptionalQuestionsEnabled;
818 }

References $considerOptionalQuestionsEnabled.

◆ setPass()

ilTestSequence::setPass (   $pass)

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

658 {
659 $this->pass = $pass;
660 }

References $pass.

◆ setQuestionChecked()

ilTestSequence::setQuestionChecked (   $questionId)

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

401 {
402 $this->newlyCheckedQuestion = $questionId;
403 }

◆ setQuestionOptional()

ilTestSequence::setQuestionOptional (   $questionId)

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

732 {
733 $this->optionalQuestions[$questionId] = $questionId;
734 }

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

+ Here is the caller graph for this function:

Field Documentation

◆ $active_id

ilTestSequence::$active_id

◆ $alreadyCheckedQuestions

ilTestSequence::$alreadyCheckedQuestions
private

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
private

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

◆ $optionalQuestions

ilTestSequence::$optionalQuestions
private

Definition at line 66 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: