ILIAS  release_8 Revision v8.24
ilTestSequenceDynamicQuestionSet Class Reference
+ Inheritance diagram for ilTestSequenceDynamicQuestionSet:
+ Collaboration diagram for ilTestSequenceDynamicQuestionSet:

Public Member Functions

 __construct (ilDBInterface $db, ilTestDynamicQuestionSet $questionSet, $activeId)
 Constructor. More...
 
 getActiveId ()
 
 setPreventCheckedQuestionsFromComingUpEnabled ($preventCheckedQuestionsFromComingUpEnabled)
 
 isPreventCheckedQuestionsFromComingUpEnabled ()
 
 getCurrentQuestionId ()
 
 setCurrentQuestionId ($currentQuestionId)
 
 loadFromDb ()
 
 saveToDb ()
 
 loadQuestions (ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
 
 cleanupQuestions (ilTestSessionDynamicQuestionSet $testSession)
 
 getUpcomingQuestionId ()
 
 isAnsweredQuestion ($questionId)
 
 isPostponedQuestion ($questionId)
 
 isFilteredQuestion ($questionId)
 
 trackedQuestionExists ()
 
 getTrackedQuestionList ($currentQuestionId=null)
 
 resetTrackedQuestionList ()
 
 openQuestionExists ()
 
 getOpenQuestions ()
 
 getTrackedQuestionCount ()
 
 getCurrentPositionIndex ($questionId)
 
 getLastPositionIndex ()
 
 setQuestionUnchecked ($questionId)
 
 setQuestionChecked ($questionId)
 
 isQuestionChecked ($questionId)
 
 setQuestionPostponed ($questionId)
 
 unsetQuestionPostponed ($questionId)
 
 setQuestionAnsweredCorrect ($questionId)
 
 setQuestionAnsweredWrong ($questionId)
 
 hasStarted ()
 
 getQuestionSet ()
 
 getCompleteQuestionsData ()
 
 getFilteredQuestionsData ()
 
 getUserSequenceQuestions ()
 
 getPass ()
 
 getSelectionOrderedSequence ()
 
 getSequenceSummary ($obligationsFilterEnabled=false)
 
 hasFilteredQuestionListCheckedQuestions ()
 
 resetFilteredQuestionListsCheckedStatus ()
 
 getActiveId ()
 
 getSequenceSummary ($obligationsFilterEnabled=false)
 

Private Member Functions

 loadQuestionTracking ()
 
 loadAnswerStatus ()
 
 loadPostponedQuestions ()
 
 loadCheckedQuestions ()
 
 saveNewlyTrackedQuestion ()
 
 getNewOrderIndexForQuestionTracking ()
 
 saveNewlyAnsweredQuestionsAnswerStatus ()
 
 saveNewlyPostponedQuestion ()
 
 removeQuestionsNotPostponedAnymore ()
 
 saveNewlyCheckedQuestion ()
 
 removeQuestionsNotCheckedAnymore ()
 
 fetchUpcomingQuestionId ($excludePostponedQuestions, $forceNonAnsweredQuestion)
 
 trackQuestion ($questionId, $answerStatus)
 
 fetchMostLeastPostponedQuestion ($postponedQuestions)
 
 orderQuestionsByPostponeCount ($postponedQuestions)
 
 fetchQuestionSequence ($nonPostponedQuestions, $nonAnsweredQuestions)
 
 fetchTrackedCorrectAnsweredSequence ()
 
 getOrderedSequence ()
 

Private Attributes

 $db = null
 
 $questionSet = null
 
 $activeId = null
 
 $preventCheckedQuestionsFromComingUpEnabled
 
 $questionTracking = array()
 
 $newlyTrackedQuestion
 
 $newlyTrackedQuestionsStatus
 
 $postponedQuestions = array()
 
 $newlyPostponedQuestion
 
 $newlyPostponedQuestionsCount
 
 $alreadyCheckedQuestions
 
 $newlyCheckedQuestion
 
 $correctAnsweredQuestions = array()
 
 $wrongAnsweredQuestions = array()
 
 $newlyAnsweredQuestion
 
 $newlyAnsweredQuestionsAnswerStatus
 
 $currentQuestionId
 

Detailed Description

Definition at line 29 of file class.ilTestSequenceDynamicQuestionSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSequenceDynamicQuestionSet::__construct ( ilDBInterface  $db,
ilTestDynamicQuestionSet  $questionSet,
  $activeId 
)

Constructor.

Parameters
ilTestDynamicQuestionSet$questionSet

Definition at line 121 of file class.ilTestSequenceDynamicQuestionSet.php.

122 {
123 $this->db = $db;
124 $this->questionSet = $questionSet;
125 $this->activeId = $activeId;
126
127 $this->newlyTrackedQuestion = null;
128 $this->newlyTrackedQuestionsStatus = null;
129
130 $this->newlyPostponedQuestion = null;
131 $this->newlyPostponedQuestionsCount = null;
132
133 $this->newlyAnsweredQuestion = null;
134 $this->newlyAnsweredQuestionsAnswerStatus = null;
135
136 $this->alreadyCheckedQuestions = array();
137 $this->newlyCheckedQuestion = null;
138
139 $this->preventCheckedQuestionsFromComingUpEnabled = false;
140
141 $this->currentQuestionId = null;
142 }

References $activeId, $db, and $questionSet.

Member Function Documentation

◆ cleanupQuestions()

ilTestSequenceDynamicQuestionSet::cleanupQuestions ( ilTestSessionDynamicQuestionSet  $testSession)

Definition at line 416 of file class.ilTestSequenceDynamicQuestionSet.php.

417 {
418 switch (true) {
419 case !$this->questionSet->questionExists($testSession->getCurrentQuestionId()):
420 case !$this->isFilteredQuestion($testSession->getCurrentQuestionId()):
421
422 $testSession->setCurrentQuestionId(null);
423 }
424
425 foreach ($this->postponedQuestions as $questionId) {
426 if (!$this->questionSet->questionExists($questionId)) {
427 unset($this->postponedQuestions[$questionId]);
428 }
429 }
430
431 foreach ($this->wrongAnsweredQuestions as $questionId) {
432 if (!$this->questionSet->questionExists($questionId)) {
433 unset($this->wrongAnsweredQuestions[$questionId]);
434 }
435 }
436
437 foreach ($this->correctAnsweredQuestions as $questionId) {
438 if (!$this->questionSet->questionExists($questionId)) {
439 unset($this->correctAnsweredQuestions[$questionId]);
440 }
441 }
442 }

References ilTestSessionDynamicQuestionSet\getCurrentQuestionId(), isFilteredQuestion(), and ilTestSessionDynamicQuestionSet\setCurrentQuestionId().

+ Here is the call graph for this function:

◆ fetchMostLeastPostponedQuestion()

ilTestSequenceDynamicQuestionSet::fetchMostLeastPostponedQuestion (   $postponedQuestions)
private
Parameters
$postponedQuestions
Returns
int|null|string

Definition at line 720 of file class.ilTestSequenceDynamicQuestionSet.php.

721 {
722 $minPostponeCount = null;
723 $minPostponeItem = null;
724
725 foreach (array_reverse($postponedQuestions, true) as $qId => $postponeCount) {
726 if ($minPostponeCount === null || $postponeCount <= $minPostponeCount) {
727 $minPostponeCount = $postponeCount;
728 $minPostponeItem = $qId;
729 }
730 }
731 return $minPostponeItem;
732 }

References $postponedQuestions.

Referenced by fetchUpcomingQuestionId().

+ Here is the caller graph for this function:

◆ fetchQuestionSequence()

ilTestSequenceDynamicQuestionSet::fetchQuestionSequence (   $nonPostponedQuestions,
  $nonAnsweredQuestions 
)
private

Definition at line 763 of file class.ilTestSequenceDynamicQuestionSet.php.

763 : array
764 {
765 $questionSequence = array();
766
767 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
768 $postponedQuestions = array();
769
770 foreach ($questions as $pos => $qId) {
771 if (isset($this->correctAnsweredQuestions[$qId])) {
772 continue;
773 }
774
775 if ($nonAnsweredQuestions && isset($this->wrongAnsweredQuestions[$qId])) {
776 continue;
777 } elseif (!$nonAnsweredQuestions && !isset($this->wrongAnsweredQuestions[$qId])) {
778 continue;
779 }
780
781 if (!$nonPostponedQuestions && isset($this->postponedQuestions[$qId])) {
782 $postponedQuestions[$qId] = $this->postponedQuestions[$qId];
783 continue;
784 } elseif ($nonPostponedQuestions && !isset($this->postponedQuestions[$qId])) {
785 $questionSequence[] = $qId;
786 }
787 }
788
789 if (!$nonPostponedQuestions && count($postponedQuestions)) {
790 $questionSequence = array_merge(
791 $questionSequence,
793 );
794 }
795 }
796
797 return $questionSequence;
798 }

