4 require_once
'Modules/Test/interfaces/interface.ilTestSequenceSummaryProvider.php';
114 $this->newlyTrackedQuestion = null;
115 $this->newlyTrackedQuestionsStatus = null;
117 $this->newlyPostponedQuestion = null;
118 $this->newlyPostponedQuestionsCount = null;
120 $this->newlyAnsweredQuestion = null;
121 $this->newlyAnsweredQuestionsAnswerStatus = null;
123 $this->alreadyCheckedQuestions = array();
124 $this->newlyCheckedQuestion = null;
126 $this->preventCheckedQuestionsFromComingUpEnabled =
false;
128 $this->currentQuestionId = null;
173 SELECT question_fi, status 174 FROM tst_seq_qst_tracking 177 ORDER BY orderindex ASC 180 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
182 $this->questionTracking = array();
184 while(
$row = $this->db->fetchAssoc(
$res) )
186 $this->questionTracking[] = array(
187 'qid' =>
$row[
'question_fi'],
188 'status' =>
$row[
'status']
196 SELECT question_fi, correctness 197 FROM tst_seq_qst_answstatus 202 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
204 $this->correctAnsweredQuestions = array();
205 $this->wrongAnsweredQuestions = array();
207 while(
$row = $this->db->fetchAssoc(
$res) )
209 if(
$row[
'correctness'] )
211 $this->correctAnsweredQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
215 $this->wrongAnsweredQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
223 SELECT question_fi, cnt 224 FROM tst_seq_qst_postponed 229 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
231 $this->postponedQuestions = array();
233 while(
$row = $this->db->fetchAssoc(
$res) )
235 $this->postponedQuestions[
$row[
'question_fi'] ] = $row[
'cnt'];
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)
245 while(
$row = $this->db->fetchAssoc(
$res) )
247 $this->alreadyCheckedQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
253 $this->db->manipulateF(
254 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
255 array(
'integer',
'integer'), array($this->
getActiveId(), 0)
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())
277 if( (
int)$this->newlyTrackedQuestion )
281 $this->db->replace(
'tst_seq_qst_tracking',
283 'active_fi' => array(
'integer', (
int)$this->
getActiveId()),
284 'pass' => array(
'integer', 0),
285 'question_fi' => array(
'integer', (
int)$this->newlyTrackedQuestion)
288 'status' => array(
'text', $this->newlyTrackedQuestionsStatus),
289 'orderindex' => array(
'integer', $newOrderIndex)
298 SELECT (MAX(orderindex) + 1) new_order_index 299 FROM tst_seq_qst_tracking 308 if(
$row[
'new_order_index'] )
310 return $row[
'new_order_index'];
318 if( (
int)$this->newlyAnsweredQuestion )
320 $this->db->replace(
'tst_seq_qst_answstatus',
322 'active_fi' => array(
'integer', (
int)$this->
getActiveId()),
323 'pass' => array(
'integer', 0),
324 'question_fi' => array(
'integer', (
int)$this->newlyAnsweredQuestion)
327 'correctness' => array(
'integer', (
int)$this->newlyAnsweredQuestionsAnswerStatus)
335 if( (
int)$this->newlyPostponedQuestion )
337 $this->db->replace(
'tst_seq_qst_postponed',
339 'active_fi' => array(
'integer', (
int)$this->
getActiveId()),
340 'pass' => array(
'integer', 0),
341 'question_fi' => array(
'integer', (
int)$this->newlyPostponedQuestion)
344 'cnt' => array(
'integer', (
int)$this->newlyPostponedQuestionsCount)
352 $INquestions = $this->db->in(
'question_fi', array_keys($this->postponedQuestions),
true,
'integer');
355 DELETE FROM tst_seq_qst_postponed 361 $this->db->manipulateF(
$query, array(
'integer',
'integer'), array($this->
getActiveId(), 0));
366 if( (
int)$this->newlyCheckedQuestion )
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)
378 $NOT_IN_checkedQuestions = $this->db->in(
'question_fi', $this->alreadyCheckedQuestions,
true,
'integer');
381 if($NOT_IN_checkedQuestions ==
' 1=2 ') $NOT_IN_checkedQuestions =
' 1=1 ';
385 DELETE FROM tst_seq_qst_checked 388 AND $NOT_IN_checkedQuestions 391 $this->db->manipulateF(
$query, array(
'integer',
'integer'), array((
int)$this->
getActiveId(), 0));
396 $this->questionSet->load($dynamicQuestionSetConfig, $filterSelection);
417 foreach($this->postponedQuestions as $questionId)
419 if( !$this->questionSet->questionExists($questionId) )
421 unset($this->postponedQuestions[$questionId]);
425 foreach($this->wrongAnsweredQuestions as $questionId)
427 if( !$this->questionSet->questionExists($questionId) )
429 unset($this->wrongAnsweredQuestions[$questionId]);
433 foreach($this->correctAnsweredQuestions as $questionId)
435 if( !$this->questionSet->questionExists($questionId) )
437 unset($this->correctAnsweredQuestions[$questionId]);
463 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
467 foreach($questions as $pos => $qId)
469 if( isset($this->correctAnsweredQuestions[$qId]) )
479 if( $forceNonAnsweredQuestion && isset($this->wrongAnsweredQuestions[$qId]) )
484 if( isset($this->postponedQuestions[$qId]) )
505 isset($this->correctAnsweredQuestions[$questionId])
506 || isset($this->wrongAnsweredQuestions[$questionId])
512 return isset($this->postponedQuestions[$questionId]);
517 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
519 if( in_array($questionId, $questions) )
530 return (
bool)count($this->questionTracking);
535 $questionList = array();
542 foreach( array_reverse($this->questionTracking) as $trackedQuestion)
544 if( !isset($questionList[ $trackedQuestion[
'qid'] ]) )
546 $questionList[ $trackedQuestion[
'qid'] ] = $this->questionSet->getQuestionData($trackedQuestion[
'qid']);
550 return $questionList;
555 $this->questionTracking = array();
565 $completeQuestionIds = array_keys( $this->questionSet->getAllQuestionsData() );
567 $openQuestions = array_diff($completeQuestionIds, $this->correctAnsweredQuestions);
569 return $openQuestions;
574 $uniqueQuestions = array();
576 foreach($this->questionTracking as $trackedQuestion)
578 $uniqueQuestions[$trackedQuestion[
'qid']] = $trackedQuestion[
'qid'];
581 return count($uniqueQuestions);
588 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
590 foreach($questions as $pos => $qId)
594 if($qId == $questionId)
608 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
610 $count += count($questions);
620 unset($this->alreadyCheckedQuestions[$questionId]);
625 $this->newlyCheckedQuestion = $questionId;
626 $this->alreadyCheckedQuestions[$questionId] = $questionId;
631 return isset($this->alreadyCheckedQuestions[$questionId]);
638 if( !isset($this->postponedQuestions[$questionId]) )
640 $this->postponedQuestions[$questionId] = 0;
643 $this->postponedQuestions[$questionId]++;
645 $this->newlyPostponedQuestion = $questionId;
646 $this->newlyPostponedQuestionsCount = $this->postponedQuestions[$questionId];
651 if( isset($this->postponedQuestions[$questionId]) )
652 unset($this->postponedQuestions[$questionId]);
659 $this->correctAnsweredQuestions[$questionId] = $questionId;
661 if( isset($this->wrongAnsweredQuestions[$questionId]) )
662 unset($this->wrongAnsweredQuestions[$questionId]);
664 $this->newlyAnsweredQuestion = $questionId;
665 $this->newlyAnsweredQuestionsAnswerStatus =
true;
672 $this->wrongAnsweredQuestions[$questionId] = $questionId;
674 if( isset($this->correctAnsweredQuestions[$questionId]) )
675 unset($this->correctAnsweredQuestions[$questionId]);
677 $this->newlyAnsweredQuestion = $questionId;
678 $this->newlyAnsweredQuestionsAnswerStatus =
false;
683 $this->questionTracking[] = array(
684 'qid' => $questionId,
'status' => $answerStatus
687 $this->newlyTrackedQuestion = $questionId;
688 $this->newlyTrackedQuestionsStatus = $answerStatus;
702 return $this->questionSet->getCompleteQuestionList()->getQuestionDataArray();
707 return $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
716 $questionSequence = array();
718 foreach( $this->questionSet->getActualQuestionSequence() as $level => $questions )
720 $questionSequence = array_merge($questionSequence, $questions);
723 return $questionSequence;
732 $minPostponeCount = null;
733 $minPostponeItem = null;
737 if($minPostponeCount === null || $postponeCount <= $minPostponeCount)
739 $minPostponeCount = $postponeCount;
740 $minPostponeItem = $qId;
743 return $minPostponeItem;
757 $orderedSequence = array();
760 for($i = 1; $i <= $maxPostponeCount; $i++)
762 if(!isset($postponedCountDomain[$i]))
769 if($postponeCount == $i)
771 $orderedSequence[] = $qId;
776 return $orderedSequence;
781 $questionSequence = array();
783 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
787 foreach($questions as $pos => $qId)
789 if( $qId == $excludeQuestionId )
794 if( isset($this->correctAnsweredQuestions[$qId]) )
799 if( $nonAnsweredQuestions && isset($this->wrongAnsweredQuestions[$qId]) )
803 elseif( !$nonAnsweredQuestions && !isset($this->wrongAnsweredQuestions[$qId]) )
808 if( !$nonPostponedQuestions && isset($this->postponedQuestions[$qId]) )
813 elseif($nonPostponedQuestions && !isset($this->postponedQuestions[$qId]))
815 $questionSequence[] = $qId;
821 $questionSequence = array_merge(
827 return $questionSequence;
832 $questionSequence = array();
834 foreach($this->questionTracking as $key => $question)
836 $qId = $question[
'qid'];
838 if($qId == $excludeQuestionId)
843 if( !isset($this->correctAnsweredQuestions[$qId]) )
848 $questionSequence[] = $qId;
851 return $questionSequence;
876 $questionOrder = array_merge(
878 $nonAnsweredQuestions, $postponedNonAnsweredQuestions,
882 return $questionOrder;
893 foreach ($questionOrder as $qId)
896 if(is_object($question))
898 $worked_through = $question->_isWorkedThrough($this->
getActiveId(), $question->getId(), $this->
getPass());
900 if(array_key_exists($question->getId(), $solved_questions))
902 $solved = $solved_questions[$question->getId()][
"solved"];
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()));
910 if(!$obligationsFilterEnabled ||
$row[
'obligatory'])
924 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
926 foreach($filteredQuestions as $filteredQuestion)
939 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
941 foreach($filteredQuestions as $filteredQuestion)
saveNewlyTrackedQuestion()
saveNewlyAnsweredQuestionsAnswerStatus()
getTrackedQuestionCount()
trackQuestion($questionId, $answerStatus)
setQuestionUnchecked($questionId)
orderQuestionsByPostponeCount($postponedQuestions)
isFilteredQuestion($questionId)
removeQuestionsNotPostponedAnymore()
resetFilteredQuestionListsCheckedStatus()
setQuestionAnsweredWrong($questionId)
getSequenceSummary($obligationsFilterEnabled=false)
isPostponedQuestion($questionId)
setQuestionChecked($questionId)
saveNewlyCheckedQuestion()
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
getUserSequenceQuestions()
getTrackedQuestionList($currentQuestionId=null)
_getSolvedQuestions($active_id, $question_fi=null)
get solved questions
setPreventCheckedQuestionsFromComingUpEnabled($preventCheckedQuestionsFromComingUpEnabled)
cleanupQuestions(ilTestSessionDynamicQuestionSet $testSession)
isPreventCheckedQuestionsFromComingUpEnabled()
loadQuestions(ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
static isQuestionObligatory($question_id)
checks wether the question with given id is marked as obligatory or not
resetTrackedQuestionList()
removeQuestionsNotCheckedAnymore()
setQuestionAnsweredCorrect($questionId)
$newlyPostponedQuestionsCount
setCurrentQuestionId($currentQuestionId)
setQuestionPostponed($questionId)
isAnsweredQuestion($questionId)
setCurrentQuestionId($currentQuestionId)
fetchTrackedCorrectAnsweredSequence($excludeQuestionId)
getCompleteQuestionsData()
saveNewlyPostponedQuestion()
__construct(ilDB $db, ilTestDynamicQuestionSet $questionSet, $activeId)
Constructor.
$newlyAnsweredQuestionsAnswerStatus
getFilteredQuestionsData()
hasFilteredQuestionListCheckedQuestions()
$newlyTrackedQuestionsStatus
unsetQuestionPostponed($questionId)
$preventCheckedQuestionsFromComingUpEnabled
$correctAnsweredQuestions
fetchMostLeastPostponedQuestion($postponedQuestions)
getCurrentPositionIndex($questionId)
fetchUpcomingQuestionId($excludePostponedQuestions, $forceNonAnsweredQuestion)
isQuestionChecked($questionId)
getNewOrderIndexForQuestionTracking()
fetchQuestionSequence($nonPostponedQuestions, $nonAnsweredQuestions, $excludeQuestionId)