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); }
/** * 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; }
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(); }
/** * Called when a new question should be created from a test * Important: $cmd may be overwritten if no question pool is available * * @access public */ function createQuestionpoolTargetObject($cmd) { global $ilUser, $ilTabs; $this->getQuestionsSubTabs(); $ilTabs->activateSubTab('edit_test_questions'); $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test"); $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write"); if (count($questionpools) == 0) { $this->tpl->setCurrentBlock("option"); $this->tpl->setVariable("VALUE_QPL", ""); $this->tpl->parseCurrentBlock(); } else { foreach ($questionpools as $key => $value) { $this->tpl->setCurrentBlock("option"); $this->tpl->setVariable("VALUE_OPTION", $key); $this->tpl->setVariable("TEXT_OPTION", $value["title"]); $this->tpl->parseCurrentBlock(); } } if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) { foreach ($_REQUEST['q_id'] as $id) { $this->tpl->setCurrentBlock("hidden"); $this->tpl->setVariable("HIDDEN_NAME", "q_id[]"); $this->tpl->setVariable("HIDDEN_VALUE", $id); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("adm_content"); } } $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this)); if (count($questionpools) == 0) { $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool")); $cmd = 'createQuestionPoolAndCopy'; } else { $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool")); } $this->tpl->setVariable("CMD_SUBMIT", $cmd); $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit")); $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel")); $createForm = $this->getQuestionpoolCreationForm(); switch ($cmd) { case 'copyAndLinkQuestionsToPool': $hidden = new ilHiddenInputGUI('link'); $hidden->setValue(1); $createForm->addItem($hidden); break; case 'copyQuestionsToPool': break; } $createForm->setFormAction($this->ctrl->getFormAction($this)); $this->tpl->parseCurrentBlock(); }