References $postponedQuestions, and orderQuestionsByPostponeCount().

Referenced by getOrderedSequence().

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

◆ fetchTrackedCorrectAnsweredSequence()

ilTestSequenceDynamicQuestionSet::fetchTrackedCorrectAnsweredSequence ( )
private

Definition at line 800 of file class.ilTestSequenceDynamicQuestionSet.php.

800 : array
801 {
802 $questionSequence = array();
803
804 foreach ($this->questionTracking as $key => $question) {
805 $qId = $question['qid'];
806
807 if (!isset($this->correctAnsweredQuestions[$qId])) {
808 continue;
809 }
810
811 $questionSequence[] = $qId;
812 }
813
814 return $questionSequence;
815 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key.

Referenced by getOrderedSequence().

+ Here is the caller graph for this function:

◆ fetchUpcomingQuestionId()

ilTestSequenceDynamicQuestionSet::fetchUpcomingQuestionId (   $excludePostponedQuestions,
  $forceNonAnsweredQuestion 
)
private

Definition at line 467 of file class.ilTestSequenceDynamicQuestionSet.php.

468 {
469 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
470 $postponedQuestions = array();
471
472 foreach ($questions as $pos => $qId) {
473 if (isset($this->correctAnsweredQuestions[$qId])) {
474 continue;
475 }
476
478 continue;
479 }
480
481 if ($forceNonAnsweredQuestion && isset($this->wrongAnsweredQuestions[$qId])) {
482 continue;
483 }
484
485 if (isset($this->postponedQuestions[$qId])) {
486 $postponedQuestions[$qId] = $this->postponedQuestions[$qId];
487 continue;
488 }
489
490 return $qId;
491 }
492
493 if (!$excludePostponedQuestions && count($postponedQuestions)) {
495 }
496 }
497
498 return null;
499 }

References $postponedQuestions, fetchMostLeastPostponedQuestion(), isPreventCheckedQuestionsFromComingUpEnabled(), and isQuestionChecked().

