/**
  * creates and returns an instance of a test sequence
  * that corresponds to the current test mode and given pass
  * 
  * @param ilTestSession|ilTestSessionDynamicQuestionSet $testSession
  * @param integer $pass
  * @return ilTestSequence|ilTestSequenceDynamicQuestionSet
  */
 public function getSequenceByPass($testSession, $pass)
 {
     if ($this->testSequence === null) {
         switch ($this->testOBJ->getQuestionSetType()) {
             case ilObjTest::QUESTION_SET_TYPE_FIXED:
                 require_once 'Modules/Test/classes/class.ilTestSequenceFixedQuestionSet.php';
                 $this->testSequence = new ilTestSequenceFixedQuestionSet($testSession->getActiveId(), $pass, $this->testOBJ->isRandomTest());
                 break;
             case ilObjTest::QUESTION_SET_TYPE_RANDOM:
                 require_once 'Modules/Test/classes/class.ilTestSequenceRandomQuestionSet.php';
                 $this->testSequence = new ilTestSequenceRandomQuestionSet($testSession->getActiveId(), $pass, $this->testOBJ->isRandomTest());
                 break;
             case ilObjTest::QUESTION_SET_TYPE_DYNAMIC:
                 require_once 'Modules/Test/classes/class.ilTestSequenceDynamicQuestionSet.php';
                 require_once 'Modules/Test/classes/class.ilTestDynamicQuestionSet.php';
                 $questionSet = new ilTestDynamicQuestionSet($this->db, $this->lng, $this->pluginAdmin, $this->testOBJ);
                 $this->testSequence = new ilTestSequenceDynamicQuestionSet($this->db, $questionSet, $testSession->getActiveId());
                 #$this->testSequence->setPreventCheckedQuestionsFromComingUpEnabled(
                 #	$this->testOBJ->isInstantFeedbackAnswerFixationEnabled()
                 #); // checked questions now has to come up any time, so they can be set to unchecked right at this moment
                 break;
         }
     }
     return $this->testSequence;
 }
 protected function getMarkedQuestions()
 {
     if ($this->object->getShowMarker()) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $marked_questions = ilObjTest::_getSolvedQuestions($this->testSession->getActiveId());
     } else {
         $marked_questions = array();
     }
     return $marked_questions;
 }
 /**
  * creates and returns an instance of a test sequence
  * that corresponds to the current test mode and given pass
  * 
  * @param ilTestSession|ilTestSessionDynamicQuestionSet $testSession
  * @param integer $pass
  * @return ilTestSequence|ilTestSequenceDynamicQuestionSet
  */
 public function getSequenceByPass($testSession, $pass)
 {
     if ($this->testSequence === null) {
         switch ($this->testOBJ->getQuestionSetType()) {
             case ilObjTest::QUESTION_SET_TYPE_FIXED:
                 require_once 'Modules/Test/classes/class.ilTestSequence.php';
                 $this->testSequence = new ilTestSequence($testSession->getActiveId(), $pass, $this->testOBJ->isRandomTest());
                 break;
             case ilObjTest::QUESTION_SET_TYPE_RANDOM:
                 require_once 'Modules/Test/classes/class.ilTestSequenceRandomQuestionSet.php';
                 $this->testSequence = new ilTestSequenceRandomQuestionSet($testSession->getActiveId(), $pass, $this->testOBJ->isRandomTest());
                 break;
             case ilObjTest::QUESTION_SET_TYPE_DYNAMIC:
                 require_once 'Modules/Test/classes/class.ilTestSequenceDynamicQuestionSet.php';
                 require_once 'Modules/Test/classes/class.ilTestDynamicQuestionSet.php';
                 $questionSet = new ilTestDynamicQuestionSet($this->db, $this->lng, $this->pluginAdmin, $this->testOBJ);
                 $this->testSequence = new ilTestSequenceDynamicQuestionSet($this->db, $questionSet, $testSession->getActiveId());
                 break;
         }
     }
     return $this->testSequence;
 }
 private function isTestResultButtonRequired()
 {
     $testOBJ = ilObjectFactory::getInstanceByObjId($this->objectId);
     if (!$testOBJ->canShowTestResults($this->testSession)) {
         return false;
     }
     require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
     $testPassesSelector = new ilTestPassesSelector($this->db, $testOBJ);
     $testPassesSelector->setActiveId($this->testSession->getActiveId());
     $testPassesSelector->setLastFinishedPass($this->testSession->getLastFinishedPass());
     if (!count($testPassesSelector->getReportablePasses())) {
         return false;
     }
     return true;
 }
 /**
  * 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);
 }
Exemplo n.º 7
0
 function createRandomSolutions($number)
 {
     global $ilDB;
     // 1. get a user
     $query = "SELECT usr_id FROM usr_data";
     $result = $ilDB->query($query);
     while ($data = $ilDB->fetchAssoc($result)) {
         $activequery = sprintf("SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s", $ilDB->quote($this->getTestId()), $ilDB->quote($data['usr_id']));
         $activeresult = $ilDB->query($activequery);
         if ($activeresult->numRows() == 0) {
             $user_id = $data['usr_id'];
             if ($user_id != 13) {
                 include_once "./Modules/Test/classes/class.ilTestSession.php";
                 $testSession = FALSE;
                 $testSession = new ilTestSession();
                 $testSession->setRefId($this->getRefId());
                 $testSession->setTestId($this->getTestId());
                 $testSession->setUserId($user_id);
                 $testSession->saveToDb();
                 $passes = $this->getNrOfTries() ? $this->getNrOfTries() : 10;
                 $nr_of_passes = rand(1, $passes);
                 $active_id = $testSession->getActiveId();
                 for ($pass = 0; $pass < $nr_of_passes; $pass++) {
                     include_once "./Modules/Test/classes/class.ilTestSequence.php";
                     $testSequence = new ilTestSequence($active_id, $pass, $this->isRandomTest());
                     if (!$testSequence->hasSequence()) {
                         $testSequence->createNewSequence($this->getQuestionCount(), $shuffle);
                         $testSequence->saveToDb();
                     }
                     for ($seq = 1; $seq <= count($this->questions); $seq++) {
                         $question_id = $testSequence->getQuestionForSequence($seq);
                         $objQuestion = ilObjTest::_instanciateQuestion($question_id);
                         $objQuestion->createRandomSolution($testSession->getActiveId(), $pass);
                     }
                     if ($pass < $nr_of_passes - 1) {
                         $testSession->increasePass();
                         $testSession->setLastSequence(0);
                         $testSession->saveToDb();
                     } else {
                         $testSession->setSubmitted(1);
                         $testSession->setSubmittedTimestamp(date('Y-m-d H:i:s'));
                         $testSession->saveToDb();
                     }
                 }
                 $number--;
                 if ($number == 0) {
                     return;
                 }
             }
         }
     }
 }
 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();
 }
Exemplo n.º 10
0
 /**
  * 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());
 }
Exemplo n.º 11
0
 public function buildVirtualSequence(ilTestSession $testSession)
 {
     global $ilDB, $lng, $ilPluginAdmin;
     require_once 'Modules/Test/classes/class.ilTestVirtualSequence.php';
     $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
     if ($this->object->isRandomTest()) {
         require_once 'Modules/Test/classes/class.ilTestVirtualSequenceRandomQuestionSet.php';
         $virtualSequence = new ilTestVirtualSequenceRandomQuestionSet($ilDB, $this->object, $testSequenceFactory);
     } else {
         require_once 'Modules/Test/classes/class.ilTestVirtualSequence.php';
         $virtualSequence = new ilTestVirtualSequence($ilDB, $this->object, $testSequenceFactory);
     }
     $virtualSequence->setActiveId($testSession->getActiveId());
     $virtualSequence->init();
     return $virtualSequence;
 }
 /**
  * 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;
 }
Exemplo n.º 13
0
 /**
  * Returns the pass overview for a given active ID
  *
  * @return string HTML code of the pass overview
  * @access public
  * 
  * @deprecated
  */
 public function getPassOverview(ilTestSession $testSession, $targetclass = "", $targetcommand = "", $short = FALSE, $hide_details = FALSE)
 {
     $active_id = $testSession->getActiveId();
     require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
     require_once 'Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php';
     $table = new ilTestPassOverviewTableGUI($this, '', $short ? ilTestPassOverviewTableGUI::CONTEXT_SHORT : ilTestPassOverviewTableGUI::CONTEXT_LONG, isset($_GET['pdf']) && $_GET['pdf'] == 1);
     $considerHiddenQuestions = true;
     if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
         $considerHiddenQuestions = false;
         $table->setObjectiveOrientedPresentationEnabled(true);
         require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
         $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
     }
     $table->init();
     $data = array();
     $counted_pass = $this->object->_getResultPass($active_id);
     $reached_pass = $this->object->_getPass($active_id);
     require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
     $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
     $testPassesSelector->setActiveId($active_id);
     $lastFinishedPass = $this->testSessionFactory->getSession($active_id)->getLastFinishedPass();
     $testPassesSelector->setLastFinishedPass($lastFinishedPass);
     foreach ($testPassesSelector->getReportablePasses() as $pass) {
         $row = array();
         $considerOptionalQuestions = true;
         if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
             $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
             $testSequence->loadFromDb();
             $testSequence->loadQuestions();
             if ($this->object->isRandomTest() && !$testSequence->isAnsweringOptionalQuestionsConfirmed()) {
                 $considerOptionalQuestions = false;
             }
             $testSequence->setConsiderHiddenQuestionsEnabled($considerHiddenQuestions);
             $testSequence->setConsiderOptionalQuestionsEnabled($considerOptionalQuestions);
             $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
             $objectivesList->loadObjectivesTitles();
             $row['objectives'] = $objectivesList->getUniqueObjectivesStringForQuestions($testSequence->getUserSequenceQuestions());
         }
         if (!$short) {
             $result_array =& $this->object->getTestResult($active_id, $pass, false, $considerHiddenQuestions, $considerOptionalQuestions);
             if (!$result_array['pass']['total_max_points']) {
                 $percentage = 0;
             } else {
                 $percentage = $result_array['pass']['total_reached_points'] / $result_array['pass']['total_max_points'] * 100;
             }
             $total_max = $result_array['pass']['total_max_points'];
             $total_reached = $result_array['pass']['total_reached_points'];
             $total_requested_hints = $result_array['pass']['total_requested_hints'];
         }
         if (!$hide_details) {
             if (strlen($targetclass) && strlen($targetcommand)) {
                 $this->ctrl->setParameterByClass($targetclass, 'active_id', $active_id);
                 $this->ctrl->setParameterByClass($targetclass, 'pass', $pass);
                 $aslgui = new ilAdvancedSelectionListGUI();
                 $aslgui->setListTitle($this->lng->txt('actions'));
                 $aslgui->setId($pass);
                 $aslgui->addItem($this->lng->txt('tst_pass_details'), 'tst_pass_details', $this->ctrl->getLinkTargetByClass($targetclass, $targetcommand));
                 if ($this->object->isPassDeletionAllowed() && $pass != $counted_pass) {
                     $aslgui->addItem($this->lng->txt('delete'), 'tst_pass_delete', $this->ctrl->getLinkTargetByClass($targetclass, 'confirmDeletePass'));
                 }
                 $row['pass_details'] = $aslgui->getHTML();
             }
         }
         if (!$short) {
             if ($pass == $counted_pass) {
                 $row['scored'] = '&otimes;';
             } else {
                 $row['scored'] = '';
             }
         }
         $row['pass'] = $pass + 1;
         $row['date'] = $this->object->getPassFinishDate($active_id, $pass);
         if (!$short) {
             $row['answered'] = $result_array['pass']['num_workedthrough'] . ' ' . strtolower($this->lng->txt('of')) . ' ' . (count($result_array) - 2);
             if ($this->object->isOfferingQuestionHintsEnabled()) {
                 $row['hints'] = $total_requested_hints;
             }
             $row['reached'] = $total_reached . ' ' . strtolower($this->lng->txt('of')) . ' ' . $total_max;
             $row['percentage'] = $percentage;
         }
         $data[] = $row;
     }
     $table->setData($data);
     return $table->getHTML();
 }
 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());
 }