127 $this->newlyTrackedQuestion = null;
128 $this->newlyTrackedQuestionsStatus = null;
130 $this->newlyPostponedQuestion = null;
131 $this->newlyPostponedQuestionsCount = null;
133 $this->newlyAnsweredQuestion = null;
134 $this->newlyAnsweredQuestionsAnswerStatus = null;
136 $this->alreadyCheckedQuestions = array();
137 $this->newlyCheckedQuestion = null;
139 $this->preventCheckedQuestionsFromComingUpEnabled =
false;
141 $this->currentQuestionId = null;
186 SELECT question_fi, status 187 FROM tst_seq_qst_tracking 190 ORDER BY orderindex ASC 193 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
195 $this->questionTracking = array();
197 while ($row = $this->db->fetchAssoc(
$res)) {
198 $this->questionTracking[] = array(
199 'qid' => $row[
'question_fi'],
200 'status' => $row[
'status']
208 SELECT question_fi, correctness 209 FROM tst_seq_qst_answstatus 214 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
216 $this->correctAnsweredQuestions = array();
217 $this->wrongAnsweredQuestions = array();
219 while ($row = $this->db->fetchAssoc(
$res)) {
220 if ($row[
'correctness']) {
221 $this->correctAnsweredQuestions[ $row[
'question_fi'] ] = $row[
'question_fi'];
223 $this->wrongAnsweredQuestions[ $row[
'question_fi'] ] = $row[
'question_fi'];
231 SELECT question_fi, cnt 232 FROM tst_seq_qst_postponed 237 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
239 $this->postponedQuestions = array();
241 while ($row = $this->db->fetchAssoc(
$res)) {
242 $this->postponedQuestions[ $row[
'question_fi'] ] = $row[
'cnt'];
248 $res = $this->db->queryF(
249 "SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
250 array(
'integer',
'integer'),
254 while ($row = $this->db->fetchAssoc(
$res)) {
255 $this->alreadyCheckedQuestions[ $row[
'question_fi'] ] = $row[
'question_fi'];
261 $this->db->manipulateF(
262 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
263 array(
'integer',
'integer'),
267 $this->db->insert(
'tst_sequence', array(
268 'active_fi' => array(
'integer', $this->
getActiveId()),
269 'pass' => array(
'integer', 0),
270 'sequence' => array(
'clob', null),
271 'postponed' => array(
'text', null),
272 'hidden' => array(
'text', null),
273 'tstamp' => array(
'integer', time())
286 if ((
int) $this->newlyTrackedQuestion) {
290 'tst_seq_qst_tracking',
292 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
293 'pass' => array(
'integer', 0),
294 'question_fi' => array(
'integer', (
int) $this->newlyTrackedQuestion)
297 'status' => array(
'text', $this->newlyTrackedQuestionsStatus),
298 'orderindex' => array(
'integer', $newOrderIndex)
307 SELECT (MAX(orderindex) + 1) new_order_index 308 FROM tst_seq_qst_tracking 315 $row = $this->db->fetchAssoc(
$res);
317 if ($row[
'new_order_index']) {
318 return $row[
'new_order_index'];
326 if ((
int) $this->newlyAnsweredQuestion) {
328 'tst_seq_qst_answstatus',
330 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
331 'pass' => array(
'integer', 0),
332 'question_fi' => array(
'integer', (
int) $this->newlyAnsweredQuestion)
335 'correctness' => array(
'integer', (
int) $this->newlyAnsweredQuestionsAnswerStatus)
343 if ((
int) $this->newlyPostponedQuestion) {
345 'tst_seq_qst_postponed',
347 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
348 'pass' => array(
'integer', 0),
349 'question_fi' => array(
'integer', (
int) $this->newlyPostponedQuestion)
352 'cnt' => array(
'integer', (
int) $this->newlyPostponedQuestionsCount)
360 $INquestions = $this->db->in(
'question_fi', array_keys($this->postponedQuestions),
true,
'integer');
363 DELETE FROM tst_seq_qst_postponed 369 $this->db->manipulateF(
$query, array(
'integer',
'integer'), array($this->
getActiveId(), 0));
374 if ((
int) $this->newlyCheckedQuestion) {
375 $this->db->replace(
'tst_seq_qst_checked', array(
376 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
377 'pass' => array(
'integer', 0),
378 'question_fi' => array(
'integer', (
int) $this->newlyCheckedQuestion)
385 $NOT_IN_checkedQuestions = $this->db->in(
'question_fi', $this->alreadyCheckedQuestions,
true,
'integer');
388 if ($NOT_IN_checkedQuestions ==
' 1=2 ') {
389 $NOT_IN_checkedQuestions =
' 1=1 ';
394 DELETE FROM tst_seq_qst_checked 397 AND $NOT_IN_checkedQuestions 400 $this->db->manipulateF(
$query, array(
'integer',
'integer'), array((
int) $this->
getActiveId(), 0));
405 $this->questionSet->load($dynamicQuestionSetConfig, $filterSelection);
425 foreach ($this->postponedQuestions as $questionId) {
426 if (!$this->questionSet->questionExists($questionId)) {
427 unset($this->postponedQuestions[$questionId]);
431 foreach ($this->wrongAnsweredQuestions as $questionId) {
432 if (!$this->questionSet->questionExists($questionId)) {
433 unset($this->wrongAnsweredQuestions[$questionId]);
437 foreach ($this->correctAnsweredQuestions as $questionId) {
438 if (!$this->questionSet->questionExists($questionId)) {
439 unset($this->correctAnsweredQuestions[$questionId]);
469 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
472 foreach ($questions as $pos => $qId) {
473 if (isset($this->correctAnsweredQuestions[$qId])) {
481 if ($forceNonAnsweredQuestion && isset($this->wrongAnsweredQuestions[$qId])) {
485 if (isset($this->postponedQuestions[$qId])) {
504 isset($this->correctAnsweredQuestions[$questionId])
505 || isset($this->wrongAnsweredQuestions[$questionId])
511 return isset($this->postponedQuestions[$questionId]);
516 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
517 if (in_array($questionId, $questions)) {
527 return (
bool) count($this->questionTracking);
532 $questionList = array();
538 foreach (array_reverse($this->questionTracking) as $trackedQuestion) {
539 if (!isset($questionList[ $trackedQuestion[
'qid'] ])) {
540 $questionList[ $trackedQuestion[
'qid'] ] = $this->questionSet->getQuestionData($trackedQuestion[
'qid']);
544 return $questionList;
549 $this->questionTracking = array();
559 $completeQuestionIds = array_keys($this->questionSet->getAllQuestionsData());
561 $openQuestions = array_diff($completeQuestionIds, $this->correctAnsweredQuestions);
563 return $openQuestions;
568 $uniqueQuestions = array();
570 foreach ($this->questionTracking as $trackedQuestion) {
571 $uniqueQuestions[$trackedQuestion[
'qid']] = $trackedQuestion[
'qid'];
574 return count($uniqueQuestions);
584 if ($qId == $questionId) {
601 unset($this->alreadyCheckedQuestions[$questionId]);
606 $this->newlyCheckedQuestion = $questionId;
607 $this->alreadyCheckedQuestions[$questionId] = $questionId;
612 return isset($this->alreadyCheckedQuestions[$questionId]);
619 if (!isset($this->postponedQuestions[$questionId])) {
620 $this->postponedQuestions[$questionId] = 0;
623 $this->postponedQuestions[$questionId]++;
625 $this->newlyPostponedQuestion = $questionId;
626 $this->newlyPostponedQuestionsCount = $this->postponedQuestions[$questionId];
631 if (isset($this->postponedQuestions[$questionId])) {
632 unset($this->postponedQuestions[$questionId]);
640 $this->correctAnsweredQuestions[$questionId] = $questionId;
642 if (isset($this->wrongAnsweredQuestions[$questionId])) {
643 unset($this->wrongAnsweredQuestions[$questionId]);
646 $this->newlyAnsweredQuestion = $questionId;
647 $this->newlyAnsweredQuestionsAnswerStatus =
true;
654 $this->wrongAnsweredQuestions[$questionId] = $questionId;
656 if (isset($this->correctAnsweredQuestions[$questionId])) {
657 unset($this->correctAnsweredQuestions[$questionId]);
660 $this->newlyAnsweredQuestion = $questionId;
661 $this->newlyAnsweredQuestionsAnswerStatus =
false;
666 $this->questionTracking[] = array(
667 'qid' => $questionId,
'status' => $answerStatus
670 $this->newlyTrackedQuestion = $questionId;
671 $this->newlyTrackedQuestionsStatus = $answerStatus;
693 return $this->questionSet->getCompleteQuestionList()->getQuestionDataArray();
698 return $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
707 $questionSequence = array();
709 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
710 $questionSequence = array_merge($questionSequence, $questions);
713 return $questionSequence;
722 $minPostponeCount = null;
723 $minPostponeItem = null;
726 if ($minPostponeCount === null || $postponeCount <= $minPostponeCount) {
727 $minPostponeCount = $postponeCount;
728 $minPostponeItem = $qId;
731 return $minPostponeItem;
745 $orderedSequence = array();
748 for (
$i = 1;
$i <= $maxPostponeCount;
$i++) {
749 if (!isset($postponedCountDomain[
$i])) {
754 if ($postponeCount == $i) {
755 $orderedSequence[] = $qId;
760 return $orderedSequence;
765 $questionSequence = array();
767 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
770 foreach ($questions as $pos => $qId) {
771 if (isset($this->correctAnsweredQuestions[$qId])) {
775 if ($nonAnsweredQuestions && isset($this->wrongAnsweredQuestions[$qId])) {
777 } elseif (!$nonAnsweredQuestions && !isset($this->wrongAnsweredQuestions[$qId])) {
781 if (!$nonPostponedQuestions && isset($this->postponedQuestions[$qId])) {
784 } elseif ($nonPostponedQuestions && !isset($this->postponedQuestions[$qId])) {
785 $questionSequence[] = $qId;
790 $questionSequence = array_merge(
797 return $questionSequence;
802 $questionSequence = array();
804 foreach ($this->questionTracking as
$key => $question) {
805 $qId = $question[
'qid'];
807 if (!isset($this->correctAnsweredQuestions[$qId])) {
811 $questionSequence[] = $qId;
814 return $questionSequence;
841 $questionOrder = array_merge(
843 $nonAnsweredQuestions,
844 $postponedNonAnsweredQuestions,
846 $postponedWrongAnsweredQuestions
849 return $questionOrder;
857 if (!$this->
getQuestionSet()->getSelectionQuestionList()->isInList($qId)) {
877 foreach ($questionOrder as $qId) {
879 if (is_object($question)) {
880 $worked_through = $question->_isWorkedThrough($this->
getActiveId(), $question->getId(), $this->
getPass());
882 if (array_key_exists($question->getId(), $solved_questions)) {
883 $solved = $solved_questions[$question->getId()][
"solved"];
889 $row = array(
"nr" =>
"$key",
"title" => $question->getTitle(),
"qid" => $question->getId(),
"visited" => $worked_through,
"solved" => (($solved) ?
"1" :
"0"),
"description" => $question->getComment(),
"points" => $question->getMaximumPoints(),
"worked_through" => $worked_through,
"postponed" =>
false,
"sequence" => $qId,
"obligatory" =>
ilObjTest::isQuestionObligatory($question->getId()),
'isAnswered' => $question->isAnswered($this->getActiveId(), $this->
getPass()));
891 if (!$obligationsFilterEnabled || $row[
'obligatory']) {
904 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
906 foreach ($filteredQuestions as $filteredQuestion) {
917 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
919 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()
getUserSequenceQuestions()
getTrackedQuestionList($currentQuestionId=null)
setPreventCheckedQuestionsFromComingUpEnabled($preventCheckedQuestionsFromComingUpEnabled)
cleanupQuestions(ilTestSessionDynamicQuestionSet $testSession)
isPreventCheckedQuestionsFromComingUpEnabled()
loadQuestions(ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
resetTrackedQuestionList()
removeQuestionsNotCheckedAnymore()
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
setQuestionAnsweredCorrect($questionId)
$newlyPostponedQuestionsCount
setCurrentQuestionId($currentQuestionId)
setQuestionPostponed($questionId)
getSelectionOrderedSequence()
__construct(ilDBInterface $db, ilTestDynamicQuestionSet $questionSet, $activeId)
Constructor.
isAnsweredQuestion($questionId)
setCurrentQuestionId($currentQuestionId)
getCompleteQuestionsData()
saveNewlyPostponedQuestion()
fetchQuestionSequence($nonPostponedQuestions, $nonAnsweredQuestions)
$newlyAnsweredQuestionsAnswerStatus
fetchTrackedCorrectAnsweredSequence()
getFilteredQuestionsData()
hasFilteredQuestionListCheckedQuestions()
$newlyTrackedQuestionsStatus
unsetQuestionPostponed($questionId)
$preventCheckedQuestionsFromComingUpEnabled
$correctAnsweredQuestions
fetchMostLeastPostponedQuestion($postponedQuestions)
getCurrentPositionIndex($questionId)
fetchUpcomingQuestionId($excludePostponedQuestions, $forceNonAnsweredQuestion)
isQuestionChecked($questionId)
getNewOrderIndexForQuestionTracking()