Referenced by getUpcomingQuestionId().

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

◆ getActiveId()

◆ getCompleteQuestionsData()

ilTestSequenceDynamicQuestionSet::getCompleteQuestionsData ( )

Definition at line 691 of file class.ilTestSequenceDynamicQuestionSet.php.

691 : array
692 {
693 return $this->questionSet->getCompleteQuestionList()->getQuestionDataArray();
694 }

◆ getCurrentPositionIndex()

ilTestSequenceDynamicQuestionSet::getCurrentPositionIndex (   $questionId)

Definition at line 577 of file class.ilTestSequenceDynamicQuestionSet.php.

577 : ?int
578 {
579 $i = 0;
580
581 foreach ($this->getSelectionOrderedSequence() as $qId) {
582 $i++;
583
584 if ($qId == $questionId) {
585 return $i;
586 }
587 }
588
589 return null;
590 }
$i
Definition: metadata.php:41

References $i, and getSelectionOrderedSequence().

+ Here is the call graph for this function:

◆ getCurrentQuestionId()

ilTestSequenceDynamicQuestionSet::getCurrentQuestionId ( )

◆ getFilteredQuestionsData()

ilTestSequenceDynamicQuestionSet::getFilteredQuestionsData ( )

Definition at line 696 of file class.ilTestSequenceDynamicQuestionSet.php.

696 : array
697 {
698 return $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
699 }

◆ getLastPositionIndex()

ilTestSequenceDynamicQuestionSet::getLastPositionIndex ( )

Definition at line 592 of file class.ilTestSequenceDynamicQuestionSet.php.

592 : int
593 {
594 return count($this->getSelectionOrderedSequence());
595 }

References getSelectionOrderedSequence().

+ Here is the call graph for this function:

◆ getNewOrderIndexForQuestionTracking()

ilTestSequenceDynamicQuestionSet::getNewOrderIndexForQuestionTracking ( )
private

Definition at line 304 of file class.ilTestSequenceDynamicQuestionSet.php.

305 {
306 $query = "
307 SELECT (MAX(orderindex) + 1) new_order_index
308 FROM tst_seq_qst_tracking
309 WHERE active_fi = %s
310 AND pass = %s
311 ";
312
313 $res = $this->db->queryF($query, array('integer','integer'), array($this->getActiveId(), 0));
314
315 $row = $this->db->fetchAssoc($res);
316
317 if ($row['new_order_index']) {
318 return $row['new_order_index'];
319 }
320
321 return 1;
322 }
$res
Definition: ltiservices.php:69
$query

References $query, $res, and getActiveId().

Referenced by saveNewlyTrackedQuestion().

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

◆ getOpenQuestions()

ilTestSequenceDynamicQuestionSet::getOpenQuestions ( )

Definition at line 557 of file class.ilTestSequenceDynamicQuestionSet.php.

557 : array
558 {
559 $completeQuestionIds = array_keys($this->questionSet->getAllQuestionsData());
560
561 $openQuestions = array_diff($completeQuestionIds, $this->correctAnsweredQuestions);
562
563 return $openQuestions;
564 }

Referenced by openQuestionExists().

+ Here is the caller graph for this function:

◆ getOrderedSequence()

ilTestSequenceDynamicQuestionSet::getOrderedSequence ( )
private

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

817 : array
818 {
820
821 $nonAnsweredQuestions = $this->fetchQuestionSequence(
822 true,
823 true
824 );
825
826 $postponedNonAnsweredQuestions = $this->fetchQuestionSequence(
827 false,
828 true
829 );
830
832 true,
833 false
834 );
835
836 $postponedWrongAnsweredQuestions = $this->fetchQuestionSequence(
837 false,
838 false
839 );
840
841 $questionOrder = array_merge(
843 $nonAnsweredQuestions,
844 $postponedNonAnsweredQuestions,
846 $postponedWrongAnsweredQuestions
847 );
848
849 return $questionOrder;
850 }
fetchQuestionSequence($nonPostponedQuestions, $nonAnsweredQuestions)

References $correctAnsweredQuestions, $wrongAnsweredQuestions, fetchQuestionSequence(), and fetchTrackedCorrectAnsweredSequence().

Referenced by getSelectionOrderedSequence().

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

◆ getPass()

ilTestSequenceDynamicQuestionSet::getPass ( )

Definition at line 734 of file class.ilTestSequenceDynamicQuestionSet.php.

734 : int
735 {
736 return 0;
737 }

◆ getQuestionSet()

ilTestSequenceDynamicQuestionSet::getQuestionSet ( )
Returns
ilTestDynamicQuestionSet

Definition at line 686 of file class.ilTestSequenceDynamicQuestionSet.php.

References $questionSet.

Referenced by getSelectionOrderedSequence().

+ Here is the caller graph for this function:

◆ getSelectionOrderedSequence()

ilTestSequenceDynamicQuestionSet::getSelectionOrderedSequence ( )

Definition at line 852 of file class.ilTestSequenceDynamicQuestionSet.php.

852 : array
853 {
854 $sequence = array();
855
856 foreach ($this->getOrderedSequence() as $qId) {
857 if (!$this->getQuestionSet()->getSelectionQuestionList()->isInList($qId)) {
858 continue;
859 }
860
861 $sequence[] = $qId;
862 }
863
864 return $sequence;
865 }

References getOrderedSequence(), and getQuestionSet().

Referenced by getCurrentPositionIndex(), getLastPositionIndex(), and getSequenceSummary().

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

