/**
  * Performs a hint request and invokes the (re-)saving the question solution.
  * Redirects to local showHint command
  * 
  * @access	private
  * @global	ilCtrl $ilCtrl
  */
 private function performRequestCmd()
 {
     global $ilCtrl;
     if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
         throw new ilTestException('no hint id given');
     }
     $nextRequestableHint = ilAssQuestionHintTracking::getNextRequestableHint($this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     if ($nextRequestableHint->getId() != (int) $_GET['hintId']) {
         throw new ilTestException('given hint id does not relate to the next requestable hint');
     }
     ilAssQuestionHintTracking::storeRequest($nextRequestableHint, $this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     $this->testOutputGUI->saveQuestionSolution();
     $redirectTarget = $this->getHintPresentationLinkTarget($nextRequestableHint->getId(), false);
     ilUtil::redirect($redirectTarget);
 }
 /**
  * Performs a hint request and invokes the (re-)saving the question solution.
  * Redirects to local showHint command
  * 
  * @access	private
  * @global	ilCtrl $ilCtrl
  */
 private function performRequestCmd()
 {
     global $ilCtrl;
     if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
         throw new ilTestException('no hint id given');
     }
     $nextRequestableHint = ilAssQuestionHintTracking::getNextRequestableHint($this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     if ($nextRequestableHint->getId() != (int) $_GET['hintId']) {
         throw new ilTestException('given hint id does not relate to the next requestable hint');
     }
     ilAssQuestionHintTracking::storeRequest($nextRequestableHint, $this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     $this->testOutputGUI->saveQuestionSolution();
     $redirectTarget = ilUtil::appendUrlParameterString($ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT, '', false, false), "hintId={$nextRequestableHint->getId()}");
     ilUtil::redirect($redirectTarget);
 }
 public function show()
 {
     require_once 'class.ilTestEvaluationGUI.php';
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     global $ilUser;
     $template = new ilTemplate("tpl.il_as_tst_submission_review.html", TRUE, TRUE, "Modules/Test");
     $this->ilCtrl->setParameter($this, "skipfinalstatement", 1);
     $template->setVariable("FORMACTION", $this->ilCtrl->getFormAction($this->testOutputGUI, 'redirectBack') . '&reviewed=1');
     $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next"));
     $template->setVariable("BUTTON_BACK", $this->lng->txt("btn_previous"));
     if ($this->test->getListOfQuestionsEnd()) {
         $template->setVariable("CANCEL_CMD", 'outQuestionSummary');
     } else {
         $template->setVariable("CANCEL_CMD", 'backFromSummary');
     }
     $active = $this->test->getActiveIdOfUser($ilUser->getId());
     $testevaluationgui = new ilTestEvaluationGUI($this->test);
     $results = $this->test->getTestResult($active, $this->testSession->getPass());
     $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $this->testSession->getPass(), false, false, false, false);
     if ($this->test->getShowExamviewPdf()) {
         $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
         global $ilSetting;
         $inst_id = $ilSetting->get('inst_id', null);
         $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
         if (!is_dir($path)) {
             ilUtil::makeDirParents($path);
         }
         $filename = $path . '/exam_N' . $inst_id . '-' . $this->testOutputGUI->object->getId() . '-' . $active . '-' . $this->testSession->getPass() . '.pdf';
         require_once 'class.ilTestPDFGenerator.php';
         ilTestPDFGenerator::generatePDF($results_output, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
         $template->setVariable("PDF_FILE_LOCATION", $filename);
     } else {
         $template->setCurrentBlock('prevent_double_form_subm');
         $template->touchBlock('prevent_double_form_subm');
         $template->parseCurrentBlock();
     }
     if ($this->test->getShowExamviewHtml()) {
         if ($this->test->getListOfQuestionsEnd()) {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'outQuestionSummary');
         } else {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'backFromSummary');
         }
         $template->setVariable("BUTTON_CONTINUE_BOTTOM", $this->lng->txt("btn_next"));
         $template->setVariable("BUTTON_BACK_BOTTOM", $this->lng->txt("btn_previous"));
         $template->setVariable('HTML_REVIEW', $results_output);
     }
     $this->tpl->setVariable($this->getContentBlockName(), $template->get());
 }
 /**
  * renders the elements for the question related navigation
  * 
  * @access private
  * @global ilTemplate $tpl
  * @global ilLanguage $lng
  * @param assQuestionGUI $questionGUI 
  */
 protected function fillQuestionRelatedNavigation(assQuestionGUI $questionGUI)
 {
     global $tpl, $lng;
     $parseQuestionRelatedNavigation = false;
     switch (1) {
         case $this->object->getSpecificAnswerFeedback():
         case $this->object->getGenericAnswerFeedback():
         case $this->object->getAnswerFeedbackPoints():
         case $this->object->getInstantFeedbackSolution():
             $tpl->setCurrentBlock("direct_feedback");
             $tpl->setVariable("CMD_SHOW_INSTANT_RESPONSE", 'showInstantResponse');
             $tpl->setVariable("TEXT_SHOW_INSTANT_RESPONSE", $lng->txt("check"));
             $tpl->parseCurrentBlock();
             $parseQuestionRelatedNavigation = true;
     }
     if ($this->object->isOfferingQuestionHintsEnabled()) {
         $questionId = $questionGUI->object->getId();
         $activeId = $this->testSession->getActiveId();
         $pass = $this->testSession->getPass();
         require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
         $questionHintTracking = new ilAssQuestionHintTracking($questionId, $activeId, $pass);
         $requestsExist = $questionHintTracking->requestsExist();
         $requestsPossible = $questionHintTracking->requestsPossible();
         if ($requestsPossible) {
             if ($requestsExist) {
                 $buttonText = $lng->txt("button_request_next_question_hint");
             } else {
                 $buttonText = $lng->txt("button_request_question_hint");
             }
             $tpl->setCurrentBlock("button_request_next_question_hint");
             $tpl->setVariable("CMD_REQUEST_NEXT_QUESTION_HINT", 'confirmHintRequest');
             $tpl->setVariable("TEXT_REQUEST_NEXT_QUESTION_HINT", $buttonText);
             $tpl->parseCurrentBlock();
             $parseQuestionRelatedNavigation = true;
         }
         if ($requestsExist) {
             $tpl->setCurrentBlock("button_show_requested_question_hints");
             $tpl->setVariable("CMD_SHOW_REQUESTED_QUESTION_HINTS", 'showRequestedHintList');
             $tpl->setVariable("TEXT_SHOW_REQUESTED_QUESTION_HINTS", $lng->txt("button_show_requested_question_hints"));
             $tpl->parseCurrentBlock();
             $parseQuestionRelatedNavigation = true;
         }
     }
     if ($parseQuestionRelatedNavigation) {
         $tpl->setCurrentBlock("question_related_navigation");
         $tpl->parseCurrentBlock();
     }
 }
 private function storeQuestion(ilTestSession $testSession, ilTestRandomQuestionSetQuestion $setQuestion)
 {
     $nextId = $this->db->nextId('tst_test_rnd_qst');
     $this->db->insert('tst_test_rnd_qst', array('test_random_question_id' => array('integer', $nextId), 'active_fi' => array('integer', $testSession->getActiveId()), 'question_fi' => array('integer', $setQuestion->getQuestionId()), 'sequence' => array('integer', $setQuestion->getSequencePosition()), 'pass' => array('integer', $testSession->getPass()), 'tstamp' => array('integer', time()), 'src_pool_def_fi' => array('integer', $setQuestion->getSourcePoolDefinitionId())));
 }
 /**
  * @param ilTestSession $testSession
  */
 protected function handleSkillTriggering(ilTestSession $testSession)
 {
     $questionList = $this->buildTestPassQuestionList();
     $questionList->load();
     $testResults = $this->object->getTestResult($testSession->getActiveId(), $testSession->getPass(), true);
     require_once 'Modules/Test/classes/class.ilTestSkillEvaluation.php';
     $skillEvaluation = new ilTestSkillEvaluation($this->db, $this->object->getTestId(), $this->object->getRefId());
     $skillEvaluation->setUserId($testSession->getUserId());
     $skillEvaluation->setActiveId($testSession->getActiveId());
     $skillEvaluation->setPass($testSession->getPass());
     $skillEvaluation->setNumRequiredBookingsForSkillTriggering($this->assSettings->get('ass_skl_trig_num_answ_barrier', ilObjAssessmentFolder::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER));
     $skillEvaluation->init($questionList);
     $skillEvaluation->evaluate($testResults);
     $skillEvaluation->handleSkillTriggering();
 }
 /**
  * creates and returns an instance of a test sequence
  * that corresponds to the current test mode and the pass stored in test session
  * 
  * @param ilTestSession|ilTestSessionDynamicQuestionSet $testSession
  * @return ilTestSequence|ilTestSequenceDynamicQuestionSet
  */
 public function getSequenceByTestSession($testSession)
 {
     return $this->getSequenceByActiveIdAndPass($testSession->getActiveId(), $testSession->getPass());
 }
 /**
  * update question result of run
  * @param ilTestSession $session
  * @param assQuestion $qst
  */
 protected function updateQuestionResult(ilTestSession $session, assQuestion $qst)
 {
     foreach ($this->run as $run) {
         if ($run->questionExists($qst->getId())) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': reached points are ' . $qst->getReachedPoints($session->getActiveId(), $session->getPass()));
             $run->setQuestionResult($qst->getId(), $qst->getReachedPoints($session->getActiveId(), $session->getPass()));
             $run->update();
             $res = $run->getResult();
             include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
             include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
             $old_result = ilLOUserResults::lookupResult($this->container_id, $this->user_id, $run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL);
             $ur = new ilLOUserResults($this->container_id, $this->user_id);
             $ur->saveObjectiveResult($run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL, ilLOUtils::isCompleted($this->container_id, $session->getRefId(), $run->getObjectiveId(), $res['max'], $res['reached'], $old_result['limit_perc']) ? ilLOUserResults::STATUS_COMPLETED : ilLOUserResults::STATUS_FAILED, (int) $res['percentage'], $old_result['limit_perc'], $old_result['tries'], $old_result['is_final']);
             $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($run->getResult(), true));
             include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
             ilLPStatusWrapper::_updateStatus($this->container_id, $this->user_id);
         }
     }
     return false;
 }
 public function show()
 {
     require_once 'class.ilTestEvaluationGUI.php';
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     global $ilUser, $ilObjDataCache;
     $template = new ilTemplate("tpl.il_as_tst_submission_review.html", TRUE, TRUE, "Modules/Test");
     $this->ctrl->setParameter($this, "skipfinalstatement", 1);
     $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this->testOutputGUI, 'redirectBack') . '&reviewed=1');
     $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next"));
     $template->setVariable("BUTTON_BACK", $this->lng->txt("btn_previous"));
     if ($this->object->getListOfQuestionsEnd()) {
         $template->setVariable("CANCEL_CMD", 'outQuestionSummary');
     } else {
         $template->setVariable("CANCEL_CMD", 'backFromSummary');
     }
     $active = $this->object->getActiveIdOfUser($ilUser->getId());
     require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
     $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
     $objectivesList = null;
     if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
         $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
         $testSequence->loadFromDb();
         $testSequence->loadQuestions();
         require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
         $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
         $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
         $objectivesList->loadObjectivesTitles();
         $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
         $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
         $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
         $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
         $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
     }
     $results = $this->object->getTestResult($active, $this->testSession->getPass(), false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired());
     $testevaluationgui = new ilTestEvaluationGUI($this->object);
     $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $this->testSession->getPass(), false, false, false, false, false, $objectivesList, $testResultHeaderLabelBuilder);
     if ($this->object->getShowExamviewPdf()) {
         $template->setCurrentBlock("pdf_export");
         $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
         global $ilSetting;
         $inst_id = $ilSetting->get('inst_id', null);
         $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
         if (!is_dir($path)) {
             ilUtil::makeDirParents($path);
         }
         $filename = $path . '/exam_N' . $inst_id . '-' . $this->testOutputGUI->object->getId() . '-' . $active . '-' . $this->testSession->getPass() . '.pdf';
         require_once 'class.ilTestPDFGenerator.php';
         ilTestPDFGenerator::generatePDF($results_output, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
         $template->setVariable("PDF_FILE_LOCATION", $filename);
     }
     if ($this->object->getShowExamviewHtml()) {
         if ($this->object->getListOfQuestionsEnd()) {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'outQuestionSummary');
         } else {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'backFromSummary');
         }
         $template->setVariable("BUTTON_CONTINUE_BOTTOM", $this->lng->txt("btn_next"));
         $template->setVariable("BUTTON_BACK_BOTTOM", $this->lng->txt("btn_previous"));
         $template->setVariable('HTML_REVIEW', $results_output);
     }
     $this->tpl->setVariable($this->getContentBlockName(), $template->get());
 }