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)) {
185 $this->questionTracking[] = array(
186 'qid' =>
$row[
'question_fi'],
187 'status' =>
$row[
'status']
195 SELECT question_fi, correctness 196 FROM tst_seq_qst_answstatus 201 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
203 $this->correctAnsweredQuestions = array();
204 $this->wrongAnsweredQuestions = array();
206 while (
$row = $this->db->fetchAssoc(
$res)) {
207 if (
$row[
'correctness']) {
208 $this->correctAnsweredQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
210 $this->wrongAnsweredQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
218 SELECT question_fi, cnt 219 FROM tst_seq_qst_postponed 224 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
226 $this->postponedQuestions = array();
228 while (
$row = $this->db->fetchAssoc(
$res)) {
229 $this->postponedQuestions[
$row[
'question_fi'] ] = $row[
'cnt'];
235 $res = $this->db->queryF(
236 "SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
237 array(
'integer',
'integer'),
241 while (
$row = $this->db->fetchAssoc(
$res)) {
242 $this->alreadyCheckedQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
248 $this->db->manipulateF(
249 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
250 array(
'integer',
'integer'),
254 $this->db->insert(
'tst_sequence', array(
255 'active_fi' => array(
'integer', $this->
getActiveId()),
256 'pass' => array(
'integer', 0),
257 'sequence' => array(
'clob', null),
258 'postponed' => array(
'text', null),
259 'hidden' => array(
'text', null),
260 'tstamp' => array(
'integer', time())
273 if ((
int) $this->newlyTrackedQuestion) {
277 'tst_seq_qst_tracking',
279 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
280 'pass' => array(
'integer', 0),
281 'question_fi' => array(
'integer', (
int) $this->newlyTrackedQuestion)
284 'status' => array(
'text', $this->newlyTrackedQuestionsStatus),
285 'orderindex' => array(
'integer', $newOrderIndex)
294 SELECT (MAX(orderindex) + 1) new_order_index 295 FROM tst_seq_qst_tracking 304 if (
$row[
'new_order_index']) {
305 return $row[
'new_order_index'];
313 if ((
int) $this->newlyAnsweredQuestion) {
315 'tst_seq_qst_answstatus',
317 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
318 'pass' => array(
'integer', 0),
319 'question_fi' => array(
'integer', (
int) $this->newlyAnsweredQuestion)
322 'correctness' => array(
'integer', (
int) $this->newlyAnsweredQuestionsAnswerStatus)
330 if ((
int) $this->newlyPostponedQuestion) {
332 'tst_seq_qst_postponed',
334 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
335 'pass' => array(
'integer', 0),
336 'question_fi' => array(
'integer', (
int) $this->newlyPostponedQuestion)
339 'cnt' => array(
'integer', (
int) $this->newlyPostponedQuestionsCount)
347 $INquestions = $this->db->in(
'question_fi', array_keys($this->postponedQuestions),
true,
'integer');
350 DELETE FROM tst_seq_qst_postponed 356 $this->db->manipulateF(
$query, array(
'integer',
'integer'), array($this->
getActiveId(), 0));
361 if ((
int) $this->newlyCheckedQuestion) {
362 $this->db->replace(
'tst_seq_qst_checked', array(
363 'active_fi' => array(
'integer', (
int) $this->
getActiveId()),
364 'pass' => array(
'integer', 0),
365 'question_fi' => array(
'integer', (
int) $this->newlyCheckedQuestion)
372 $NOT_IN_checkedQuestions = $this->db->in(
'question_fi', $this->alreadyCheckedQuestions,
true,
'integer');
375 if ($NOT_IN_checkedQuestions ==
' 1=2 ') {
376 $NOT_IN_checkedQuestions =
' 1=1 ';
381 DELETE FROM tst_seq_qst_checked 384 AND $NOT_IN_checkedQuestions 387 $this->db->manipulateF(
$query, array(
'integer',
'integer'), array((
int) $this->
getActiveId(), 0));
392 $this->questionSet->load($dynamicQuestionSetConfig, $filterSelection);
412 foreach ($this->postponedQuestions as $questionId) {
413 if (!$this->questionSet->questionExists($questionId)) {
414 unset($this->postponedQuestions[$questionId]);
418 foreach ($this->wrongAnsweredQuestions as $questionId) {
419 if (!$this->questionSet->questionExists($questionId)) {
420 unset($this->wrongAnsweredQuestions[$questionId]);
424 foreach ($this->correctAnsweredQuestions as $questionId) {
425 if (!$this->questionSet->questionExists($questionId)) {
426 unset($this->correctAnsweredQuestions[$questionId]);
456 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
459 foreach ($questions as $pos => $qId) {
460 if (isset($this->correctAnsweredQuestions[$qId])) {
468 if ($forceNonAnsweredQuestion && isset($this->wrongAnsweredQuestions[$qId])) {
472 if (isset($this->postponedQuestions[$qId])) {
491 isset($this->correctAnsweredQuestions[$questionId])
492 || isset($this->wrongAnsweredQuestions[$questionId])
498 return isset($this->postponedQuestions[$questionId]);
503 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
504 if (in_array($questionId, $questions)) {
514 return (
bool) count($this->questionTracking);
519 $questionList = array();
525 foreach (array_reverse($this->questionTracking) as $trackedQuestion) {
526 if (!isset($questionList[ $trackedQuestion[
'qid'] ])) {
527 $questionList[ $trackedQuestion[
'qid'] ] = $this->questionSet->getQuestionData($trackedQuestion[
'qid']);
531 return $questionList;
536 $this->questionTracking = array();
546 $completeQuestionIds = array_keys($this->questionSet->getAllQuestionsData());
548 $openQuestions = array_diff($completeQuestionIds, $this->correctAnsweredQuestions);
550 return $openQuestions;
555 $uniqueQuestions = array();
557 foreach ($this->questionTracking as $trackedQuestion) {
558 $uniqueQuestions[$trackedQuestion[
'qid']] = $trackedQuestion[
'qid'];
561 return count($uniqueQuestions);
571 if ($qId == $questionId) {
588 unset($this->alreadyCheckedQuestions[$questionId]);
593 $this->newlyCheckedQuestion = $questionId;
594 $this->alreadyCheckedQuestions[$questionId] = $questionId;
599 return isset($this->alreadyCheckedQuestions[$questionId]);
606 if (!isset($this->postponedQuestions[$questionId])) {
607 $this->postponedQuestions[$questionId] = 0;
610 $this->postponedQuestions[$questionId]++;
612 $this->newlyPostponedQuestion = $questionId;
613 $this->newlyPostponedQuestionsCount = $this->postponedQuestions[$questionId];
618 if (isset($this->postponedQuestions[$questionId])) {
619 unset($this->postponedQuestions[$questionId]);
627 $this->correctAnsweredQuestions[$questionId] = $questionId;
629 if (isset($this->wrongAnsweredQuestions[$questionId])) {
630 unset($this->wrongAnsweredQuestions[$questionId]);
633 $this->newlyAnsweredQuestion = $questionId;
634 $this->newlyAnsweredQuestionsAnswerStatus =
true;
641 $this->wrongAnsweredQuestions[$questionId] = $questionId;
643 if (isset($this->correctAnsweredQuestions[$questionId])) {
644 unset($this->correctAnsweredQuestions[$questionId]);
647 $this->newlyAnsweredQuestion = $questionId;
648 $this->newlyAnsweredQuestionsAnswerStatus =
false;
653 $this->questionTracking[] = array(
654 'qid' => $questionId,
'status' => $answerStatus
657 $this->newlyTrackedQuestion = $questionId;
658 $this->newlyTrackedQuestionsStatus = $answerStatus;
680 return $this->questionSet->getCompleteQuestionList()->getQuestionDataArray();
685 return $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
694 $questionSequence = array();
696 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
697 $questionSequence = array_merge($questionSequence, $questions);
700 return $questionSequence;
709 $minPostponeCount = null;
710 $minPostponeItem = null;
713 if ($minPostponeCount === null || $postponeCount <= $minPostponeCount) {
714 $minPostponeCount = $postponeCount;
715 $minPostponeItem = $qId;
718 return $minPostponeItem;
732 $orderedSequence = array();
735 for (
$i = 1;
$i <= $maxPostponeCount;
$i++) {
736 if (!isset($postponedCountDomain[
$i])) {
741 if ($postponeCount == $i) {
742 $orderedSequence[] = $qId;
747 return $orderedSequence;
752 $questionSequence = array();
754 foreach ($this->questionSet->getActualQuestionSequence() as $level => $questions) {
757 foreach ($questions as $pos => $qId) {
758 if (isset($this->correctAnsweredQuestions[$qId])) {
762 if ($nonAnsweredQuestions && isset($this->wrongAnsweredQuestions[$qId])) {
764 } elseif (!$nonAnsweredQuestions && !isset($this->wrongAnsweredQuestions[$qId])) {
768 if (!$nonPostponedQuestions && isset($this->postponedQuestions[$qId])) {
771 } elseif ($nonPostponedQuestions && !isset($this->postponedQuestions[$qId])) {
772 $questionSequence[] = $qId;
777 $questionSequence = array_merge(
784 return $questionSequence;
789 $questionSequence = array();
791 foreach ($this->questionTracking as
$key => $question) {
792 $qId = $question[
'qid'];
794 if (!isset($this->correctAnsweredQuestions[$qId])) {
798 $questionSequence[] = $qId;
801 return $questionSequence;
828 $questionOrder = array_merge(
830 $nonAnsweredQuestions,
831 $postponedNonAnsweredQuestions,
833 $postponedWrongAnsweredQuestions
836 return $questionOrder;
844 if (!$this->
getQuestionSet()->getSelectionQuestionList()->isInList($qId)) {
864 foreach ($questionOrder as $qId) {
866 if (is_object($question)) {
867 $worked_through = $question->_isWorkedThrough($this->
getActiveId(), $question->getId(), $this->
getPass());
869 if (array_key_exists($question->getId(), $solved_questions)) {
870 $solved = $solved_questions[$question->getId()][
"solved"];
876 $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()));
878 if (!$obligationsFilterEnabled ||
$row[
'obligatory']) {
891 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
893 foreach ($filteredQuestions as $filteredQuestion) {
904 $filteredQuestions = $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
906 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
resetTrackedQuestionList()
foreach($_POST as $key=> $value) $res
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()