◆ getSequenceSummary()

ilTestSequenceDynamicQuestionSet::getSequenceSummary (   $obligationsFilterEnabled = false)

Implements ilTestSequenceSummaryProvider.

Definition at line 867 of file class.ilTestSequenceDynamicQuestionSet.php.

867 : array
868 {
869 $questionOrder = $this->getSelectionOrderedSequence();
870
871 $solved_questions = ilObjTest::_getSolvedQuestions($this->getActiveId());
872
873 $key = 1;
874
875 $summary = array();
876
877 foreach ($questionOrder as $qId) {
878 $question = ilObjTest::_instanciateQuestion($qId);
879 if (is_object($question)) {
880 $worked_through = $question->_isWorkedThrough($this->getActiveId(), $question->getId(), $this->getPass());
881 $solved = 0;
882 if (array_key_exists($question->getId(), $solved_questions)) {
883 $solved = $solved_questions[$question->getId()]["solved"];
884 }
885
886 // do not show postponing, since this happens implicit on dircarding solutions (CTM only)
887 //$is_postponed = $this->isPostponedQuestion($question->getId());
888
889 $row = array("nr" => "$key", "title" => $question->getTitle(), "qid" => $question->getId(), "visited" => $worked_through, "solved" => (($solved) ? "1" : "0"), "description" => $question->getComment(), "points" => $question->getMaximumPoints(), "worked_through" => $worked_through, "postponed" => false, "sequence" => $qId, "obligatory" => ilObjTest::isQuestionObligatory($question->getId()), 'isAnswered' => $question->isAnswered($this->getActiveId(), $this->getPass()));
890
891 if (!$obligationsFilterEnabled || $row['obligatory']) {
892 $summary[] = $row;
893 }
894
895 $key++;
896 }
897 }
898
899 return $summary;
900 }
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

References ILIAS\LTI\ToolProvider\$key, ilObjTest\_getSolvedQuestions(), ilObjTest\_instanciateQuestion(), getActiveId(), getSelectionOrderedSequence(), and ilObjTest\isQuestionObligatory().

+ Here is the call graph for this function:

◆ getTrackedQuestionCount()

ilTestSequenceDynamicQuestionSet::getTrackedQuestionCount ( )

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

566 : int
567 {
568 $uniqueQuestions = array();
569
570 foreach ($this->questionTracking as $trackedQuestion) {
571 $uniqueQuestions[$trackedQuestion['qid']] = $trackedQuestion['qid'];
572 }
573
574 return count($uniqueQuestions);
575 }

◆ getTrackedQuestionList()

ilTestSequenceDynamicQuestionSet::getTrackedQuestionList (   $currentQuestionId = null)

Definition at line 530 of file class.ilTestSequenceDynamicQuestionSet.php.

530 : array
531 {
532 $questionList = array();
533
534 if ($currentQuestionId) {
535 $questionList[$currentQuestionId] = $this->questionSet->getQuestionData($currentQuestionId);
536 }
537
538 foreach (array_reverse($this->questionTracking) as $trackedQuestion) {
539 if (!isset($questionList[ $trackedQuestion['qid'] ])) {
540 $questionList[ $trackedQuestion['qid'] ] = $this->questionSet->getQuestionData($trackedQuestion['qid']);
541 }
542 }
543
544 return $questionList;
545 }

References $currentQuestionId.

◆ getUpcomingQuestionId()

ilTestSequenceDynamicQuestionSet::getUpcomingQuestionId ( )

Definition at line 446 of file class.ilTestSequenceDynamicQuestionSet.php.

447 {
448 if ($questionId = $this->fetchUpcomingQuestionId(true, true)) {
449 return $questionId;
450 }
451
452 if ($questionId = $this->fetchUpcomingQuestionId(false, true)) {
453 return $questionId;
454 }
455
456 if ($questionId = $this->fetchUpcomingQuestionId(true, false)) {
457 return $questionId;
458 }
459
460 if ($questionId = $this->fetchUpcomingQuestionId(false, false)) {
461 return $questionId;
462 }
463
464 return null;
465 }
fetchUpcomingQuestionId($excludePostponedQuestions, $forceNonAnsweredQuestion)

References fetchUpcomingQuestionId().

+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequenceDynamicQuestionSet::getUserSequenceQuestions ( )

Definition at line 703 of file class.ilTestSequenceDynamicQuestionSet.php.

703 : array
704 {
705 //return array_keys( $this->getTrackedQuestionList() );
706
707 $questionSequence = array();
708
709 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
710 $questionSequence = array_merge($questionSequence, $questions);
711 }
712
713 return $questionSequence;
714 }

◆ hasFilteredQuestionListCheckedQuestions()

ilTestSequenceDynamicQuestionSet::hasFilteredQuestionListCheckedQuestions ( )

Definition at line 902 of file class.ilTestSequenceDynamicQuestionSet.php.

902 : bool
903 {
904 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
905
906 foreach ($filteredQuestions as $filteredQuestion) {
907 if ($this->isQuestionChecked($filteredQuestion['question_id'])) {
908 return true;
909 }
910 }
911
912 return false;
913 }

References isQuestionChecked().

+ Here is the call graph for this function:

◆ hasStarted()

ilTestSequenceDynamicQuestionSet::hasStarted ( )

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

676 : bool
677 {
678 return $this->trackedQuestionExists();
679 }

References trackedQuestionExists().

+ Here is the call graph for this function:

◆ isAnsweredQuestion()

