private function build(ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList) { $involvedSourcePoolIds = $sourcePoolDefinitionList->getInvolvedSourcePoolIds(); foreach ($involvedSourcePoolIds as $sourcePoolId) { $questionIdMapping = $this->stageQuestionsFromSourcePool($sourcePoolId); $taxonomiesKeysMap = $this->mirrorSourcePoolTaxonomies($sourcePoolId, $questionIdMapping); $this->applyMappedTaxonomiesKeys($sourcePoolDefinitionList, $taxonomiesKeysMap, $sourcePoolId); } }
private function saveEditSourcePoolDefinitionFormCmd() { $this->questionSetConfig->loadFromDb(); $defId = $this->fetchSingleSourcePoolDefinitionIdParameter(); $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId); $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId()); $form = $this->buildEditSourcePoolDefinitionFormGUI(); $form->build($sourcePoolDefinition, $availableTaxonomyIds); $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost() $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput() if ($errors) { return $this->showSourcePoolDefinitionListCmd($form); } $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds); $sourcePoolDefinition->saveToDb(); $this->sourcePoolDefinitionList->loadDefinitions(); $this->stagingPool->rebuild($this->sourcePoolDefinitionList); $this->questionSetConfig->setLastQuestionSyncTimestamp(time()); $this->questionSetConfig->saveToDb(); $this->sourcePoolDefinitionList->saveDefinitions(); $this->testOBJ->saveCompleteStatus($this->questionSetConfig); ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_config_modified"), true); $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST); }
/** * Returns the number of questions in the test * * @return integer The number of questions * @access public */ function getQuestionCount() { $num = 0; if ($this->isRandomTest()) { global $tree, $ilDB, $ilPluginAdmin; $questionSetConfig = new ilTestRandomQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this); $questionSetConfig->loadFromDb(); if ($questionSetConfig->isQuestionAmountConfigurationModePerPool()) { require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php'; require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilderWithAmountPerPool.php'; require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php'; $sourcePoolDefinitionList = new ilTestRandomQuestionSetSourcePoolDefinitionList($ilDB, $this, new ilTestRandomQuestionSetSourcePoolDefinitionFactory($ilDB, $this)); $sourcePoolDefinitionList->loadDefinitions(); $num = $sourcePoolDefinitionList->getQuestionAmount(); } else { $num = $questionSetConfig->getQuestionAmountPerTest(); } } else { $num = count($this->questions); } return $num; }
/** * Parse test * throws ilLOInvalidConfigurationException in case assigned test cannot be found. */ public function parse($a_tst_ref_id) { include_once './Modules/Test/classes/class.ilObjTest.php'; $tst = ilObjectFactory::getInstanceByRefId($a_tst_ref_id, false); if (!$tst instanceof ilObjTest) { throw new ilLOInvalidConfigurationException('No valid test given'); } $tst_data['ref_id'] = $tst->getRefId(); $tst_data['title'] = $tst->getTitle(); $tst_data['description'] = $tst->getLongDescription(); $tst_data['ttype'] = $tst->getQuestionSetType(); switch ($tst->getQuestionSetType()) { case ilObjTest::QUESTION_SET_TYPE_FIXED: $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_num_qst'); $tst_data['qst_info'] .= ' ' . count($tst->getAllQuestions()); break; default: // get available assiged question pools include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php'; include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php'; $list = new ilTestRandomQuestionSetSourcePoolDefinitionList($GLOBALS['ilDB'], $tst, new ilTestRandomQuestionSetSourcePoolDefinitionFactory($GLOBALS['ilDB'], $tst)); $list->loadDefinitions(); // tax translations include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php'; $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']); $translater->loadLabels($list); $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_qpls'); $num = 0; foreach ($list as $definition) { /** @var ilTestRandomQuestionSetSourcePoolDefinition[] $definition */ $title = $definition->getPoolTitle(); $tax_id = $definition->getMappedFilterTaxId(); if ($tax_id) { $title .= ' -> ' . $translater->getTaxonomyTreeLabel($tax_id); } $tax_node = $definition->getMappedFilterTaxNodeId(); if ($tax_node) { $title .= ' -> ' . $translater->getTaxonomyNodeLabel($tax_node); } $tst_data['qpls'][] = $title; ++$num; } if (!$num) { $tst_data['qst_info'] .= ' ' . (int) 0; } break; } $this->setData(array($tst_data)); }
protected function generateRandomTestPassForActiveUser() { global $tree, $ilDB, $ilPluginAdmin; require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfig.php'; $questionSetConfig = new ilTestRandomQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this->object); $questionSetConfig->loadFromDb(); require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php'; $sourcePoolDefinitionFactory = new ilTestRandomQuestionSetSourcePoolDefinitionFactory($ilDB, $this->object); require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php'; $sourcePoolDefinitionList = new ilTestRandomQuestionSetSourcePoolDefinitionList($ilDB, $this->object, $sourcePoolDefinitionFactory); $sourcePoolDefinitionList->loadDefinitions(); $this->processLocker->requestRandomPassBuildLock($sourcePoolDefinitionList->hasTaxonomyFilters()); if (!$this->performTearsAndAngerBrokenConfessionChecks()) { require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetStagingPoolQuestionList.php'; $stagingPoolQuestionList = new ilTestRandomQuestionSetStagingPoolQuestionList($ilDB, $ilPluginAdmin); require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilder.php'; $questionSetBuilder = ilTestRandomQuestionSetBuilder::getInstance($ilDB, $this->object, $questionSetConfig, $sourcePoolDefinitionList, $stagingPoolQuestionList); $questionSetBuilder->performBuild($this->testSession); } $this->processLocker->releaseRandomPassBuildLock(); }
/** * Lookup assigned qpl name (including taxonomy) by sequence * @param type $a_test_ref_id * @param type $a_sequence_id * @return string */ public static function lookupQplBySequence($a_test_ref_id, $a_sequence_id) { if (!$a_sequence_id) { return ''; } $tst = ilObjectFactory::getInstanceByRefId($a_test_ref_id, false); if (!$tst instanceof ilObjTest) { return ''; } include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php'; include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php'; $list = new ilTestRandomQuestionSetSourcePoolDefinitionList($GLOBALS['ilDB'], $tst, new ilTestRandomQuestionSetSourcePoolDefinitionFactory($GLOBALS['ilDB'], $tst)); $list->loadDefinitions(); include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php'; $translator = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']); $translator->loadLabels($list); $title = ''; foreach ($list as $definition) { if ($definition->getId() != $a_sequence_id) { continue; } $title = self::buildQplTitleByDefinition($definition, $translator); } return $title; }
protected function getRandomTestQplOptions() { include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php'; include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php'; $tst_ref_id = $this->getSettings()->getTestByType($this->test_type); if ($tst_ref_id) { $tst = ilObjectFactory::getInstanceByRefId($tst_ref_id, false); } if (!$tst instanceof ilObjTest) { return array(); } $list = new ilTestRandomQuestionSetSourcePoolDefinitionList($GLOBALS['ilDB'], $tst, new ilTestRandomQuestionSetSourcePoolDefinitionFactory($GLOBALS['ilDB'], $tst)); $list->loadDefinitions(); include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php'; $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']); $translater->loadLabels($list); $options[0] = $this->lng->txt('select_one'); foreach ($list as $definition) { $title = $definition->getPoolTitle(); $tax_id = $definition->getMappedFilterTaxId(); if ($tax_id) { $title .= ' -> ' . $translater->getTaxonomyTreeLabel($tax_id); } $tax_node = $definition->getMappedFilterTaxNodeId(); if ($tax_node) { $title .= ' -> ' . $translater->getTaxonomyNodeLabel($tax_node); } $options[$definition->getId()] = $title; } return $options; }