ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilTestSequenceDynamicQuestionSet Class Reference
+ Inheritance diagram for ilTestSequenceDynamicQuestionSet:
+ Collaboration diagram for ilTestSequenceDynamicQuestionSet:

Public Member Functions

 __construct (ilDB $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 ()
 
 getCompleteQuestionsData ()
 
 getFilteredQuestionsData ()
 
 getUserSequenceQuestions ()
 
 getPass ()
 
 getSequenceSummary ($obligationsFilterEnabled=false)
 
 hasFilteredQuestionListCheckedQuestions ()
 
 resetFilteredQuestionListsCheckedStatus ()
 

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, $excludeQuestionId)
 
 fetchTrackedCorrectAnsweredSequence ($excludeQuestionId)
 
 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 16 of file class.ilTestSequenceDynamicQuestionSet.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
ilTestDynamicQuestionSet$questionSet

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

References $activeId, $db, and $questionSet.

109  {
110  $this->db = $db;
111  $this->questionSet = $questionSet;
112  $this->activeId = $activeId;
113 
114  $this->newlyTrackedQuestion = null;
115  $this->newlyTrackedQuestionsStatus = null;
116 
117  $this->newlyPostponedQuestion = null;
118  $this->newlyPostponedQuestionsCount = null;
119 
120  $this->newlyAnsweredQuestion = null;
121  $this->newlyAnsweredQuestionsAnswerStatus = null;
122 
123  $this->alreadyCheckedQuestions = array();
124  $this->newlyCheckedQuestion = null;
125 
126  $this->preventCheckedQuestionsFromComingUpEnabled = false;
127 
128  $this->currentQuestionId = null;
129  }

Member Function Documentation

◆ cleanupQuestions()

ilTestSequenceDynamicQuestionSet::cleanupQuestions ( ilTestSessionDynamicQuestionSet  $testSession)

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

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

408  {
409  switch( true )
410  {
411  case !$this->questionSet->questionExists($testSession->getCurrentQuestionId()):
412  case !$this->isFilteredQuestion($testSession->getCurrentQuestionId()):
413 
414  $testSession->setCurrentQuestionId(null);
415  }
416 
417  foreach($this->postponedQuestions as $questionId)
418  {
419  if( !$this->questionSet->questionExists($questionId) )
420  {
421  unset($this->postponedQuestions[$questionId]);
422  }
423  }
424 
425  foreach($this->wrongAnsweredQuestions as $questionId)
426  {
427  if( !$this->questionSet->questionExists($questionId) )
428  {
429  unset($this->wrongAnsweredQuestions[$questionId]);
430  }
431  }
432 
433  foreach($this->correctAnsweredQuestions as $questionId)
434  {
435  if( !$this->questionSet->questionExists($questionId) )
436  {
437  unset($this->correctAnsweredQuestions[$questionId]);
438  }
439  }
440  }
+ Here is the call graph for this function:

◆ fetchMostLeastPostponedQuestion()

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

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

References $postponedQuestions.

Referenced by fetchUpcomingQuestionId().

731  {
732  $minPostponeCount = null;
733  $minPostponeItem = null;
734 
735  foreach(array_reverse($postponedQuestions, true) as $qId => $postponeCount)
736  {
737  if($minPostponeCount === null || $postponeCount <= $minPostponeCount)
738  {
739  $minPostponeCount = $postponeCount;
740  $minPostponeItem = $qId;
741  }
742  }
743  return $minPostponeItem;
744  }
+ Here is the caller graph for this function:

◆ fetchQuestionSequence()

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

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

References $postponedQuestions, and orderQuestionsByPostponeCount().

Referenced by getOrderedSequence().