ilTestSequenceDynamicQuestionSet::isAnsweredQuestion (   $questionId)

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

501 : bool
502 {
503 return (
504 isset($this->correctAnsweredQuestions[$questionId])
505 || isset($this->wrongAnsweredQuestions[$questionId])
506 );
507 }

◆ isFilteredQuestion()

ilTestSequenceDynamicQuestionSet::isFilteredQuestion (   $questionId)

Definition at line 514 of file class.ilTestSequenceDynamicQuestionSet.php.

514 : bool
515 {
516 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
517 if (in_array($questionId, $questions)) {
518 return true;
519 }
520 }
521
522 return false;
523 }

Referenced by cleanupQuestions().

+ Here is the caller graph for this function:

◆ isPostponedQuestion()

ilTestSequenceDynamicQuestionSet::isPostponedQuestion (   $questionId)

Definition at line 509 of file class.ilTestSequenceDynamicQuestionSet.php.

509 : bool
510 {
511 return isset($this->postponedQuestions[$questionId]);
512 }

◆ isPreventCheckedQuestionsFromComingUpEnabled()

ilTestSequenceDynamicQuestionSet::isPreventCheckedQuestionsFromComingUpEnabled ( )

Definition at line 154 of file class.ilTestSequenceDynamicQuestionSet.php.

References $preventCheckedQuestionsFromComingUpEnabled.

Referenced by fetchUpcomingQuestionId().

+ Here is the caller graph for this function:

◆ isQuestionChecked()

ilTestSequenceDynamicQuestionSet::isQuestionChecked (   $questionId)

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

610 : bool
611 {
612 return isset($this->alreadyCheckedQuestions[$questionId]);
613 }

Referenced by fetchUpcomingQuestionId(), hasFilteredQuestionListCheckedQuestions(), and resetFilteredQuestionListsCheckedStatus().

+ Here is the caller graph for this function:

◆ loadAnswerStatus()

ilTestSequenceDynamicQuestionSet::loadAnswerStatus ( )
private

Definition at line 205 of file class.ilTestSequenceDynamicQuestionSet.php.

206 {
207 $query = "
208 SELECT question_fi, correctness
209 FROM tst_seq_qst_answstatus
210 WHERE active_fi = %s
211 AND pass = %s
212 ";
213
214 $res = $this->db->queryF($query, array('integer','integer'), array($this->activeId, 0));
215
216 $this->correctAnsweredQuestions = array();
217 $this->wrongAnsweredQuestions = array();
218
219 while ($row = $this->db->fetchAssoc($res)) {
220 if ($row['correctness']) {
221 $this->correctAnsweredQuestions[ $row['question_fi'] ] = $row['question_fi'];
222 } else {
223 $this->wrongAnsweredQuestions[ $row['question_fi'] ] = $row['question_fi'];
224 }
225 }
226 }

References $query, and $res.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ loadCheckedQuestions()

ilTestSequenceDynamicQuestionSet::loadCheckedQuestions ( )
private

Definition at line 246 of file class.ilTestSequenceDynamicQuestionSet.php.

247 {
248 $res = $this->db->queryF(
249 "SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
250 array('integer','integer'),
251 array($this->getActiveId(), 0)
252 );
253
254 while ($row = $this->db->fetchAssoc($res)) {
255 $this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
256 }
257 }

References $res, and getActiveId().

Referenced by loadFromDb().

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

◆ loadFromDb()

◆ loadPostponedQuestions()

ilTestSequenceDynamicQuestionSet::loadPostponedQuestions ( )
private

Definition at line 228 of file class.ilTestSequenceDynamicQuestionSet.php.

229 {
230 $query = "
231 SELECT question_fi, cnt
232 FROM tst_seq_qst_postponed
233 WHERE active_fi = %s
234 AND pass = %s
235 ";
236
237 $res = $this->db->queryF($query, array('integer','integer'), array($this->activeId, 0));
238
239 $this->postponedQuestions = array();
240
241 while ($row = $this->db->fetchAssoc($res)) {
242 $this->postponedQuestions[ $row['question_fi'] ] = $row['cnt'];
243 }
244 }

References $query, and $res.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ loadQuestions()

ilTestSequenceDynamicQuestionSet::loadQuestions ( ilObjTestDynamicQuestionSetConfig  $dynamicQuestionSetConfig,
ilTestDynamicQuestionSetFilterSelection  $filterSelection 
)

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

404 {
405 $this->questionSet->load($dynamicQuestionSetConfig, $filterSelection);
406
407 // echo "<table><tr>";
408// echo "<td width='200'><pre>".print_r($this->questionSet->getActualQuestionSequence(), 1)."</pre></td>";
409// echo "<td width='200'><pre>".print_r($this->correctAnsweredQuestions, 1)."</pre></td>";
410// echo "<td width='200'><pre>".print_r($this->wrongAnsweredQuestions, 1)."</pre></td>";
411// echo "</tr></table>";
412 }

◆ loadQuestionTracking()

ilTestSequenceDynamicQuestionSet::loadQuestionTracking ( )
private

Definition at line 183 of file class.ilTestSequenceDynamicQuestionSet.php.

184 {
185 $query = "
186 SELECT question_fi, status
187 FROM tst_seq_qst_tracking
188 WHERE active_fi = %s
189 AND pass = %s
190 ORDER BY orderindex ASC
191 ";
192
193 $res = $this->db->queryF($query, array('integer','integer'), array($this->activeId, 0));
194
195 $this->questionTracking = array();
196
197 while ($row = $this->db->fetchAssoc($res)) {
198 $this->questionTracking[] = array(
199 'qid' => $row['question_fi'],
200 'status' => $row['status']
201 );
202 }
203 }

