/**
  * @param string $extension
  * @param string $additional
  * @return string
  * @throws ilException
  */
 public function getPathname($extension, $additional = '')
 {
     if (!is_string($extension) || !strlen($extension)) {
         throw new ilException('Missing file extension! Please pass a file extension of type string.');
     } else {
         if (substr_count($extension, '.') > 1 || strpos($extension, '.') !== false && strpos($extension, '.') !== 0) {
             throw new ilException('Please use at most one dot in your file extension.');
         } else {
             if (strpos($extension, '.') === 0) {
                 $extension = substr($extension, 1);
             }
         }
     }
     if (!is_string($additional)) {
     } else {
         if (strlen($additional)) {
             if (strpos($additional, '__') === 0) {
                 throw new ilException('The additional file part may not contain __ at the beginning!');
             }
             $additional = '__' . $additional . '_';
         } else {
             $additional = '_';
         }
     }
     return $this->test->getExportDirectory() . DIRECTORY_SEPARATOR . $this->getTimestamp() . '__' . IL_INST_ID . '__' . $this->test->getType() . $additional . $this->test->getId() . '.' . $extension;
 }
 /**
  * creates and returns an instance of a test sequence
  * that corresponds to the current test mode and given active/pass
  * 
  * @param integer $activeId
  * @param integer $pass
  * @return ilTestSequenceFixedQuestionSet|ilTestSequenceRandomQuestionSet|ilTestSequenceDynamicQuestionSet
  */
 public function getSequenceByActiveIdAndPass($activeId, $pass)
 {
     if ($this->testSequences[$activeId][$pass] === null) {
         switch ($this->testOBJ->getQuestionSetType()) {
             case ilObjTest::QUESTION_SET_TYPE_FIXED:
                 require_once 'Modules/Test/classes/class.ilTestSequenceFixedQuestionSet.php';
                 $this->testSequences[$activeId][$pass] = new ilTestSequenceFixedQuestionSet($activeId, $pass, $this->testOBJ->isRandomTest());
                 break;
             case ilObjTest::QUESTION_SET_TYPE_RANDOM:
                 require_once 'Modules/Test/classes/class.ilTestSequenceRandomQuestionSet.php';
                 $this->testSequences[$activeId][$pass] = new ilTestSequenceRandomQuestionSet($activeId, $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->testSequences[$activeId][$pass] = new ilTestSequenceDynamicQuestionSet($this->db, $questionSet, $activeId);
                 #$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->testSequences[$activeId][$pass];
 }
Exemplo n.º 3
0
 /**
  * Get the configuration that should be used for the current selector
  * @param	object	(optional) current running test 
  * @return	ilCharSelectorConfig
  */
 static function _getCurrentConfig(ilObjTest $a_test_obj = null)
 {
     global $ilSetting, $ilUser;
     // check configuration from administration settings
     $admin_config = new self(self::CONTEXT_ADMIN, true);
     $admin_config->setAvailability($ilSetting->get('char_selector_availability'));
     $admin_config->setDefinition($ilSetting->get('char_selector_definition'));
     if ($admin_config->getAvailability() == self::INACTIVE) {
         // a globally inactive selector can't be overwritten by users or tests
         return $admin_config;
     }
     // a test configuration is relevant for test runs
     if (isset($a_test_obj)) {
         $test_config = new self(self::CONTEXT_TEST, false);
         $test_config->setAvailability($a_test_obj->getCharSelectorAvailability());
         $test_config->setDefinition($a_test_obj->getCharSelectorDefinition());
         if ($test_config->getAvailability() != self::INHERIT) {
             // a specific test configuration has precedence over user configuration
             return $test_config;
         }
     }
     // check configuration from user settings
     $user_config = new self(self::CONTEXT_USER, true);
     $user_config->setAvailability($ilUser->getPref('char_selector_availability'));
     $user_config->setDefinition($ilUser->getPref('char_selector_definition'));
     if ($user_config->getAvailability() != self::INHERIT) {
         // take user specific config
         return $user_config;
     } else {
         // take admin config as default
         return $admin_config;
     }
 }
 private function loadResultData()
 {
     $this->resultData = $this->testOBJ->getResultsForActiveId($this->getActiveId());
     if ($this->testOBJ->getECTSOutput()) {
         $ectsMark = $this->testOBJ->getECTSGrade($this->testOBJ->getTotalPointsPassedArray(), $this->resultData['reached_points'], $this->resultData['max_points']);
         $this->resultData['ects_grade'] = $this->lng->txt('ects_grade_' . strtolower($ectsMark));
     }
 }
 public function getHTML()
 {
     $gui = new ilPersonalSkillsGUI();
     $gui->setGapAnalysisActualStatusModePerObject($this->testOBJ->getId(), $this->lng->txt('tst_test_result'));
     $gui->setProfileId($this->getSelectedSkillProfile());
     $html = $gui->getGapAnalysisHTML($this->getUsrId(), $this->getAvailableSkills());
     return $html;
 }
Exemplo n.º 6
0
 public function __construct(ilObjTest $testOBJ)
 {
     $this->testOBJ = $testOBJ;
     $templateId = $this->testOBJ->getTemplate();
     if ($templateId) {
         include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
         $this->settingsTemplate = new ilSettingsTemplate($templateId, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
     }
 }
 public function build()
 {
     $availablePools = $this->testOBJ->getAvailableQuestionpools(true, $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(), false, true, true);
     require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
     $poolSelection = new ilSelectInputGUI(null, 'quest_pool_id');
     $poolSelection->setOptions($this->buildSourcePoolSelectOptionsArray($availablePools));
     $this->addInputItem($poolSelection, true);
     $this->setFormAction($this->ctrl->getFormAction($this->questionSetConfigGUI));
     $this->addFormButton($this->lng->txt('tst_rnd_quest_set_tb_add_pool_btn'), ilTestRandomQuestionSetConfigGUI::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM);
 }
 private function transferAssignmentsFromOriginalToDuplicatedTaxonomy($originalTaxonomyId, $mappedTaxonomyId)
 {
     $originalTaxAssignment = new ilTaxNodeAssignment('qpl', $this->getSourcePoolId(), 'quest', $originalTaxonomyId);
     $duplicatedTaxAssignment = new ilTaxNodeAssignment('tst', $this->testOBJ->getId(), 'quest', $mappedTaxonomyId);
     foreach ($this->getQuestionIdMapping() as $originalQuestionId => $duplicatedQuestionId) {
         $assignments = $originalTaxAssignment->getAssignmentsOfItem($originalQuestionId);
         foreach ($assignments as $assData) {
             $mappedNodeId = $this->duplicatedTaxonomiesKeysMap->getMappedTaxNodeId($assData['node_id']);
             $duplicatedTaxAssignment->addAssignment($mappedNodeId, $duplicatedQuestionId);
         }
     }
 }
 /**
  * creates and returns an instance of a player gui
  * that corresponds to the current test mode
  * 
  * @return ilTestPlayerAbstractGUI
  */
 public function getPlayerGUI()
 {
     switch ($this->testOBJ->getQuestionSetType()) {
         case ilObjTest::QUESTION_SET_TYPE_FIXED:
         case ilObjTest::QUESTION_SET_TYPE_RANDOM:
             require_once 'Modules/Test/classes/class.ilTestOutputGUI.php';
             return new ilTestOutputGUI($this->testOBJ);
         case ilObjTest::QUESTION_SET_TYPE_DYNAMIC:
             require_once 'Modules/Test/classes/class.ilTestPlayerDynamicQuestionSetGUI.php';
             return new ilTestPlayerDynamicQuestionSetGUI($this->testOBJ);
     }
 }
 private function stageQuestionsFromSourcePool($sourcePoolId)
 {
     $questionIdMapping = array();
     $query = 'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL';
     $res = $this->db->queryF($query, array('integer', 'text'), array($sourcePoolId, 1));
     while ($row = $this->db->fetchAssoc($res)) {
         $question = assQuestion::_instanciateQuestion($row['question_id']);
         $duplicateId = $question->duplicate(true, null, null, null, $this->testOBJ->getId());
         $nextId = $this->db->nextId('tst_rnd_cpy');
         $this->db->insert('tst_rnd_cpy', array('copy_id' => array('integer', $nextId), 'tst_fi' => array('integer', $this->testOBJ->getTestId()), 'qst_fi' => array('integer', $duplicateId), 'qpl_fi' => array('integer', $sourcePoolId)));
         $questionIdMapping[$row['question_id']] = $duplicateId;
     }
     return $questionIdMapping;
 }
 public function prevQuestion()
 {
     $obj = new ilObjTest($_REQUEST['ref_id']);
     $questions = array_keys($obj->getQuestionTitlesAndIndexes());
     $pos = array_search($_REQUEST['q_id'], $questions);
     if ($pos !== false) {
         $next = $questions[$pos - 1];
     } else {
         $next = $questions[0];
     }
     $this->ctrl->setParameter($this, 'q_id', $next);
     $link = $this->ctrl->getLinkTarget($this, 'edit', '', '', false);
     ilUtil::redirect($link);
 }
 /**
  * Get all completed tests
  */
 protected function getItems()
 {
     global $ilUser;
     include_once "Modules/Test/classes/class.ilObjTest.php";
     $data = array();
     foreach (ilObjTest::_lookupFinishedUserTests($ilUser->getId()) as $test_id => $passed) {
         // #11210 - only available certificates!
         $test = new ilObjTest($test_id, false);
         $active_id = $test->getActiveIdOfUser($ilUser->getId());
         if ($test->canShowCertificate($ilUser->getId(), $active_id)) {
             $data[] = array("id" => $test_id, "title" => ilObject::_lookupTitle($test_id), "passed" => $passed);
         }
     }
     $this->setData($data);
 }
 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());
 }
Exemplo n.º 14
0
 private function areSkillLevelThresholdsMissing()
 {
     if ($this->object->isDynamicTest()) {
         $questionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
         $questionContainerId = $questionSetConfig->getSourceQuestionPoolId();
     } else {
         $questionContainerId = $this->object->getId();
     }
     global $ilDB;
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
     require_once 'Modules/Test/classes/class.ilTestSkillLevelThreshold.php';
     $assignmentList = new ilAssQuestionSkillAssignmentList($ilDB);
     $assignmentList->setParentObjId($questionContainerId);
     $assignmentList->loadFromDb();
     foreach ($assignmentList->getUniqueAssignedSkills() as $data) {
         foreach ($data['skill']->getLevelData() as $level) {
             $treshold = new ilTestSkillLevelThreshold($ilDB);
             $treshold->setTestId($this->object->getTestId());
             $treshold->setSkillBaseId($data['skill_base_id']);
             $treshold->setSkillTrefId($data['skill_tref_id']);
             $treshold->setSkillLevelId($level['id']);
             if (!$treshold->dbRecordExists()) {
                 return true;
             }
         }
     }
     return false;
 }
 private function handleConfigurationStateMessages($currentRequestCmd)
 {
     if (!$this->questionSetConfig->isQuestionAmountConfigComplete()) {
         $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_incomplete_quest_amount_cfg');
         if ($this->isQuestionAmountConfigPerTestHintRequired($currentRequestCmd)) {
             $infoMessage .= '<br />' . sprintf($this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'), $this->buildGeneralConfigSubTabLink());
         } elseif ($this->isQuestionAmountConfigPerPoolHintRequired($currentRequestCmd)) {
             $infoMessage .= '<br />' . sprintf($this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'), $this->buildQuestionSelectionSubTabLink());
         }
     } elseif (!$this->questionSetConfig->hasSourcePoolDefinitions()) {
         $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_no_src_pool_defs');
     } elseif (!$this->questionSetConfig->isQuestionSetBuildable()) {
         $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_pass_not_buildable');
     } else {
         $syncDate = new ilDateTime($this->questionSetConfig->getLastQuestionSyncTimestamp(), IL_CAL_UNIX);
         $infoMessage = sprintf($this->lng->txt('tst_msg_rand_quest_set_stage_pool_last_sync'), ilDatePresentation::formatDate($syncDate));
         if (!$this->testOBJ->participantDataExist()) {
             $infoMessage .= "<br />{$this->buildQuestionStageRebuildLink($currentRequestCmd)}";
         }
     }
     if ($this->isNoAvailableQuestionPoolsHintRequired($currentRequestCmd)) {
         $infoMessage .= '<br />' . $this->lng->txt('tst_msg_rand_quest_set_no_pools_available');
     }
     ilUtil::sendInfo($infoMessage);
 }
 private function buildSkillLevelThresholdList()
 {
     require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdList.php';
     $thresholdList = new ilTestSkillLevelThresholdList($this->db);
     $thresholdList->setTestId($this->testOBJ->getTestId());
     return $thresholdList;
 }
 /**
  * @return bool
  */
 public function savedDefinitionsExist()
 {
     $query = "SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
     $res = $this->db->queryF($query, array('integer'), array($this->testOBJ->getTestId()));
     $row = $this->db->fetchAssoc($res);
     return $row['cnt'] > 0;
 }
 /**
  * builds the question set config form and initialises the fields
  * with the config currently saved in database
  * 
  * @return ilPropertyFormGUI $form
  */
 private function buildForm()
 {
     $this->questionSetConfig->loadFromDb($this->testOBJ->getTestId());
     require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setId("tst_form_dynamic_question_set_config");
     $form->setTitle($this->lng->txt('tst_form_dynamic_question_set_config'));
     $form->setTableWidth("100%");
     $hiddenInputTaxSelectOptAsyncUrl = new ilHiddenInputGUI('taxSelectOptAsyncUrl');
     $hiddenInputTaxSelectOptAsyncUrl->setValue($this->ctrl->getLinkTarget($this, self::CMD_GET_TAXONOMY_OPTIONS_ASYNC, '', true));
     $form->addItem($hiddenInputTaxSelectOptAsyncUrl);
     if ($this->testOBJ->participantDataExist()) {
         $pool = new ilNonEditableValueGUI($this->lng->txt('tst_input_dynamic_question_set_source_questionpool'), 'source_qpl_title');
         $pool->setValue($this->questionSetConfig->getSourceQuestionPoolSummaryString($this->lng, $this->tree));
         $pool->setDisabled(true);
         $form->addItem($pool);
     } else {
         $poolInput = new ilSelectInputGUI($this->lng->txt('tst_input_dynamic_question_set_source_questionpool'), 'source_qpl_id');
         $poolInput->setOptions($this->buildQuestionPoolSelectInputOptionArray($this->testOBJ->getAvailableQuestionpools(true, false, false, true, true)));
         $poolInput->setValue($this->questionSetConfig->getSourceQuestionPoolId());
         $poolInput->setRequired(true);
         $form->addItem($poolInput);
     }
     $questionOderingInput = new ilRadioGroupInputGUI($this->lng->txt('tst_input_dynamic_question_set_question_ordering'), 'question_ordering');
     $questionOderingInput->setValue($this->questionSetConfig->getOrderingTaxonomyId() ? self::QUESTION_ORDERING_TYPE_TAXONOMY : self::QUESTION_ORDERING_TYPE_UPDATE_DATE);
     $optionOrderByDate = new ilRadioOption($this->lng->txt('tst_input_dynamic_question_set_question_ordering_by_date'), self::QUESTION_ORDERING_TYPE_UPDATE_DATE, $this->lng->txt('tst_inp_dyn_quest_set_quest_ordering_by_date_desc'));
     $questionOderingInput->addOption($optionOrderByDate);
     $optionOrderByTax = new ilRadioOption($this->lng->txt('tst_input_dynamic_question_set_question_ordering_by_tax'), self::QUESTION_ORDERING_TYPE_TAXONOMY, $this->lng->txt('tst_inp_dyn_quest_set_quest_ordering_by_tax_desc'));
     $orderTaxInput = new ilSelectInputGUI($this->lng->txt('tst_input_dynamic_question_set_ordering_tax'), 'ordering_tax');
     $orderTaxInput->setInfo($this->lng->txt('tst_input_dynamic_question_set_ordering_tax_description'));
     $orderTaxInput->setValue($this->questionSetConfig->getOrderingTaxonomyId());
     $orderTaxInput->setRequired(true);
     $orderTaxInput->setOptions($this->buildTaxonomySelectInputOptionArray($this->questionSetConfig->getSourceQuestionPoolId()));
     $optionOrderByTax->addSubItem($orderTaxInput);
     $questionOderingInput->addOption($optionOrderByTax);
     $form->addItem($questionOderingInput);
     $taxFilterInput = new ilCheckboxInputGUI($this->lng->txt('tst_input_dynamic_question_set_taxonomie_filter_enabled'), 'tax_filter_enabled');
     $taxFilterInput->setValue(1);
     $taxFilterInput->setChecked($this->questionSetConfig->isTaxonomyFilterEnabled());
     $form->addItem($taxFilterInput);
     $answStatusFilterInput = new ilCheckboxInputGUI($this->lng->txt('tst_input_dyn_quest_set_answer_status_filter_enabled'), 'answer_status_filter_enabled');
     $answStatusFilterInput->setValue(1);
     $answStatusFilterInput->setChecked($this->questionSetConfig->isAnswerStatusFilterEnabled());
     $form->addItem($answStatusFilterInput);
     $previousQuestionsListInput = new ilCheckboxInputGUI($this->lng->txt('tst_input_dyn_quest_set_prev_quest_list_enabled'), 'prev_quest_list_enabled');
     $previousQuestionsListInput->setValue(1);
     $previousQuestionsListInput->setChecked($this->questionSetConfig->isPreviousQuestionsListEnabled());
     $form->addItem($previousQuestionsListInput);
     if ($this->testOBJ->participantDataExist()) {
         $questionOderingInput->setDisabled(true);
         $taxFilterInput->setDisabled(true);
         $answStatusFilterInput->setDisabled(true);
         $previousQuestionsListInput->setDisabled(true);
     } else {
         $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
     }
     return $form;
 }
 /**
  * Get all completed tests
  */
 protected function getItems()
 {
     global $ilUser;
     include_once "Modules/Test/classes/class.ilObjTest.php";
     include_once "Modules/Test/classes/class.ilTestSessionFactory.php";
     $data = array();
     foreach (ilObjTest::getTestObjIdsWithActiveForUserId($ilUser->getId()) as $test_id) {
         // #11210 - only available certificates!
         $test = new ilObjTest($test_id, false);
         $session = new ilTestSessionFactory($test);
         $session = $session->getSession(null);
         if ($test->canShowCertificate($session, $session->getUserId(), $session->getActiveId())) {
             $data[] = array("id" => $test_id, "title" => $test->getTitle(), "passed" => $test->getPassed($session->getActiveId()));
         }
     }
     $this->setData($data);
 }
 private function getAvailableTaxonomyIds()
 {
     if ($this->getAvailableTaxonomyIds === null) {
         require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
         $this->availableTaxonomyIds = (array) ilObjTaxonomy::getUsageOfObject($this->testOBJ->getId());
     }
     return $this->availableTaxonomyIds;
 }
 private function buildHeaderText()
 {
     $headerText = sprintf($this->lng->txt('tst_change_quest_set_type_from_old_to_new_with_conflict'), $this->testOBJ->getQuestionSetTypeTranslation($this->lng, $this->getOldQuestionSetType()), $this->testOBJ->getQuestionSetTypeTranslation($this->lng, $this->getNewQuestionSetType()));
     if ($this->isQuestionLossInfoEnabled()) {
         $headerText .= '<br /><br />' . $this->lng->txt('tst_nonpool_questions_get_lost_warning');
     }
     return $headerText;
 }
 public function saveToDb()
 {
     if ($this->getId()) {
         $this->updateDbRecord($this->testOBJ->getTestId());
     } else {
         $this->insertDbRecord($this->testOBJ->getTestId());
     }
 }
 public function prevQuestion()
 {
     $obj = new ilObjTest($_REQUEST['ref_id']);
     $questions = array_keys($obj->getQuestionTitlesAndIndexes());
     $pos = array_search($_REQUEST['q_id'], $questions);
     if ($pos == 0) {
         ilUtil::sendInfo('test_express_start_reached_moved_to_last', true);
         $next = $questions[count($questions) - 1];
     } elseif ($pos !== false) {
         $next = $questions[$pos - 1];
     } else {
         $next = $questions[0];
     }
     $this->ctrl->setParameter($this, 'q_id', $next);
     $link = $this->ctrl->getLinkTarget($this, 'edit', '', '', false);
     ilUtil::redirect($link);
 }
 private function isTestQuestion($questionId)
 {
     foreach ($this->testOBJ->getTestQuestions() as $question) {
         if ($question['question_id'] == $questionId) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 25
0
 /**
  * @return string HTML with the best solution output.
  */
 public function calculateBestSolutionForTest()
 {
     $solution = '';
     foreach ($this->test->getAllQuestions() as $question) {
         /** @var AssQuestionGUI $question_gui */
         $question_gui = $this->test->createQuestionGUI("", $question['question_id']);
         $solution .= $question_gui->getSolutionOutput(0, null, true, true, false, false, true, false);
     }
     return $solution;
 }
 private function getSourcePoolDefinitionByAvailableQuestionPoolId($poolId)
 {
     $availablePools = $this->testOBJ->getAvailableQuestionpools(true, $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(), false, true, true);
     if (isset($availablePools[$poolId])) {
         $originalPoolData = $availablePools[$poolId];
         $originalPoolData['qpl_path'] = $this->questionSetConfig->getQuestionPoolPathString($poolId);
         return $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
     }
     require_once 'Modules/Test/exceptions/class.ilTestQuestionPoolNotAvailableAsSourcePoolException.php';
     throw new ilTestQuestionPoolNotAvailableAsSourcePoolException();
 }
 /**
  * removes all question set config related data for cloned/copied test
  *
  * @param ilObjTest $cloneTestOBJ
  */
 public function cloneQuestionSetRelatedData($cloneTestOBJ)
 {
     global $ilLog;
     require_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
     $cwo = ilCopyWizardOptions::_getInstance($cloneTestOBJ->getId());
     foreach ($this->questions as $key => $question_id) {
         $question = assQuestion::_instanciateQuestion($question_id);
         $cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId());
         $original_id = assQuestion::_getOriginalId($question_id);
         $question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]);
         $question->saveToDb($original_id);
         // Save the mapping of old question id <-> new question id
         // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
         $originalKey = $this->testOBJ->getRefId() . '_' . $question_id;
         $mappedKey = $cloneTestOBJ->getRefId() . '_' . $cloneTestOBJ->questions[$key];
         $cwo->appendMapping($originalKey, $mappedKey);
         $ilLog->write(__METHOD__ . ": Added mapping {$originalKey} <-> {$mappedKey}");
     }
 }
 protected function fetchQuestionsFromStageRandomly($questionStage, $requiredQuestionAmount)
 {
     $randomKeys = $this->getRandomArrayKeys($questionStage, $requiredQuestionAmount);
     $questionSet = array();
     foreach ($randomKeys as $randomKey) {
         $questionSet[] = $questionStage[$randomKey];
     }
     if ($this->testOBJ->getShuffleQuestions()) {
         shuffle($questionSet);
     }
     return $questionSet;
 }
 /**
  * Import relevant properties from given test
  *
  * @param ilObjTest $a_test
  * @return object
  */
 public static function createFromTest(ilObjTest $a_test, $a_user_id)
 {
     global $lng;
     $lng->loadLanguageModule("wsp");
     $newObj = new self();
     $newObj->setTitle($lng->txt("wsp_type_tstv") . " \"" . $a_test->getTitle() . "\"");
     $newObj->setDescription($a_test->getDescription());
     $active_id = $a_test->getActiveIdOfUser($a_user_id);
     $pass = ilObjTest::_getResultPass($active_id);
     $date = $a_test->getPassFinishDate($active_id, $pass);
     $newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX));
     // create certificate
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php";
     $certificate = new ilCertificate(new ilTestCertificateAdapter($a_test));
     $certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false);
     // save pdf file
     if ($certificate) {
         // we need the object id for storing the certificate file
         $newObj->create();
         $path = self::initStorage($newObj->getId(), "certificate");
         $file_name = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf";
         if (file_put_contents($path . $file_name, $certificate)) {
             $newObj->setProperty("file", $file_name);
             $newObj->update();
             return $newObj;
         }
         // file creation failed, so remove to object, too
         $newObj->delete();
     }
 }
 /**
  * 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;
 }