780  {
781  $questionSequence = array();
782 
783  foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
784  {
785  $postponedQuestions = array();
786 
787  foreach($questions as $pos => $qId)
788  {
789  if( $qId == $excludeQuestionId )
790  {
791  continue;
792  }
793 
794  if( isset($this->correctAnsweredQuestions[$qId]) )
795  {
796  continue;
797  }
798 
799  if( $nonAnsweredQuestions && isset($this->wrongAnsweredQuestions[$qId]) )
800  {
801  continue;
802  }
803  elseif( !$nonAnsweredQuestions && !isset($this->wrongAnsweredQuestions[$qId]) )
804  {
805  continue;
806  }
807 
808  if( !$nonPostponedQuestions && isset($this->postponedQuestions[$qId]) )
809  {
810  $postponedQuestions[$qId] = $this->postponedQuestions[$qId];
811  continue;
812  }
813  elseif($nonPostponedQuestions && !isset($this->postponedQuestions[$qId]))
814  {
815  $questionSequence[] = $qId;
816  }
817  }
818 
819  if( !$nonPostponedQuestions && count($postponedQuestions) )
820  {
821  $questionSequence = array_merge(
822  $questionSequence, $this->orderQuestionsByPostponeCount($postponedQuestions)
823  );
824  }
825  }
826 
827  return $questionSequence;
828  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchTrackedCorrectAnsweredSequence()

ilTestSequenceDynamicQuestionSet::fetchTrackedCorrectAnsweredSequence (   $excludeQuestionId)
private

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

Referenced by getOrderedSequence().

831  {
832  $questionSequence = array();
833 
834  foreach($this->questionTracking as $key => $question)
835  {
836  $qId = $question['qid'];
837 
838  if($qId == $excludeQuestionId)
839  {
840  continue;
841  }
842 
843  if( !isset($this->correctAnsweredQuestions[$qId]) )
844  {
845  continue;
846  }
847 
848  $questionSequence[] = $qId;
849  }
850 
851  return $questionSequence;
852  }
+ Here is the caller graph for this function:

◆ fetchUpcomingQuestionId()

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

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

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

Referenced by getUpcomingQuestionId().

462  {
463  foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
464  {
465  $postponedQuestions = array();
466 
467  foreach($questions as $pos => $qId)
468  {
469  if( isset($this->correctAnsweredQuestions[$qId]) )
470  {
471  continue;
472  }
473 
475  {
476  continue;
477  }
478 
479  if( $forceNonAnsweredQuestion && isset($this->wrongAnsweredQuestions[$qId]) )
480  {
481  continue;
482  }
483 
484  if( isset($this->postponedQuestions[$qId]) )
485  {
486  $postponedQuestions[$qId] = $this->postponedQuestions[$qId];
487  continue;
488  }
489 
490  return $qId;
491  }
492 
493  if( !$excludePostponedQuestions && count($postponedQuestions) )
494  {
496  }
497  }
498 
499  return null;
500  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

◆ getCompleteQuestionsData()

ilTestSequenceDynamicQuestionSet::getCompleteQuestionsData ( )

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

701  {
702  return $this->questionSet->getCompleteQuestionList()->getQuestionDataArray();
703  }

◆ getCurrentPositionIndex()

ilTestSequenceDynamicQuestionSet::getCurrentPositionIndex (   $questionId)

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

585  {
586  $i = 0;
587 
588  foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
589  {
590  foreach($questions as $pos => $qId)
591  {
592  $i++;
593 
594  if($qId == $questionId)
595  {
596  return $i;
597  }
598  }
599  }
600 
601  return null;
602  }

◆ getCurrentQuestionId()

ilTestSequenceDynamicQuestionSet::getCurrentQuestionId ( )
Returns
int

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

References $currentQuestionId.

Referenced by getOrderedSequence().

+ Here is the caller graph for this function:

◆ getFilteredQuestionsData()

ilTestSequenceDynamicQuestionSet::getFilteredQuestionsData ( )

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

706  {
707  return $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
708  }

◆ getLastPositionIndex()

ilTestSequenceDynamicQuestionSet::getLastPositionIndex ( )

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

605  {
606  $count = 0;
607 
608  foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
609  {
610  $count += count($questions);
611  }
612 
613  return $count;
614  }

◆ getNewOrderIndexForQuestionTracking()

ilTestSequenceDynamicQuestionSet::getNewOrderIndexForQuestionTracking ( )
private

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

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

Referenced by saveNewlyTrackedQuestion().

296  {
297  $query = "
298  SELECT (MAX(orderindex) + 1) new_order_index
299  FROM tst_seq_qst_tracking
300  WHERE active_fi = %s
301  AND pass = %s
302  ";
303 
304  $res = $this->db->queryF($query, array('integer','integer'), array($this->getActiveId(), 0));
305 
306  $row = $this->db->fetchAssoc($res);
307 
308  if( $row['new_order_index'] )
309  {
310  return $row['new_order_index'];
311  }
312 
313  return 1;
314  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOpenQuestions()

ilTestSequenceDynamicQuestionSet::getOpenQuestions ( )

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

Referenced by openQuestionExists().

564  {
565  $completeQuestionIds = array_keys( $this->questionSet->getAllQuestionsData() );
566 
567  $openQuestions = array_diff($completeQuestionIds, $this->correctAnsweredQuestions);
568 
569  return $openQuestions;
570  }
+ Here is the caller graph for this function:

◆ getOrderedSequence()

ilTestSequenceDynamicQuestionSet::getOrderedSequence ( )
private

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

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

Referenced by getSequenceSummary().

855  {
857  $this->getCurrentQuestionId()
858  );
859 
860  $nonAnsweredQuestions = $this->fetchQuestionSequence(
861  true, true, $this->getCurrentQuestionId()
862  );
863 
864  $postponedNonAnsweredQuestions = $this->fetchQuestionSequence(
865  false, true, $this->getCurrentQuestionId()
866  );
867 
869  true, false, $this->getCurrentQuestionId()
870  );
871 
872  $postponedWrongAnsweredQuestions = $this->fetchQuestionSequence(
873  false, false, $this->getCurrentQuestionId()
874  );
875 
876  $questionOrder = array_merge(
878  $nonAnsweredQuestions, $postponedNonAnsweredQuestions,
879  $wrongAnsweredQuestions, $postponedWrongAnsweredQuestions
880  );
881 
882  return $questionOrder;
883  }
fetchQuestionSequence($nonPostponedQuestions, $nonAnsweredQuestions, $excludeQuestionId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPass()

ilTestSequenceDynamicQuestionSet::getPass ( )

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

Referenced by getSequenceSummary().

747  {
748  return 0;
749  }
+ Here is the caller graph for this function:

◆ getSequenceSummary()

ilTestSequenceDynamicQuestionSet::getSequenceSummary (   $obligationsFilterEnabled = false)

Implements ilTestSequenceSummaryProvider.

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

References $row, ilObjTest\_getSolvedQuestions(), ilObjTest\_instanciateQuestion(), getActiveId(), getOrderedSequence(), getPass(), and ilObjTest\isQuestionObligatory().

886  {
887  $questionOrder = $this->getOrderedSequence();
888 
889  $solved_questions = ilObjTest::_getSolvedQuestions($this->getActiveId());
890 
891  $key = 1;
892 
893  foreach ($questionOrder as $qId)
894  {
895  $question =& ilObjTest::_instanciateQuestion($qId);
896  if(is_object($question))
897  {
898  $worked_through = $question->_isWorkedThrough($this->getActiveId(), $question->getId(), $this->getPass());
899  $solved = 0;
900  if(array_key_exists($question->getId(), $solved_questions))
901  {
902  $solved = $solved_questions[$question->getId()]["solved"];
903  }
904 
905  // do not show postponing, since this happens implicit on dircarding solutions (CTM only)
906  //$is_postponed = $this->isPostponedQuestion($question->getId());
907 
908  $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" => $is_postponed, "sequence" => $qId, "obligatory" => ilObjTest::isQuestionObligatory($question->getId()), 'isAnswered' => $question->isAnswered($this->getActiveId(), $this->getPass()));
909 
910  if(!$obligationsFilterEnabled || $row['obligatory'])
911  {
912  $summary[] = $row;
913  }
914 
915  $key++;
916  }
917  }
918 
919  return $summary;
920  }
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
_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
+ Here is the call graph for this function:

◆ getTrackedQuestionCount()

ilTestSequenceDynamicQuestionSet::getTrackedQuestionCount ( )

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

573  {
574  $uniqueQuestions = array();
575 
576  foreach($this->questionTracking as $trackedQuestion)
577  {
578  $uniqueQuestions[$trackedQuestion['qid']] = $trackedQuestion['qid'];
579  }
580 
581  return count($uniqueQuestions);
582  }

◆ getTrackedQuestionList()

ilTestSequenceDynamicQuestionSet::getTrackedQuestionList (   $currentQuestionId = null)

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

References $currentQuestionId.

534  {
535  $questionList = array();
536 
537  if( $currentQuestionId )
538  {
539  $questionList[$currentQuestionId] = $this->questionSet->getQuestionData($currentQuestionId);
540  }
541 
542  foreach( array_reverse($this->questionTracking) as $trackedQuestion)
543  {
544  if( !isset($questionList[ $trackedQuestion['qid'] ]) )
545  {
546  $questionList[ $trackedQuestion['qid'] ] = $this->questionSet->getQuestionData($trackedQuestion['qid']);
547  }
548  }
549 
550  return $questionList;
551  }

◆ getUpcomingQuestionId()

ilTestSequenceDynamicQuestionSet::getUpcomingQuestionId ( )

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

References fetchUpcomingQuestionId().

445  {
446  if( $questionId = $this->fetchUpcomingQuestionId(true, true) )
447  return $questionId;
448 
449  if( $questionId = $this->fetchUpcomingQuestionId(false, true) )
450  return $questionId;
451 
452  if( $questionId = $this->fetchUpcomingQuestionId(true, false) )
453  return $questionId;
454 
455  if( $questionId = $this->fetchUpcomingQuestionId(false, false) )
456  return $questionId;
457 
458  return null;
459  }
fetchUpcomingQuestionId($excludePostponedQuestions, $forceNonAnsweredQuestion)
+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequenceDynamicQuestionSet::getUserSequenceQuestions ( )

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

713  {
714  //return array_keys( $this->getTrackedQuestionList() );
715 
716  $questionSequence = array();
717 
718  foreach( $this->questionSet->getActualQuestionSequence() as $level => $questions )
719  {
720  $questionSequence = array_merge($questionSequence, $questions);
721  }
722 
723  return $questionSequence;
724  }

◆ hasFilteredQuestionListCheckedQuestions()

ilTestSequenceDynamicQuestionSet::hasFilteredQuestionListCheckedQuestions ( )

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

References isQuestionChecked().

923  {
924  $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
925 
926  foreach($filteredQuestions as $filteredQuestion)
927  {
928  if( $this->isQuestionChecked($filteredQuestion['question_id']) )
929  {
930  return true;
931  }
932  }
933 
934  return false;
935  }
+ Here is the call graph for this function:

◆ hasStarted()

ilTestSequenceDynamicQuestionSet::hasStarted ( )

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

References trackedQuestionExists().

+ Here is the call graph for this function:

◆ isAnsweredQuestion()

ilTestSequenceDynamicQuestionSet::isAnsweredQuestion (   $questionId)

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

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

◆ isFilteredQuestion()

ilTestSequenceDynamicQuestionSet::isFilteredQuestion (   $questionId)

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

Referenced by cleanupQuestions().

516  {
517  foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
518  {
519  if( in_array($questionId, $questions) )
520  {
521  return true;
522  }
523  }
524 
525  return false;
526  }
+ Here is the caller graph for this function:

◆ isPostponedQuestion()

ilTestSequenceDynamicQuestionSet::isPostponedQuestion (   $questionId)

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

511  {
512  return isset($this->postponedQuestions[$questionId]);
513  }

◆ isPreventCheckedQuestionsFromComingUpEnabled()

ilTestSequenceDynamicQuestionSet::isPreventCheckedQuestionsFromComingUpEnabled ( )

Definition at line 141 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 629 of file class.ilTestSequenceDynamicQuestionSet.php.

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

630  {
631  return isset($this->alreadyCheckedQuestions[$questionId]);
632  }
+ Here is the caller graph for this function:

◆ loadAnswerStatus()

ilTestSequenceDynamicQuestionSet::loadAnswerStatus ( )
private

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

References $query, $res, and $row.

Referenced by loadFromDb().

194  {
195  $query = "
196  SELECT question_fi, correctness
197  FROM tst_seq_qst_answstatus
198  WHERE active_fi = %s
199  AND pass = %s
200  ";
201 
202  $res = $this->db->queryF($query, array('integer','integer'), array($this->activeId, 0));
203 
204  $this->correctAnsweredQuestions = array();
205  $this->wrongAnsweredQuestions = array();
206 
207  while( $row = $this->db->fetchAssoc($res) )
208  {
209  if( $row['correctness'] )
210  {
211  $this->correctAnsweredQuestions[ $row['question_fi'] ] = $row['question_fi'];
212  }
213  else
214  {
215  $this->wrongAnsweredQuestions[ $row['question_fi'] ] = $row['question_fi'];
216  }
217  }
218  }
+ Here is the caller graph for this function:

◆ loadCheckedQuestions()

ilTestSequenceDynamicQuestionSet::loadCheckedQuestions ( )
private

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

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

Referenced by loadFromDb().

240  {
241  $res = $this->db->queryF("SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
242  array('integer','integer'), array($this->getActiveId(), 0)
243  );
244 
245  while( $row = $this->db->fetchAssoc($res) )
246  {
247  $this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
248  }
249  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromDb()

◆ loadPostponedQuestions()

ilTestSequenceDynamicQuestionSet::loadPostponedQuestions ( )
private

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

References $query, $res, and $row.

Referenced by loadFromDb().

221  {
222  $query = "
223  SELECT question_fi, cnt
224  FROM tst_seq_qst_postponed
225  WHERE active_fi = %s
226  AND pass = %s
227  ";
228 
229  $res = $this->db->queryF($query, array('integer','integer'), array($this->activeId, 0));
230 
231  $this->postponedQuestions = array();
232 
233  while( $row = $this->db->fetchAssoc($res) )
234  {
235  $this->postponedQuestions[ $row['question_fi'] ] = $row['cnt'];
236  }
237  }
+ Here is the caller graph for this function:

◆ loadQuestions()

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

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

395  {
396  $this->questionSet->load($dynamicQuestionSetConfig, $filterSelection);
397 
398 // echo "<table><tr>";
399 // echo "<td width='200'><pre>".print_r($this->questionSet->getActualQuestionSequence(), 1)."</pre></td>";
400 // echo "<td width='200'><pre>".print_r($this->correctAnsweredQuestions, 1)."</pre></td>";
401 // echo "<td width='200'><pre>".print_r($this->wrongAnsweredQuestions, 1)."</pre></td>";
402 // echo "</tr></table>";
403  }

◆ loadQuestionTracking()

ilTestSequenceDynamicQuestionSet::loadQuestionTracking ( )
private

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

References $query, $res, and $row.

Referenced by loadFromDb().

171  {
172  $query = "
173  SELECT question_fi, status
174  FROM tst_seq_qst_tracking
175  WHERE active_fi = %s
176  AND pass = %s
177  ORDER BY orderindex ASC
178  ";
179 
180  $res = $this->db->queryF($query, array('integer','integer'), array($this->activeId, 0));
181 
182  $this->questionTracking = array();
183 
184  while( $row = $this->db->fetchAssoc($res) )
185  {
186  $this->questionTracking[] = array(
187  'qid' => $row['question_fi'],
188  'status' => $row['status']
189  );
190  }
191  }
+ Here is the caller graph for this function:

◆ openQuestionExists()

ilTestSequenceDynamicQuestionSet::openQuestionExists ( )

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

References getOpenQuestions().

559  {
560  return count($this->getOpenQuestions()) > 0;
561  }
+ Here is the call graph for this function:

◆ orderQuestionsByPostponeCount()

ilTestSequenceDynamicQuestionSet::orderQuestionsByPostponeCount (   $postponedQuestions)
private

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

References $postponedQuestions.

Referenced by fetchQuestionSequence().

754  {
755  $maxPostponeCount = max($postponedQuestions);
756 
757  $orderedSequence = array();
758  $postponedCountDomain = array_flip($postponedQuestions);
759 
760  for($i = 1; $i <= $maxPostponeCount; $i++)
761  {
762  if(!isset($postponedCountDomain[$i]))
763  {
764  continue;
765  }
766 
767  foreach($postponedQuestions as $qId => $postponeCount)
768  {
769  if($postponeCount == $i)
770  {
771  $orderedSequence[] = $qId;
772  }
773  }
774  }
775 
776  return $orderedSequence;
777  }
+ Here is the caller graph for this function:

◆ removeQuestionsNotCheckedAnymore()

ilTestSequenceDynamicQuestionSet::removeQuestionsNotCheckedAnymore ( )
private

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

References $query, and getActiveId().

Referenced by saveToDb().

377  {
378  $NOT_IN_checkedQuestions = $this->db->in('question_fi', $this->alreadyCheckedQuestions, true, 'integer');
379 
380  // BEGIN: FIX IN QUERY
381  if($NOT_IN_checkedQuestions == ' 1=2 ') $NOT_IN_checkedQuestions = ' 1=1 ';
382  // END: FIX IN QUERY
383 
384  $query = "
385  DELETE FROM tst_seq_qst_checked
386  WHERE active_fi = %s
387  AND pass = %s
388  AND $NOT_IN_checkedQuestions
389  ";
390 
391  $this->db->manipulateF($query, array('integer', 'integer'), array((int)$this->getActiveId(), 0));
392  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeQuestionsNotPostponedAnymore()

ilTestSequenceDynamicQuestionSet::removeQuestionsNotPostponedAnymore ( )
private

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

References $query, and getActiveId().

Referenced by saveToDb().

351  {
352  $INquestions = $this->db->in('question_fi', array_keys($this->postponedQuestions), true, 'integer');
353 
354  $query = "
355  DELETE FROM tst_seq_qst_postponed
356  WHERE active_fi = %s
357  AND pass = %s
358  AND $INquestions
359  ";
360 
361  $this->db->manipulateF($query, array('integer','integer'), array($this->getActiveId(), 0));
362  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilteredQuestionListsCheckedStatus()

ilTestSequenceDynamicQuestionSet::resetFilteredQuestionListsCheckedStatus ( )

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

References isQuestionChecked(), and setQuestionUnchecked().

938  {
939  $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
940 
941  foreach($filteredQuestions as $filteredQuestion)
942  {
943  if( $this->isQuestionChecked($filteredQuestion['question_id']) )
944  {
945  $this->setQuestionUnchecked($filteredQuestion['question_id']);
946  }
947  }
948  }
+ Here is the call graph for this function:

◆ resetTrackedQuestionList()

ilTestSequenceDynamicQuestionSet::resetTrackedQuestionList ( )

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

554  {
555  $this->questionTracking = array();
556  }

◆ saveNewlyAnsweredQuestionsAnswerStatus()

ilTestSequenceDynamicQuestionSet::saveNewlyAnsweredQuestionsAnswerStatus ( )
private

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

References getActiveId().

Referenced by saveToDb().

317  {
318  if( (int)$this->newlyAnsweredQuestion )
319  {
320  $this->db->replace('tst_seq_qst_answstatus',
321  array(
322  'active_fi' => array('integer', (int)$this->getActiveId()),
323  'pass' => array('integer', 0),
324  'question_fi' => array('integer', (int)$this->newlyAnsweredQuestion)
325  ),
326  array(
327  'correctness' => array('integer', (int)$this->newlyAnsweredQuestionsAnswerStatus)
328  )
329  );
330  }
331  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveNewlyCheckedQuestion()

ilTestSequenceDynamicQuestionSet::saveNewlyCheckedQuestion ( )
private

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

References getActiveId().

Referenced by saveToDb().

365  {
366  if( (int)$this->newlyCheckedQuestion )
367  {
368  $this->db->replace('tst_seq_qst_checked', array(
369  'active_fi' => array('integer', (int)$this->getActiveId()),
370  'pass' => array('integer', 0),
371  'question_fi' => array('integer', (int)$this->newlyCheckedQuestion)
372  ), array());
373  }
374  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveNewlyPostponedQuestion()

ilTestSequenceDynamicQuestionSet::saveNewlyPostponedQuestion ( )
private

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

References getActiveId().

Referenced by saveToDb().

334  {
335  if( (int)$this->newlyPostponedQuestion )
336  {
337  $this->db->replace('tst_seq_qst_postponed',
338  array(
339  'active_fi' => array('integer', (int)$this->getActiveId()),
340  'pass' => array('integer', 0),
341  'question_fi' => array('integer', (int)$this->newlyPostponedQuestion)
342  ),
343  array(
344  'cnt' => array('integer', (int)$this->newlyPostponedQuestionsCount)
345  )
346  );
347  }
348  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveNewlyTrackedQuestion()

ilTestSequenceDynamicQuestionSet::saveNewlyTrackedQuestion ( )
private

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

References getActiveId(), and getNewOrderIndexForQuestionTracking().

Referenced by saveToDb().

276  {
277  if( (int)$this->newlyTrackedQuestion )
278  {
279  $newOrderIndex = $this->getNewOrderIndexForQuestionTracking();
280 
281  $this->db->replace('tst_seq_qst_tracking',
282  array(
283  'active_fi' => array('integer', (int)$this->getActiveId()),
284  'pass' => array('integer', 0),
285  'question_fi' => array('integer', (int)$this->newlyTrackedQuestion)
286  ),
287  array(
288  'status' => array('text', $this->newlyTrackedQuestionsStatus),
289  'orderindex' => array('integer', $newOrderIndex)
290  )
291  );
292  }
293  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

ilTestSequenceDynamicQuestionSet::saveToDb ( )

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

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

252  {
253  $this->db->manipulateF(
254  "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
255  array('integer','integer'), array($this->getActiveId(), 0)
256  );
257 
258  $this->db->insert('tst_sequence', array(
259  'active_fi' => array('integer', $this->getActiveId()),
260  'pass' => array('integer', 0),
261  'sequence' => array('clob', null),
262  'postponed' => array('text', null),
263  'hidden' => array('text', null),
264  'tstamp' => array('integer', time())
265  ));
266 
267  $this->saveNewlyTrackedQuestion();
271  $this->saveNewlyCheckedQuestion();
273  }
+ Here is the call graph for this function:

◆ setCurrentQuestionId()

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

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

References $currentQuestionId.

158  {
159  $this->currentQuestionId = $currentQuestionId;
160  }

◆ setPreventCheckedQuestionsFromComingUpEnabled()

ilTestSequenceDynamicQuestionSet::setPreventCheckedQuestionsFromComingUpEnabled (   $preventCheckedQuestionsFromComingUpEnabled)

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

References $preventCheckedQuestionsFromComingUpEnabled.

137  {
138  $this->preventCheckedQuestionsFromComingUpEnabled = $preventCheckedQuestionsFromComingUpEnabled;
139  }

◆ setQuestionAnsweredCorrect()

ilTestSequenceDynamicQuestionSet::setQuestionAnsweredCorrect (   $questionId)

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

References trackQuestion().

656  {
657  $this->trackQuestion($questionId, 'correct');
658 
659  $this->correctAnsweredQuestions[$questionId] = $questionId;
660 
661  if( isset($this->wrongAnsweredQuestions[$questionId]) )
662  unset($this->wrongAnsweredQuestions[$questionId]);
663 
664  $this->newlyAnsweredQuestion = $questionId;
665  $this->newlyAnsweredQuestionsAnswerStatus = true;
666  }
+ Here is the call graph for this function:

◆ setQuestionAnsweredWrong()

ilTestSequenceDynamicQuestionSet::setQuestionAnsweredWrong (   $questionId)

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

References trackQuestion().

669  {
670  $this->trackQuestion($questionId, 'wrong');
671 
672  $this->wrongAnsweredQuestions[$questionId] = $questionId;
673 
674  if( isset($this->correctAnsweredQuestions[$questionId]) )
675  unset($this->correctAnsweredQuestions[$questionId]);
676 
677  $this->newlyAnsweredQuestion = $questionId;
678  $this->newlyAnsweredQuestionsAnswerStatus = false;
679  }
+ Here is the call graph for this function:

◆ setQuestionChecked()

ilTestSequenceDynamicQuestionSet::setQuestionChecked (   $questionId)

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

624  {
625  $this->newlyCheckedQuestion = $questionId;
626  $this->alreadyCheckedQuestions[$questionId] = $questionId;
627  }

◆ setQuestionPostponed()

ilTestSequenceDynamicQuestionSet::setQuestionPostponed (   $questionId)

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

References trackQuestion().

635  {
636  $this->trackQuestion($questionId, 'postponed');
637 
638  if( !isset($this->postponedQuestions[$questionId]) )
639  {
640  $this->postponedQuestions[$questionId] = 0;
641  }
642 
643  $this->postponedQuestions[$questionId]++;
644 
645  $this->newlyPostponedQuestion = $questionId;
646  $this->newlyPostponedQuestionsCount = $this->postponedQuestions[$questionId];
647  }
+ Here is the call graph for this function:

◆ setQuestionUnchecked()

ilTestSequenceDynamicQuestionSet::setQuestionUnchecked (   $questionId)

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

Referenced by resetFilteredQuestionListsCheckedStatus().

619  {
620  unset($this->alreadyCheckedQuestions[$questionId]);
621  }
+ Here is the caller graph for this function:

◆ trackedQuestionExists()

ilTestSequenceDynamicQuestionSet::trackedQuestionExists ( )

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

Referenced by hasStarted().

529  {
530  return (bool)count($this->questionTracking);
531  }
+ Here is the caller graph for this function:

◆ trackQuestion()

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

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

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

682  {
683  $this->questionTracking[] = array(
684  'qid' => $questionId, 'status' => $answerStatus
685  );
686 
687  $this->newlyTrackedQuestion = $questionId;
688  $this->newlyTrackedQuestionsStatus = $answerStatus;
689  }
+ Here is the caller graph for this function:

◆ unsetQuestionPostponed()

ilTestSequenceDynamicQuestionSet::unsetQuestionPostponed (   $questionId)

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

650  {
651  if( isset($this->postponedQuestions[$questionId]) )
652  unset($this->postponedQuestions[$questionId]);
653  }

Field Documentation

◆ $activeId

ilTestSequenceDynamicQuestionSet::$activeId = null
private

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

Referenced by __construct(), and getActiveId().

◆ $alreadyCheckedQuestions

ilTestSequenceDynamicQuestionSet::$alreadyCheckedQuestions
private

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

◆ $correctAnsweredQuestions

ilTestSequenceDynamicQuestionSet::$correctAnsweredQuestions = array()
private

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

Referenced by getOrderedSequence().

◆ $currentQuestionId

ilTestSequenceDynamicQuestionSet::$currentQuestionId
private

◆ $db

ilTestSequenceDynamicQuestionSet::$db = null
private

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

Referenced by __construct().

◆ $newlyAnsweredQuestion

ilTestSequenceDynamicQuestionSet::$newlyAnsweredQuestion
private

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

◆ $newlyAnsweredQuestionsAnswerStatus

ilTestSequenceDynamicQuestionSet::$newlyAnsweredQuestionsAnswerStatus
private

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

◆ $newlyCheckedQuestion

ilTestSequenceDynamicQuestionSet::$newlyCheckedQuestion
private

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

◆ $newlyPostponedQuestion

ilTestSequenceDynamicQuestionSet::$newlyPostponedQuestion
private

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

◆ $newlyPostponedQuestionsCount

ilTestSequenceDynamicQuestionSet::$newlyPostponedQuestionsCount
private

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

◆ $newlyTrackedQuestion

ilTestSequenceDynamicQuestionSet::$newlyTrackedQuestion
private

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

◆ $newlyTrackedQuestionsStatus

ilTestSequenceDynamicQuestionSet::$newlyTrackedQuestionsStatus
private

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

◆ $postponedQuestions

ilTestSequenceDynamicQuestionSet::$postponedQuestions = array()
private

◆ $preventCheckedQuestionsFromComingUpEnabled

ilTestSequenceDynamicQuestionSet::$preventCheckedQuestionsFromComingUpEnabled
private

◆ $questionSet

ilTestSequenceDynamicQuestionSet::$questionSet = null
private

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

Referenced by __construct().

◆ $questionTracking

ilTestSequenceDynamicQuestionSet::$questionTracking = array()
private

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

◆ $wrongAnsweredQuestions

ilTestSequenceDynamicQuestionSet::$wrongAnsweredQuestions = array()
private

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

Referenced by getOrderedSequence().


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