/**
  * creates and returns an instance of a test sequence
  * that corresponds to the current test mode
  * 
  * @param integer $activeId
  * @return ilTestSession|ilTestSessionDynamicQuestionSet
  */
 public function getSession($activeId = null)
 {
     global $ilUser;
     if (self::$testSession === null) {
         switch ($this->testOBJ->getQuestionSetType()) {
             case ilObjTest::QUESTION_SET_TYPE_FIXED:
             case ilObjTest::QUESTION_SET_TYPE_RANDOM:
                 global $ilUser;
                 require_once 'Modules/Test/classes/class.ilTestSession.php';
                 self::$testSession = new ilTestSession();
                 break;
             case ilObjTest::QUESTION_SET_TYPE_DYNAMIC:
                 require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
                 self::$testSession = new ilTestSessionDynamicQuestionSet();
                 break;
         }
         self::$testSession->setRefId($this->testOBJ->getRefId());
         self::$testSession->setTestId($this->testOBJ->getTestId());
         if ($activeId) {
             self::$testSession->loadFromDb($activeId);
         } else {
             self::$testSession->loadTestSession($this->testOBJ->getTestId(), $ilUser->getId(), $_SESSION["tst_access_code"][$this->testOBJ->getTestId()]);
         }
     }
     return self::$testSession;
 }
 /**
  * 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;
 }
 /**
  * @return string
  */
 protected function getIntroductionPageButtonLabel()
 {
     if ($this->testSession->isObjectiveOriented()) {
         return $this->lng->txt("save_back_to_objective_container");
     }
     return $this->lng->txt("save_introduction");
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 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;
 }
 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());
 }
 /**
  * @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();
 }
 public function __construct()
 {
     parent::__construct();
     $this->questionSetFilterSelection = new ilTestDynamicQuestionSetFilterSelection();
 }
 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())));
 }
Exemplo n.º 12
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;
 }
 protected function updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
 {
     include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
     include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
     foreach ($this->run as $tst_run) {
         // Clear questions of previous run
         $tst_run->clearQuestions();
         $rnd = new ilLORandomTestQuestionPools($this->container_id, $tst_run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOSettings::TYPE_TEST_QUALIFIED : ilLOSettings::TYPE_TEST_INITIAL);
         $stored_sequence_id = $rnd->getQplSequence();
         $points = 0;
         foreach ($seq->getQuestionIds() as $qst) {
             if ($stored_sequence_id == $seq->getResponsibleSourcePoolDefinitionId($qst)) {
                 $tst_run->addQuestion($qst);
                 $points += ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion($qst);
             }
         }
         $tst_run->setMaxPoints($points);
     }
 }
Exemplo n.º 14
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'] = '⊗';
             } 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());
 }
Exemplo n.º 16
0
 public function hasStarted(ilTestSession $testSession)
 {
     if ($testSession->getLastSequence() < 1) {
         return false;
     }
     // WTF ?? heard about tests with only one question !?
     if ($testSession->getLastSequence() == $this->getFirstSequence()) {
         return false;
     }
     return true;
 }
Exemplo n.º 17
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.º 18
0
 public function hasStarted(ilTestSession $testSession)
 {
     if ($testSession->getLastSequence() < 1) {
         return false;
     }
     if ($testSession->getLastSequence() == $this->getFirstSequence()) {
         return false;
     }
     return true;
 }
Exemplo n.º 19
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;
                 }
             }
         }
     }
 }
 public static function getInstance(ilTestSession $a_test_session)
 {
     $adapter = new self($a_test_session->getUserId(), $a_test_session->getObjectiveOrientedContainerId());
     $adapter->initTestRun($a_test_session);
     return $adapter;
 }