References $query, and $res.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ openQuestionExists()

ilTestSequenceDynamicQuestionSet::openQuestionExists ( )

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

552 : bool
553 {
554 return count($this->getOpenQuestions()) > 0;
555 }

References getOpenQuestions().

+ Here is the call graph for this function:

◆ orderQuestionsByPostponeCount()

ilTestSequenceDynamicQuestionSet::orderQuestionsByPostponeCount (   $postponedQuestions)
private

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

741 : array
742 {
743 $maxPostponeCount = max($postponedQuestions);
744
745 $orderedSequence = array();
746 $postponedCountDomain = array_flip($postponedQuestions);
747
748 for ($i = 1; $i <= $maxPostponeCount; $i++) {
749 if (!isset($postponedCountDomain[$i])) {
750 continue;
751 }
752
753 foreach ($postponedQuestions as $qId => $postponeCount) {
754 if ($postponeCount == $i) {
755 $orderedSequence[] = $qId;
756 }
757 }
758 }
759
760 return $orderedSequence;
761 }

References $i, and $postponedQuestions.

Referenced by fetchQuestionSequence().

+ Here is the caller graph for this function:

◆ removeQuestionsNotCheckedAnymore()

ilTestSequenceDynamicQuestionSet::removeQuestionsNotCheckedAnymore ( )
private

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

384 {
385 $NOT_IN_checkedQuestions = $this->db->in('question_fi', $this->alreadyCheckedQuestions, true, 'integer');
386
387 // BEGIN: FIX IN QUERY
388 if ($NOT_IN_checkedQuestions == ' 1=2 ') {
389 $NOT_IN_checkedQuestions = ' 1=1 ';
390 }
391 // END: FIX IN QUERY
392
393 $query = "
394 DELETE FROM tst_seq_qst_checked
395 WHERE active_fi = %s
396 AND pass = %s
397 AND $NOT_IN_checkedQuestions
398 ";
399
400 $this->db->manipulateF($query, array('integer', 'integer'), array((int) $this->getActiveId(), 0));
401 }

References $query, and getActiveId().

Referenced by saveToDb().

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

◆ removeQuestionsNotPostponedAnymore()

ilTestSequenceDynamicQuestionSet::removeQuestionsNotPostponedAnymore ( )
private

Definition at line 358 of file class.ilTestSequenceDynamicQuestionSet.php.

359 {
360 $INquestions = $this->db->in('question_fi', array_keys($this->postponedQuestions), true, 'integer');
361
362 $query = "
363 DELETE FROM tst_seq_qst_postponed
364 WHERE active_fi = %s
365 AND pass = %s
366 AND $INquestions
367 ";
368
369 $this->db->manipulateF($query, array('integer','integer'), array($this->getActiveId(), 0));
370 }

References $query, and getActiveId().

Referenced by saveToDb().

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

◆ resetFilteredQuestionListsCheckedStatus()

ilTestSequenceDynamicQuestionSet::resetFilteredQuestionListsCheckedStatus ( )

Definition at line 915 of file class.ilTestSequenceDynamicQuestionSet.php.

916 {
917 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
918
919 foreach ($filteredQuestions as $filteredQuestion) {
920 if ($this->isQuestionChecked($filteredQuestion['question_id'])) {
921 $this->setQuestionUnchecked($filteredQuestion['question_id']);
922 }
923 }
924 }

References isQuestionChecked(), and setQuestionUnchecked().

+ Here is the call graph for this function:

◆ resetTrackedQuestionList()

ilTestSequenceDynamicQuestionSet::resetTrackedQuestionList ( )

Definition at line 547 of file class.ilTestSequenceDynamicQuestionSet.php.

548 {
549 $this->questionTracking = array();
550 }

◆ saveNewlyAnsweredQuestionsAnswerStatus()

ilTestSequenceDynamicQuestionSet::saveNewlyAnsweredQuestionsAnswerStatus ( )
private

Definition at line 324 of file class.ilTestSequenceDynamicQuestionSet.php.

325 {
326 if ((int) $this->newlyAnsweredQuestion) {
327 $this->db->replace(
328 'tst_seq_qst_answstatus',
329 array(
330 'active_fi' => array('integer', (int) $this->getActiveId()),
331 'pass' => array('integer', 0),
332 'question_fi' => array('integer', (int) $this->newlyAnsweredQuestion)
333 ),
334 array(
335 'correctness' => array('integer', (int) $this->newlyAnsweredQuestionsAnswerStatus)
336 )
337 );
338 }
339 }

References getActiveId().

Referenced by saveToDb().

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

◆ saveNewlyCheckedQuestion()

ilTestSequenceDynamicQuestionSet::saveNewlyCheckedQuestion ( )
private

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

373 {
374 if ((int) $this->newlyCheckedQuestion) {
375 $this->db->replace('tst_seq_qst_checked', array(
376 'active_fi' => array('integer', (int) $this->getActiveId()),
377 'pass' => array('integer', 0),
378 'question_fi' => array('integer', (int) $this->newlyCheckedQuestion)
379 ), array());
380 }
381 }

References getActiveId().

Referenced by saveToDb().

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

◆ saveNewlyPostponedQuestion()

ilTestSequenceDynamicQuestionSet::saveNewlyPostponedQuestion ( )
private

