ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 

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 16 of file class.ilTestSequenceDynamicQuestionSet.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
ilTestDynamicQuestionSet$questionSet

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

References $activeId, $db, $questionSet, and array.

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  }
Create styles array
The data for the language used.

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 728 of file class.ilTestSequenceDynamicQuestionSet.php.

References $postponedQuestions.

Referenced by fetchUpcomingQuestionId().

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

◆ fetchQuestionSequence()

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

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

References $postponedQuestions, array, and orderQuestionsByPostponeCount().

Referenced by getOrderedSequence().

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

◆ fetchTrackedCorrectAnsweredSequence()

ilTestSequenceDynamicQuestionSet::fetchTrackedCorrectAnsweredSequence ( )
private

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

References array.

Referenced by getOrderedSequence().

824  {
825  $questionSequence = array();
826 
827  foreach($this->questionTracking as $key => $question)
828  {
829  $qId = $question['qid'];
830 
831  if( !isset($this->correctAnsweredQuestions[$qId]) )
832  {
833  continue;
834  }
835 
836  $questionSequence[] = $qId;
837  }
838 
839  return $questionSequence;
840  }
Create styles array
The data for the language used.
+ 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, array, fetchMostLeastPostponedQuestion(), isPreventCheckedQuestionsFromComingUpEnabled(), and isQuestionChecked().

Referenced by getUpcomingQuestionId().

462  {
463  foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
464  {
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  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

◆ getCompleteQuestionsData()

ilTestSequenceDynamicQuestionSet::getCompleteQuestionsData ( )

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

699  {
700  return $this->questionSet->getCompleteQuestionList()->getQuestionDataArray();
701  }

◆ getCurrentPositionIndex()

ilTestSequenceDynamicQuestionSet::getCurrentPositionIndex (   $questionId)

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

References getSelectionOrderedSequence().

585  {
586  $i = 0;
587 
588  foreach($this->getSelectionOrderedSequence() as $qId)
589  {
590  $i++;
591 
592  if($qId == $questionId)
593  {
594  return $i;
595  }
596  }
597 
598  return null;
599  }
+ Here is the call graph for this function:

◆ getCurrentQuestionId()

ilTestSequenceDynamicQuestionSet::getCurrentQuestionId ( )

◆ getFilteredQuestionsData()

ilTestSequenceDynamicQuestionSet::getFilteredQuestionsData ( )

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

704  {
705  return $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
706  }

◆ getLastPositionIndex()

ilTestSequenceDynamicQuestionSet::getLastPositionIndex ( )

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

References getSelectionOrderedSequence().

602  {
603  return count($this->getSelectionOrderedSequence());
604  }
+ Here is the call graph for this function:

◆ getNewOrderIndexForQuestionTracking()

ilTestSequenceDynamicQuestionSet::getNewOrderIndexForQuestionTracking ( )
private

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

References $query, $res, $row, array, 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  }
Create styles array
The data for the language used.
+ 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 842 of file class.ilTestSequenceDynamicQuestionSet.php.

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

Referenced by getSelectionOrderedSequence().

843  {
845 
846  $nonAnsweredQuestions = $this->fetchQuestionSequence(
847  true, true
848  );
849 
850  $postponedNonAnsweredQuestions = $this->fetchQuestionSequence(
851  false, true
852  );
853 
855  true, false
856  );
857 
858  $postponedWrongAnsweredQuestions = $this->fetchQuestionSequence(
859  false, false
860  );
861 
862  $questionOrder = array_merge( $correctAnsweredQuestions,
863  $nonAnsweredQuestions, $postponedNonAnsweredQuestions,
864  $wrongAnsweredQuestions, $postponedWrongAnsweredQuestions
865  );
866 
867  return $questionOrder;
868  }
fetchQuestionSequence($nonPostponedQuestions, $nonAnsweredQuestions)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPass()

ilTestSequenceDynamicQuestionSet::getPass ( )

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

Referenced by getSequenceSummary().

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

◆ getQuestionSet()

ilTestSequenceDynamicQuestionSet::getQuestionSet ( )
Returns
ilTestDynamicQuestionSet

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

References $questionSet.

Referenced by getSelectionOrderedSequence().

+ Here is the caller graph for this function:

◆ getSelectionOrderedSequence()

ilTestSequenceDynamicQuestionSet::getSelectionOrderedSequence ( )

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

References array, getOrderedSequence(), and getQuestionSet().

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

871  {
872  $sequence = array();
873 
874  foreach($this->getOrderedSequence() as $qId)
875  {
876  if( !$this->getQuestionSet()->getSelectionQuestionList()->isInList($qId) )
877  {
878  continue;
879  }
880 
881  $sequence[] = $qId;
882  }
883 
884  return $sequence;
885  }
Create styles array
The data for the language used.
+ 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 887 of file class.ilTestSequenceDynamicQuestionSet.php.

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

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

◆ getTrackedQuestionCount()

ilTestSequenceDynamicQuestionSet::getTrackedQuestionCount ( )

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

References array.

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  }
Create styles array
The data for the language used.

◆ getTrackedQuestionList()

ilTestSequenceDynamicQuestionSet::getTrackedQuestionList (   $currentQuestionId = null)

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

References $currentQuestionId, and array.

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  }
Create styles array
The data for the language used.

◆ 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 710 of file class.ilTestSequenceDynamicQuestionSet.php.

References array.

