92 $this->newlyTrackedQuestion = null;
93 $this->newlyTrackedQuestionsStatus = null;
95 $this->newlyPostponedQuestion = null;
96 $this->newlyPostponedQuestionsCount = null;
98 $this->newlyAnsweredQuestion = null;
99 $this->newlyAnsweredQuestionsAnswerStatus = null;
117 SELECT question_fi, status
118 FROM tst_seq_qst_tracking
121 ORDER BY orderindex ASC
124 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
126 $this->questionTracking = array();
128 while(
$row = $this->db->fetchAssoc(
$res) )
130 $this->questionTracking[] = array(
131 'qid' =>
$row[
'question_fi'],
132 'status' =>
$row[
'status']
140 SELECT question_fi, correctness
141 FROM tst_seq_qst_answstatus
146 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
148 $this->correctAnsweredQuestions = array();
149 $this->wrongAnsweredQuestions = array();
151 while(
$row = $this->db->fetchAssoc(
$res) )
153 if(
$row[
'correctness'] )
155 $this->correctAnsweredQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
159 $this->wrongAnsweredQuestions[
$row[
'question_fi'] ] = $row[
'question_fi'];
167 SELECT question_fi, cnt
168 FROM tst_seq_qst_postponed
173 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array($this->activeId, 0));
175 $this->postponedQuestions = array();
177 while(
$row = $this->db->fetchAssoc(
$res) )
179 $this->postponedQuestions[
$row[
'question_fi'] ] = $row[
'cnt'];
185 $this->db->manipulateF(
186 "DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
187 array(
'integer',
'integer'), array($this->
getActiveId(), 0)
190 $this->db->insert(
'tst_sequence', array(
191 'active_fi' => array(
'integer', $this->
getActiveId()),
192 'pass' => array(
'integer', 0),
193 'sequence' => array(
'clob', null),
194 'postponed' => array(
'text', null),
195 'hidden' => array(
'text', null),
196 'tstamp' => array(
'integer', time())
207 if( (
int)$this->newlyTrackedQuestion )
211 $this->db->replace(
'tst_seq_qst_tracking',
213 'active_fi' => array(
'integer', (
int)$this->
getActiveId()),
214 'pass' => array(
'integer', 0),
215 'question_fi' => array(
'integer', (
int)$this->newlyTrackedQuestion)
218 'status' => array(
'text', $this->newlyTrackedQuestionsStatus),
219 'orderindex' => array(
'integer', $newOrderIndex)
228 SELECT (MAX(orderindex) + 1) new_order_index
229 FROM tst_seq_qst_tracking
238 if(
$row[
'new_order_index'] )
240 return $row[
'new_order_index'];
248 if( (
int)$this->newlyAnsweredQuestion )
250 $this->db->replace(
'tst_seq_qst_answstatus',
252 'active_fi' => array(
'integer', (
int)$this->
getActiveId()),
253 'pass' => array(
'integer', 0),
254 'question_fi' => array(
'integer', (
int)$this->newlyAnsweredQuestion)
257 'correctness' => array(
'integer', (
int)$this->newlyAnsweredQuestionsAnswerStatus)
265 if( (
int)$this->newlyPostponedQuestion )
267 $this->db->replace(
'tst_seq_qst_postponed',
269 'active_fi' => array(
'integer', (
int)$this->
getActiveId()),
270 'pass' => array(
'integer', 0),
271 'question_fi' => array(
'integer', (
int)$this->newlyPostponedQuestion)
274 'cnt' => array(
'integer', (
int)$this->newlyPostponedQuestionsCount)
282 $INquestions = $this->db->in(
'question_fi', array_keys($this->postponedQuestions),
true,
'integer');
285 if( $INquestions ==
' 1=2 ' ) $INquestions =
' 1=1 ';
289 DELETE FROM tst_seq_qst_postponed
295 $this->db->manipulateF(
$query, array(
'integer',
'integer'), array($this->
getActiveId(), 0));
300 $this->questionSet->load($dynamicQuestionSetConfig, $filterSelection);
321 foreach($this->postponedQuestions as $questionId)
323 if( !$this->questionSet->questionExists($questionId) )
325 unset($this->postponedQuestions[$questionId]);
329 foreach($this->wrongAnsweredQuestions as $questionId)
331 if( !$this->questionSet->questionExists($questionId) )
333 unset($this->wrongAnsweredQuestions[$questionId]);
337 foreach($this->correctAnsweredQuestions as $questionId)
339 if( !$this->questionSet->questionExists($questionId) )
341 unset($this->correctAnsweredQuestions[$questionId]);
367 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
371 foreach($questions as $pos => $qId)
373 if( isset($this->correctAnsweredQuestions[$qId]) )
378 if( $forceNonAnsweredQuestion && isset($this->wrongAnsweredQuestions[$qId]) )
383 if( isset($this->postponedQuestions[$qId]) )
404 isset($this->correctAnsweredQuestions[$questionId])
405 || isset($this->wrongAnsweredQuestions[$questionId])
411 return isset($this->postponedQuestions[$questionId]);
416 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
418 if( in_array($questionId, $questions) )
429 return (
bool)count($this->questionTracking);
434 $questionList = array();
436 if( $currentQuestionId )
438 $questionList[$currentQuestionId] = $this->questionSet->getQuestionData($currentQuestionId);
441 foreach( array_reverse($this->questionTracking) as $trackedQuestion)
443 if( !isset($questionList[ $trackedQuestion[
'qid'] ]) )
445 $questionList[ $trackedQuestion[
'qid'] ] = $this->questionSet->getQuestionData($trackedQuestion[
'qid']);
449 return $questionList;
454 $this->questionTracking = array();
464 $completeQuestionIds = array_keys( $this->questionSet->getAllQuestionsData() );
466 $openQuestions = array_diff($completeQuestionIds, $this->correctAnsweredQuestions);
468 return $openQuestions;
473 $uniqueQuestions = array();
475 foreach($this->questionTracking as $trackedQuestion)
477 $uniqueQuestions[$trackedQuestion[
'qid']] = $trackedQuestion[
'qid'];
480 return count($uniqueQuestions);
487 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
489 foreach($questions as $pos => $qId)
493 if($qId == $questionId)
507 foreach($this->questionSet->getActualQuestionSequence() as $level => $questions)
509 $count += count($questions);
521 if( !isset($this->postponedQuestions[$questionId]) )
523 $this->postponedQuestions[$questionId] = 0;
526 $this->postponedQuestions[$questionId]++;
528 $this->newlyPostponedQuestion = $questionId;
529 $this->newlyPostponedQuestionsCount = $this->postponedQuestions[$questionId];
534 if( isset($this->postponedQuestions[$questionId]) )
535 unset($this->postponedQuestions[$questionId]);
542 $this->correctAnsweredQuestions[$questionId] = $questionId;
544 if( isset($this->wrongAnsweredQuestions[$questionId]) )
545 unset($this->wrongAnsweredQuestions[$questionId]);
547 $this->newlyAnsweredQuestion = $questionId;
548 $this->newlyAnsweredQuestionsAnswerStatus =
true;
555 $this->wrongAnsweredQuestions[$questionId] = $questionId;
557 if( isset($this->correctAnsweredQuestions[$questionId]) )
558 unset($this->correctAnsweredQuestions[$questionId]);
560 $this->newlyAnsweredQuestion = $questionId;
561 $this->newlyAnsweredQuestionsAnswerStatus =
false;
566 $this->questionTracking[] = array(
567 'qid' => $questionId,
'status' => $answerStatus
570 $this->newlyTrackedQuestion = $questionId;
571 $this->newlyTrackedQuestionsStatus = $answerStatus;
585 return $this->questionSet->getCompleteQuestionList()->getQuestionDataArray();
590 return $this->questionSet->getFilteredQuestionList()->getQuestionDataArray();
599 $questionSequence = array();
601 foreach( $this->questionSet->getActualQuestionSequence() as $level => $questions )
603 $questionSequence = array_merge($questionSequence, $questions);
606 return $questionSequence;
615 $minPostponeCount = null;
616 $minPostponeItem = null;
620 if($minPostponeCount === null || $postponeCount <= $minPostponeCount)
622 $minPostponeCount = $postponeCount;
623 $minPostponeItem = $qId;
626 return $minPostponeItem;