Definition at line 341 of file class.ilTestSequenceDynamicQuestionSet.php.

342 {
343 if ((int) $this->newlyPostponedQuestion) {
344 $this->db->replace(
345 'tst_seq_qst_postponed',
346 array(
347 'active_fi' => array('integer', (int) $this->getActiveId()),
348 'pass' => array('integer', 0),
349 'question_fi' => array('integer', (int) $this->newlyPostponedQuestion)
350 ),
351 array(
352 'cnt' => array('integer', (int) $this->newlyPostponedQuestionsCount)
353 )
354 );
355 }
356 }

References getActiveId().

Referenced by saveToDb().

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

◆ saveNewlyTrackedQuestion()

ilTestSequenceDynamicQuestionSet::saveNewlyTrackedQuestion ( )
private

Definition at line 284 of file class.ilTestSequenceDynamicQuestionSet.php.

285 {
286 if ((int) $this->newlyTrackedQuestion) {
287 $newOrderIndex = $this->getNewOrderIndexForQuestionTracking();
288
289 $this->db->replace(
290 'tst_seq_qst_tracking',
291 array(
292 'active_fi' => array('integer', (int) $this->getActiveId()),
293 'pass' => array('integer', 0),
294 'question_fi' => array('integer', (int) $this->newlyTrackedQuestion)
295 ),
296 array(
297 'status' => array('text', $this->newlyTrackedQuestionsStatus),
298 'orderindex' => array('integer', $newOrderIndex)
299 )
300 );
301 }
302 }

References getActiveId(), and getNewOrderIndexForQuestionTracking().

Referenced by saveToDb().

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

◆ saveToDb()

ilTestSequenceDynamicQuestionSet::saveToDb ( )

Definition at line 259 of file class.ilTestSequenceDynamicQuestionSet.php.

260 {
261 $this->db->manipulateF(
262 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
263 array('integer','integer'),
264 array($this->getActiveId(), 0)
265 );
266
267 $this->db->insert('tst_sequence', array(
268 'active_fi' => array('integer', $this->getActiveId()),
269 'pass' => array('integer', 0),
270 'sequence' => array('clob', null),
271 'postponed' => array('text', null),
272 'hidden' => array('text', null),
273 'tstamp' => array('integer', time())
274 ));
275
282 }

References getActiveId(), removeQuestionsNotCheckedAnymore(), removeQuestionsNotPostponedAnymore(), saveNewlyAnsweredQuestionsAnswerStatus(), saveNewlyCheckedQuestion(), saveNewlyPostponedQuestion(), and saveNewlyTrackedQuestion().

+ Here is the call graph for this function:

◆ setCurrentQuestionId()

ilTestSequenceDynamicQuestionSet::setCurrentQuestionId (   $currentQuestionId)
Parameters
int$currentQuestionId

Definition at line 170 of file class.ilTestSequenceDynamicQuestionSet.php.

171 {
172 $this->currentQuestionId = $currentQuestionId;
173 }

References $currentQuestionId.

◆ setPreventCheckedQuestionsFromComingUpEnabled()

ilTestSequenceDynamicQuestionSet::setPreventCheckedQuestionsFromComingUpEnabled (   $preventCheckedQuestionsFromComingUpEnabled)

Definition at line 149 of file class.ilTestSequenceDynamicQuestionSet.php.

150 {
151 $this->preventCheckedQuestionsFromComingUpEnabled = $preventCheckedQuestionsFromComingUpEnabled;
152 }

References $preventCheckedQuestionsFromComingUpEnabled.

◆ setQuestionAnsweredCorrect()

ilTestSequenceDynamicQuestionSet::setQuestionAnsweredCorrect (   $questionId)

Definition at line 636 of file class.ilTestSequenceDynamicQuestionSet.php.

637 {
638 $this->trackQuestion($questionId, 'correct');
639
640 $this->correctAnsweredQuestions[$questionId] = $questionId;
641
642 if (isset($this->wrongAnsweredQuestions[$questionId])) {
643 unset($this->wrongAnsweredQuestions[$questionId]);
644 }
645
646 $this->newlyAnsweredQuestion = $questionId;
647 $this->newlyAnsweredQuestionsAnswerStatus = true;
648 }

References trackQuestion().

+ Here is the call graph for this function:

◆ setQuestionAnsweredWrong()

ilTestSequenceDynamicQuestionSet::setQuestionAnsweredWrong (   $questionId)

Definition at line 650 of file class.ilTestSequenceDynamicQuestionSet.php.

651 {
652 $this->trackQuestion($questionId, 'wrong');
653
654 $this->wrongAnsweredQuestions[$questionId] = $questionId;
655
656 if (isset($this->correctAnsweredQuestions[$questionId])) {
657 unset($this->correctAnsweredQuestions[$questionId]);
658 }
659
660 $this->newlyAnsweredQuestion = $questionId;
661 $this->newlyAnsweredQuestionsAnswerStatus = false;
662 }

References trackQuestion().

+ Here is the call graph for this function:

◆ setQuestionChecked()

ilTestSequenceDynamicQuestionSet::setQuestionChecked (   $questionId)

Definition at line 604 of file class.ilTestSequenceDynamicQuestionSet.php.

605 {
606 $this->newlyCheckedQuestion = $questionId;
607 $this->alreadyCheckedQuestions[$questionId] = $questionId;
608 }

◆ setQuestionPostponed()

ilTestSequenceDynamicQuestionSet::setQuestionPostponed (   $questionId)