711  {
712  //return array_keys( $this->getTrackedQuestionList() );
713 
714  $questionSequence = array();
715 
716  foreach( $this->questionSet->getActualQuestionSequence() as $level => $questions )
717  {
718  $questionSequence = array_merge($questionSequence, $questions);
719  }
720 
721  return $questionSequence;
722  }
Create styles array
The data for the language used.

◆ hasFilteredQuestionListCheckedQuestions()

ilTestSequenceDynamicQuestionSet::hasFilteredQuestionListCheckedQuestions ( )

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

References isQuestionChecked().

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

◆ hasStarted()

ilTestSequenceDynamicQuestionSet::hasStarted ( )

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

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

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

◆ loadAnswerStatus()

ilTestSequenceDynamicQuestionSet::loadAnswerStatus ( )
private

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

References $query, $res, $row, and array.

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  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ loadCheckedQuestions()

ilTestSequenceDynamicQuestionSet::loadCheckedQuestions ( )
private

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

References $res, $row, array, 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  }
Create styles array
The data for the language used.
+ 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, $row, and array.

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  }
Create styles array
The data for the language used.
+ 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, $row, and array.

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  }
Create styles array
The data for the language used.
+ 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 751 of file class.ilTestSequenceDynamicQuestionSet.php.

References $postponedQuestions, and array.

Referenced by fetchQuestionSequence().

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

◆ removeQuestionsNotCheckedAnymore()

ilTestSequenceDynamicQuestionSet::removeQuestionsNotCheckedAnymore ( )
private

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

References $query, array, 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  }
Create styles array
The data for the language used.
+ 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, array, 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  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilteredQuestionListsCheckedStatus()

ilTestSequenceDynamicQuestionSet::resetFilteredQuestionListsCheckedStatus ( )

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

References isQuestionChecked(), and setQuestionUnchecked().

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

◆ resetTrackedQuestionList()

ilTestSequenceDynamicQuestionSet::resetTrackedQuestionList ( )

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

References array.

554  {
555  $this->questionTracking = array();
556  }
Create styles array
The data for the language used.

◆ saveNewlyAnsweredQuestionsAnswerStatus()

ilTestSequenceDynamicQuestionSet::saveNewlyAnsweredQuestionsAnswerStatus ( )
private

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

References array, and 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  }
Create styles array
The data for the language used.
+ 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 array, and 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  }
Create styles array
The data for the language used.
+ 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 array, and 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  }
Create styles array
The data for the language used.
+ 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 array, 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  }
Create styles array
The data for the language used.
+ 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 array, getActiveId(), removeQuestionsNotCheckedAnymore(), removeQuestionsNotPostponedAnymore(), saveNewlyAnsweredQuestionsAnswerStatus(), saveNewlyCheckedQuestion(), saveNewlyPostponedQuestion(), saveNewlyTrackedQuestion(), and time.

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  }
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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 645 of file class.ilTestSequenceDynamicQuestionSet.php.

References trackQuestion().

646  {
647  $this->trackQuestion($questionId, 'correct');
648 
649  $this->correctAnsweredQuestions[$questionId] = $questionId;
650 
651  if( isset($this->wrongAnsweredQuestions[$questionId]) )
652  unset($this->wrongAnsweredQuestions[$questionId]);
653 
654  $this->newlyAnsweredQuestion = $questionId;
655  $this->newlyAnsweredQuestionsAnswerStatus = true;
656  }
+ Here is the call graph for this function:

◆ setQuestionAnsweredWrong()

ilTestSequenceDynamicQuestionSet::setQuestionAnsweredWrong (   $questionId)

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

References trackQuestion().

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

◆ setQuestionChecked()

ilTestSequenceDynamicQuestionSet::setQuestionChecked (   $questionId)

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

614  {
615  $this->newlyCheckedQuestion = $questionId;
616  $this->alreadyCheckedQuestions[$questionId] = $questionId;
617  }

◆ setQuestionPostponed()

ilTestSequenceDynamicQuestionSet::setQuestionPostponed (   $questionId)

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

References trackQuestion().

625  {
626  $this->trackQuestion($questionId, 'postponed');
627 
628  if( !isset($this->postponedQuestions[$questionId]) )
629  {
630  $this->postponedQuestions[$questionId] = 0;
631  }
632 
633  $this->postponedQuestions[$questionId]++;
634 
635  $this->newlyPostponedQuestion = $questionId;
636  $this->newlyPostponedQuestionsCount = $this->postponedQuestions[$questionId];
637  }
+ Here is the call graph for this function:

◆ setQuestionUnchecked()

ilTestSequenceDynamicQuestionSet::setQuestionUnchecked (   $questionId)

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

Referenced by resetFilteredQuestionListsCheckedStatus().

609  {
610  unset($this->alreadyCheckedQuestions[$questionId]);
611  }
+ 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 671 of file class.ilTestSequenceDynamicQuestionSet.php.

References array.

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

672  {
673  $this->questionTracking[] = array(
674  'qid' => $questionId, 'status' => $answerStatus
675  );
676 
677  $this->newlyTrackedQuestion = $questionId;
678  $this->newlyTrackedQuestionsStatus = $answerStatus;
679  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ unsetQuestionPostponed()

ilTestSequenceDynamicQuestionSet::unsetQuestionPostponed (   $questionId)

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

640  {
641  if( isset($this->postponedQuestions[$questionId]) )
642  unset($this->postponedQuestions[$questionId]);
643  }

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(), and getQuestionSet().

◆ $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: