4 require_once
'./Modules/Test/classes/class.ilTestPlayerAbstractGUI.php';
29 $ilTabs->clearTargets();
31 $cmd = $this->ctrl->getCmd();
32 $next_class = $this->ctrl->getNextClass($this);
34 $this->ctrl->saveParameter($this,
"sequence");
35 $this->ctrl->saveParameter($this,
"active_id");
37 if (preg_match(
"/^gotoquestion_(\\d+)$/",
$cmd, $matches))
39 $cmd =
"gotoquestion";
40 if (strlen($matches[1]))
42 $this->ctrl->setParameter($this,
'gotosequence', $matches[1]);
54 $this->testSequence = $testSequenceFactory->getSequence($this->testSession);
55 $this->testSequence->loadFromDb();
56 $this->testSequence->loadQuestions();
58 include_once
'Services/jQuery/classes/class.iljQueryUtil.php';
60 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
69 case 'ilassquestionpagegui':
71 $questionId = $this->testSequence->getQuestionForSequence( $this->
calculateSequence() );
73 require_once
"./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
75 $ret = $this->ctrl->forwardCommand($page_gui);
78 case 'iltestsubmissionreviewgui':
79 require_once
'./Modules/Test/classes/class.ilTestSubmissionReviewGUI.php';
81 $ret = $this->ctrl->forwardCommand($gui);
84 case 'ilassquestionhintrequestgui':
86 $questionGUI = $this->
object->createQuestionGUI(
87 "", $this->testSequence->getQuestionForSequence( $this->calculateSequence() )
90 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
92 $questionGUI->object->getId(), $this->testSession->getActiveId(), $this->testSession->getPass()
95 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
98 $ret = $this->ctrl->forwardCommand($gui);
102 case 'iltestsignaturegui':
103 require_once
'./Modules/Test/classes/class.ilTestSignatureGUI.php';
105 $ret = $this->ctrl->forwardCommand($gui);
108 case 'iltestpasswordprotectiongui':
109 require_once
'Modules/Test/classes/class.ilTestPasswordProtectionGUI.php';
111 $ret = $this->ctrl->forwardCommand($gui);
125 $_GET[
'activecommand'] =
'start';
134 $questionId = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
141 $this->ctrl->setParameter($this,
"activecommand",
"next");
142 $this->ctrl->redirect($this,
"redirectQuestion");
150 $questionId = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
157 $this->ctrl->setParameter($this,
"activecommand",
"previous");
158 $this->ctrl->redirect($this,
"redirectQuestion");
175 $executable = $this->
object->isExecutable($this->testSession, $ilUser->getId());
176 if (!$executable[
"executable"])
179 $this->ctrl->redirectByClass(
"ilobjtestgui",
"infoScreen");
181 switch (
$_GET[
"activecommand"])
185 if ($this->sequence === FALSE)
187 if ($this->object->getListOfQuestionsEnd())
191 $this->testSession->getTestId(),
192 $this->testSession->getActiveId(),
193 $this->testSession->getPass()
196 if( $this->object->areObligationsEnabled() && !$allObligationsAnswered )
198 $this->ctrl->redirect($this,
"outQuestionSummaryWithObligationsInfo");
205 $this->ctrl->redirect($this,
"finishTest");
210 $this->testSession->setLastSequence($this->sequence);
211 $this->testSession->saveToDb();
217 $this->testSession->setLastSequence($this->sequence);
218 $this->testSession->saveToDb();
219 if ($this->sequence === FALSE)
221 $this->ctrl->redirect($this,
"outIntroductionPage");
230 $nextSequence = $this->testSequence->getNextSequence($this->sequence);
231 $this->testSequence->postponeSequence($this->sequence);
232 $this->testSequence->saveToDb();
233 $this->testSession->setLastSequence($nextSequence);
234 $this->testSession->saveToDb();
235 $this->sequence = $nextSequence;
240 $this->testSession->setLastSequence($this->sequence);
241 $this->testSession->saveToDb();
242 $q_id = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
243 $this->
object->setQuestionSetSolved(1, $q_id, $ilUser->getId());
248 $this->testSession->setLastSequence($this->sequence);
249 $this->testSession->saveToDb();
250 $q_id = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
251 $this->
object->setQuestionSetSolved(0, $q_id, $ilUser->getId());
254 case "directfeedback":
256 $this->testSession->setLastSequence($this->sequence);
257 $this->testSession->saveToDb();
260 case "handleQuestionAction":
262 $this->testSession->setLastSequence($this->sequence);
263 $this->testSession->saveToDb();
267 $this->ctrl->redirect($this,
"outQuestionSummary");
269 case "summary_obligations":
270 $this->ctrl->redirect($this,
"outQuestionSummaryWithObligationsInfo");
272 case "summary_obligations_only":
273 $this->ctrl->redirect($this,
"outObligationsOnlySummary");
279 $this->testSession->setUserId($ilUser->getId());
280 $this->testSession->setAnonymousId(
$_SESSION[
"tst_access_code"][$this->object->getTestId()]);
282 $this->testSession->saveToDb();
284 $active_id = $this->testSession->getActiveId();
285 $this->ctrl->setParameter($this,
"active_id", $active_id);
286 $shuffle = $this->
object->getShuffleQuestions();
287 if ($this->object->isRandomTest())
291 $this->
object->loadQuestions();
295 assQuestion::_updateTestPassResults(
296 $active_id, $this->testSession->getPass(), $this->
object->areObligationsEnabled(), null, $this->
object->id
300 if( !$this->testSequence->hasSequence() )
302 $this->testSequence->createNewSequence($this->object->getQuestionCount(), $shuffle);
303 $this->testSequence->saveToDb();
306 if( $this->testSession->isObjectiveOriented() )
308 $this->testSequence->loadFromDb();
309 $this->testSequence->loadQuestions();
312 $this->testSession, $this->testSequence
316 $active_time_id = $this->
object->startWorkingTime($this->testSession->getActiveId(), $this->testSession->getPass());
317 $_SESSION[
"active_time_id"] = $active_time_id;
318 if ($this->object->getListOfQuestionsStart())
320 $this->ctrl->setParameter($this,
"activecommand",
"summary");
321 $this->ctrl->redirect($this,
"redirectQuestion");
325 $this->ctrl->setParameter($this,
"sequence", $this->sequence);
326 $this->ctrl->setParameter($this,
"activecommand",
"gotoquestion");
327 $this->ctrl->saveParameter($this,
"tst_javascript");
328 $this->ctrl->redirect($this,
"redirectQuestion");
333 $active_id = $this->testSession->getActiveId();
334 $this->ctrl->setParameter($this,
"active_id", $active_id);
336 if ($this->object->isRandomTest())
338 if (!$this->testSequence->hasRandomQuestionsForPass($active_id, $this->testSession->getPass()))
344 $shuffle = $this->
object->getShuffleQuestions();
345 if ($this->object->isRandomTest())
350 assQuestion::_updateTestPassResults(
351 $active_id, $this->testSession->getPass(), $this->
object->areObligationsEnabled(), null, $this->
object->id
355 if( !$this->testSequence->hasSequence() )
357 $this->testSequence->createNewSequence($this->object->getQuestionCount(), $shuffle);
358 $this->testSequence->saveToDb();
361 $this->sequence = $this->testSession->getLastSequence();
362 $active_time_id = $this->
object->startWorkingTime($active_id, $this->testSession->getPass());
363 $_SESSION[
"active_time_id"] = $active_time_id;
364 if ($this->object->getListOfQuestionsStart())
366 $this->ctrl->setParameter($this,
"activecommand",
"summary");
367 $this->ctrl->redirect($this,
"redirectQuestion");
371 $this->ctrl->setParameter($this,
"sequence", $this->sequence);
372 $this->ctrl->setParameter($this,
"activecommand",
"gotoquestion");
373 $this->ctrl->saveParameter($this,
"tst_javascript");
374 $this->ctrl->redirect($this,
"redirectQuestion");
378 case 'test_submission_overview':
379 require_once
'./Modules/Test/classes/class.ilTestSubmissionReviewGUI.php';
380 $this->ctrl->redirectByClass(
'ilTestSubmissionReviewGUI',
"show");
387 if (array_key_exists(
"tst_javascript",
$_GET))
389 $ilUser->writePref(
"tst_javascript",
$_GET[
"tst_javascript"]);
392 if (strlen(
$_GET[
'gotosequence'])) $this->sequence =
$_GET[
'gotosequence'];
393 $this->testSession->setLastSequence($this->sequence);
394 $this->testSession->saveToDb();
402 if( $sequenceElement < 1 )
407 if( !$this->testSequence->getPositionOfSequence($sequenceElement) )
424 $sequence = $this->testSequence->getFirstSequence();
427 $_SESSION[
"active_time_id"]= $this->
object->startWorkingTime($this->testSession->getActiveId(),
428 $this->testSession->getPass()
434 if ($this->object->getListOfQuestions())
439 $questionId = $this->testSequence->getQuestionForSequence(
$sequence);
441 if( !(
int)$questionId && $this->testSession->isObjectiveOriented() )
444 sprintf($this->lng->txt(
'tst_objective_oriented_test_pass_without_questions'), $this->
object->getTitle()),
true
449 $question_gui = $this->
object->createQuestionGUI(
"", $questionId);
451 if( !is_object($question_gui) )
456 "INV SEQ: active={$this->testSession->getActiveId()} qId=$questionId seq=$sequence "
457 .serialize($this->testSequence)
460 $ilLog->logStack(
'INV SEQ');
462 $this->ctrl->setParameter($this,
'gotosequence', $this->testSequence->getFirstSequence());
463 $this->ctrl->setParameter($this,
'activecommand',
'gotoquestion');
464 $this->ctrl->redirect($this,
'redirectQuestion');
467 $question_gui->setTargetGui($this);
469 if ($this->object->getJavaScriptOutput())
474 $is_postponed = $this->testSequence->isPostponedQuestion($question_gui->object->getId());
475 $this->ctrl->setParameter($this,
"sequence",
"$sequence");
476 $formaction = $this->ctrl->getFormAction($this,
"gotoQuestion");
478 $question_gui->setSequenceNumber($this->testSequence->getPositionOfSequence(
$sequence));
479 $question_gui->setQuestionCount($this->testSequence->getUserQuestionCount());
483 $user_post_solution = FALSE;
484 if (array_key_exists(
"previouspost",
$_SESSION))
486 $user_post_solution =
$_SESSION[
"previouspost"];
493 $answer_feedback = FALSE;
494 if (($directfeedback) && ($this->object->getSpecificAnswerFeedback()))
496 $answer_feedback = TRUE;
501 $solutionoutput = $question_gui->getSolutionOutput(
502 $this->testSession->getActiveId(), #active_id
504 FALSE, #graphical_output
505 false, #result_output
506 true, #show_question_only
507 $answer_feedback, #show_feedback
508 false, #show_correct_solution
509 FALSE, #show_manual_scoring
510 true #show_question_text
513 $pageoutput = $question_gui->outQuestionPage(
514 "", $this->testSequence->isPostponedQuestion($questionId),
515 $this->testSession->getActiveId(),
519 $this->tpl->setVariable(
"QUESTION_OUTPUT", $pageoutput);
520 $this->tpl->setVariable(
"FORMACTION", $formaction);
522 $directfeedback =
true;
528 $question_gui->outQuestionForTest(
529 $formaction, #form_action
530 $this->testSession->getActiveId(), #active_id
532 $is_postponed, #is_postponed
533 $user_post_solution, #user_post_solution
534 $answer_feedback #answer_feedback == inline_specific_feedback
548 if ($this->object->getInstantFeedbackSolution())
553 $solutionoutput = $question_gui->getSolutionOutput(
554 $this->testSession->getActiveId(), #active_id
556 FALSE, #graphical_output
557 $show_question_inline_score, #result_output
558 FALSE, #show_question_only
559 FALSE, #show_feedback
560 TRUE, #show_correct_solution
561 FALSE, #show_manual_scoring
562 FALSE #show_question_text
569 if ($this->object->getAnswerFeedbackPoints())
571 $reachedPoints = $question_gui->object->getAdjustedReachedPoints($this->testSession->getActiveId(), NULL);
572 $maxPoints = $question_gui->object->getMaximumPoints();
579 if ($this->object->getGenericAnswerFeedback())
586 if ($this->object->getSpecificAnswerFeedback())
594 if ($postpone_allowed && !$is_postponed)
599 if ($this->object->getListOfQuestions())
604 if ($this->object->getShowCancel())
611 if ($this->object->getListOfQuestionsEnd())
625 if ($this->object->getShowMarker())
627 include_once
"./Modules/Test/classes/class.ilObjTest.php";
631 if (count ($solved_array) > 0)
633 $solved = array_pop($solved_array);
634 $solved = $solved[
"solved"];
649 if ($this->object->getJavaScriptOutput())
651 $this->tpl->setVariable(
"JAVASCRIPT_TITLE", $this->lng->txt(
"disable_javascript"));
652 $this->ctrl->setParameter($this,
"tst_javascript",
"0");
653 $this->tpl->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this,
"gotoQuestion"));
657 $this->tpl->setVariable(
"JAVASCRIPT_TITLE", $this->lng->txt(
"enable_javascript"));
658 $this->ctrl->setParameter($this,
"tst_javascript",
"1");
659 $this->tpl->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this,
"gotoQuestion"));
662 if ($question_gui->object->requiresJsSwitch() && !$this->
object->getForceJS())
664 $this->tpl->touchBlock(
"jsswitch");
669 $this->tpl->setVariable(
"AUTOSAVE_URL", $this->ctrl->getFormAction($this,
"autosave",
"",
true));
671 if ($question_gui->isAutosaveable()&& $this->
object->getAutosave())
673 $this->tpl->touchBlock(
'autosave');
677 $this->tpl->setVariable(
"AUTOSAVEFORMACTION", str_replace(
"&",
"&", $this->ctrl->getLinkTarget($this,
"autosave")));
678 $this->tpl->setVariable(
"AUTOSAVEINTERVAL", $this->object->getAutosaveIval());
683 $this->tpl->touchBlock(
'question_obligatory');
684 $this->tpl->setVariable(
'QUESTION_OBLIGATORY', $this->lng->txt(
'required_field'));
690 return $sequence == $this->testSequence->getFirstSequence();
695 return $this->testSequence->getQuestionForSequence($this->testSequence->getLastSequence()) == $question_gui->object->getId();
714 $this->saveResult = FALSE;
717 $formtimestamp =
$_POST[
"formtimestamp"];
718 if (strlen($formtimestamp) == 0) $formtimestamp =
$_GET[
"formtimestamp"];
719 if ($formtimestamp !=
$_SESSION[
"formtimestamp"])
721 $_SESSION[
"formtimestamp"] = $formtimestamp;
732 $q_id = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
733 if (is_numeric($q_id) && (
int)$q_id)
737 $question_gui = $this->
object->createQuestionGUI(
"", $q_id);
738 if ($this->object->getJavaScriptOutput())
743 $active_id = $this->testSession->getActiveId();
744 if ($this->object->isRandomTest())
746 $pass = $this->
object->_getPass($active_id);
748 $this->saveResult = $question_gui->object->persistWorkingState(
749 $active_id,
$pass, $this->object->areObligationsEnabled()
756 if( $this->testSession->isObjectiveOriented() )
759 $this->testSession, $this->testSequence, $question_gui->object
764 if ($this->saveResult == FALSE)
766 $this->ctrl->setParameter($this,
"save_error",
"1");
774 $questionId = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
780 $this->testSequence->setQuestionChecked($questionId);
781 $this->testSequence->saveToDb();
784 $this->ctrl->setParameter($this,
"activecommand",
"directfeedback");
785 $this->ctrl->redirect($this,
"redirectQuestion");
790 $questionId = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
797 if ($this->saveResult == FALSE)
799 $this->ctrl->setParameter($this,
"activecommand",
"");
800 $this->ctrl->redirect($this,
"redirectQuestion");
804 $this->ctrl->setParameter($this,
"activecommand",
"summary");
805 $this->ctrl->redirect($this,
"redirectQuestion");
811 $this->ctrl->setParameter($this,
"activecommand",
"summary");
812 $this->ctrl->redirect($this,
"redirectQuestion");
822 $questionId = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
829 $this->ctrl->setParameter($this,
"activecommand",
"postpone");
830 $this->ctrl->redirect($this,
"redirectQuestion");
835 $questionId = $this->testSequence->getQuestionForSequence(
$_GET[
"sequence"]);
843 $this->ctrl->setParameter($this,
'activecommand',
'handleQuestionAction');
844 $this->ctrl->redirect($this,
'redirectQuestion');
849 if ($this->testSession->getActiveId() > 0)
851 if ($this->testSequence->hasRandomQuestionsForPass($this->testSession->getActiveId(), $this->testSession->getPass()) > 0)
859 __METHOD__.
' Random Questions allready exists for user '.
860 $ilUser->getId().
' in test '.$this->
object->getTestId()
872 $ilLog->write(__METHOD__.
' '.sprintf(
873 $this->lng->txt(
"error_random_question_generation"), $ilUser->getId(), $this->
object->getTestId()
886 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetConfig.php';
888 $questionSetConfig->loadFromDb();
890 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
893 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
895 $sourcePoolDefinitionList->loadDefinitions();
897 $this->processLocker->requestRandomPassBuildLock($sourcePoolDefinitionList->hasTaxonomyFilters());
901 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetStagingPoolQuestionList.php';
904 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetBuilder.php';
907 $questionSetBuilder->performBuild($this->testSession);
910 $this->processLocker->releaseRandomPassBuildLock();
915 require_once
'Modules/Course/classes/Objectives/class.ilLOSettings.php';
922 require_once
'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
929 require_once
'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
938 return $this->testSession->isObjectiveOriented();
945 require_once
'Services/Link/classes/class.ilLink.php';