Definition at line 615 of file class.ilTestSequenceDynamicQuestionSet.php.

616 {
617 $this->trackQuestion($questionId, 'postponed');
618
619 if (!isset($this->postponedQuestions[$questionId])) {
620 $this->postponedQuestions[$questionId] = 0;
621 }
622
623 $this->postponedQuestions[$questionId]++;
624
625 $this->newlyPostponedQuestion = $questionId;
626 $this->newlyPostponedQuestionsCount = $this->postponedQuestions[$questionId];
627 }

References trackQuestion().

+ Here is the call graph for this function:

◆ setQuestionUnchecked()

ilTestSequenceDynamicQuestionSet::setQuestionUnchecked (   $questionId)

Definition at line 599 of file class.ilTestSequenceDynamicQuestionSet.php.

600 {
601 unset($this->alreadyCheckedQuestions[$questionId]);
602 }

Referenced by resetFilteredQuestionListsCheckedStatus().

+ Here is the caller graph for this function:

◆ trackedQuestionExists()

ilTestSequenceDynamicQuestionSet::trackedQuestionExists ( )

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

525 : bool
526 {
527 return (bool) count($this->questionTracking);
528 }

Referenced by hasStarted().

+ Here is the caller graph for this function:

◆ trackQuestion()

ilTestSequenceDynamicQuestionSet::trackQuestion (   $questionId,
  $answerStatus 
)
private

Definition at line 664 of file class.ilTestSequenceDynamicQuestionSet.php.

665 {
666 $this->questionTracking[] = array(
667 'qid' => $questionId, 'status' => $answerStatus
668 );
669
670 $this->newlyTrackedQuestion = $questionId;
671 $this->newlyTrackedQuestionsStatus = $answerStatus;
672 }

Referenced by setQuestionAnsweredCorrect(), setQuestionAnsweredWrong(), and setQuestionPostponed().

+ Here is the caller graph for this function:

◆ unsetQuestionPostponed()

ilTestSequenceDynamicQuestionSet::unsetQuestionPostponed (   $questionId)

Definition at line 629 of file class.ilTestSequenceDynamicQuestionSet.php.

630 {
631 if (isset($this->postponedQuestions[$questionId])) {
632 unset($this->postponedQuestions[$questionId]);
633 }
634 }

Field Documentation

◆ $activeId

ilTestSequenceDynamicQuestionSet::$activeId = null
private

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

Referenced by __construct(), and getActiveId().

◆ $alreadyCheckedQuestions

ilTestSequenceDynamicQuestionSet::$alreadyCheckedQuestions
private

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

◆ $correctAnsweredQuestions

ilTestSequenceDynamicQuestionSet::$correctAnsweredQuestions = array()
private

Definition at line 94 of file class.ilTestSequenceDynamicQuestionSet.php.

Referenced by getOrderedSequence().

◆ $currentQuestionId

ilTestSequenceDynamicQuestionSet::$currentQuestionId
private

◆ $db

ilTestSequenceDynamicQuestionSet::$db = null
private

Definition at line 34 of file class.ilTestSequenceDynamicQuestionSet.php.

Referenced by __construct().

◆ $newlyAnsweredQuestion

ilTestSequenceDynamicQuestionSet::$newlyAnsweredQuestion
private

Definition at line 104 of file class.ilTestSequenceDynamicQuestionSet.php.

◆ $newlyAnsweredQuestionsAnswerStatus

ilTestSequenceDynamicQuestionSet::$newlyAnsweredQuestionsAnswerStatus
private

Definition at line 109 of file class.ilTestSequenceDynamicQuestionSet.php.

◆ $newlyCheckedQuestion

ilTestSequenceDynamicQuestionSet::$newlyCheckedQuestion
private

Definition at line 89 of file class.ilTestSequenceDynamicQuestionSet.php.

◆ $newlyPostponedQuestion

ilTestSequenceDynamicQuestionSet::$newlyPostponedQuestion
private

Definition at line 74 of file class.ilTestSequenceDynamicQuestionSet.php.

◆ $newlyPostponedQuestionsCount

ilTestSequenceDynamicQuestionSet::$newlyPostponedQuestionsCount
private

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

◆ $newlyTrackedQuestion

ilTestSequenceDynamicQuestionSet::$newlyTrackedQuestion
private

Definition at line 59 of file class.ilTestSequenceDynamicQuestionSet.php.

◆ $newlyTrackedQuestionsStatus

ilTestSequenceDynamicQuestionSet::$newlyTrackedQuestionsStatus
private

Definition at line 64 of file class.ilTestSequenceDynamicQuestionSet.php.

◆ $postponedQuestions

ilTestSequenceDynamicQuestionSet::$postponedQuestions = array()
private

◆ $preventCheckedQuestionsFromComingUpEnabled

ilTestSequenceDynamicQuestionSet::$preventCheckedQuestionsFromComingUpEnabled
private

◆ $questionSet

ilTestSequenceDynamicQuestionSet::$questionSet = null
private

Definition at line 39 of file class.ilTestSequenceDynamicQuestionSet.php.

Referenced by __construct(), and getQuestionSet().

◆ $questionTracking

ilTestSequenceDynamicQuestionSet::$questionTracking = array()
private

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

◆ $wrongAnsweredQuestions

ilTestSequenceDynamicQuestionSet::$wrongAnsweredQuestions = array()
private

Definition at line 99 of file class.ilTestSequenceDynamicQuestionSet.php.

Referenced by getOrderedSequence().


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