/** * edit question */ function edit() { global $ilCtrl, $ilTabs; $ilTabs->setTabActive('question'); if ($this->getSelfAssessmentMode()) { $q_ref = $this->content_obj->getQuestionReference(); if ($q_ref != "") { $inst_id = ilInternalLink::_extractInstOfTarget($q_ref); if (!($inst_id > 0)) { $q_id = ilInternalLink::_extractObjIdOfTarget($q_ref); } } $q_type = $_POST["q_type"] != "" ? $_POST["q_type"] : $_GET["q_type"]; $ilCtrl->setParameter($this, "q_type", $q_type); if ($q_id == "" && $q_type == "") { return $this->insert("edit_empty"); } include_once "./Modules/TestQuestionPool/classes/class.ilQuestionEditGUI.php"; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php"; /* $ilCtrl->setCmdClass("ilquestioneditgui"); $ilCtrl->setCmd("editQuestion"); $edit_gui = new ilQuestionEditGUI();*/ // create question first-hand (needed for uploads) if ($q_id < 1 && $q_type) { include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php"; $q_gui =& assQuestionGUI::_getQuestionGUI($q_type); // feedback editing mode include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled() && $_REQUEST['add_quest_cont_edit_mode'] != "") { $addContEditMode = $_GET['add_quest_cont_edit_mode']; } else { $addContEditMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT; } $q_gui->object->setAdditionalContentEditingMode($addContEditMode); //set default tries $q_gui->object->setDefaultNrOfTries(ilObjSAHSLearningModule::_getTries($this->scormlmid)); $q_id = $q_gui->object->createNewQuestion(true); $this->content_obj->setQuestionReference("il__qst_" . $q_id); $this->pg_obj->update(); unset($q_gui); } $ilCtrl->setParameterByClass("ilQuestionEditGUI", "q_id", $q_id); $ilCtrl->redirectByClass(array(get_class($this->pg_obj) . "GUI", "ilQuestionEditGUI"), "editQuestion"); /* $edit_gui->setPoolObjId(0); $edit_gui->setQuestionId($q_id); $edit_gui->setQuestionType($q_type); $edit_gui->setSelfAssessmentEditingMode(true); $edit_gui->setPageConfig($this->getPageConfig()); $ret = $ilCtrl->forwardCommand($edit_gui); $this->tpl->setContent($ret);*/ return $ret; } else { require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php"; $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]); $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($q_gui)), "editQuestion"); } }
public function addQuestion() { global $lng, $ilCtrl, $tpl; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']); $form = new ilPropertyFormGUI(); $ilCtrl->setParameter($this, 'test_express_mode', 1); $form->setFormAction($ilCtrl->getFormAction($this, "handleToolbarCommand")); $form->setTitle($lng->txt("ass_create_question")); include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php'; $pool = new ilObjQuestionPool(); $questionTypes = $pool->getQuestionTypes(false, true); $options = array(); // question type foreach ($questionTypes as $label => $data) { $options[$data['question_type_id']] = $label; } include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype"); $si->setOptions($options); $form->addItem($si, true); // position $questions = $this->test_object->getQuestionTitlesAndIndexes(); if ($questions) { $si = new ilSelectInputGUI($lng->txt("position"), "position"); $options = array('0' => $lng->txt('first')); foreach ($questions as $key => $title) { $options[$key] = $lng->txt('behind') . ' ' . $title . ' [' . $this->lng->txt('question_id_short') . ': ' . $key . ']'; } $si->setOptions($options); $si->setValue($_REQUEST['q_id']); $form->addItem($si, true); } // content editing mode if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled()) { $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode"); $ri->addOption(new ilRadioOption($lng->txt('tst_add_quest_cont_edit_mode_default'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT)); $ri->addOption(new ilRadioOption($lng->txt('tst_add_quest_cont_edit_mode_page_object'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT)); $ri->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $form->addItem($ri, true); } else { $hi = new ilHiddenInputGUI("question_content_editing_type"); $hi->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $form->addItem($hi, true); } if ($this->test_object->getPoolUsage()) { // use pool $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage"); $usage->setRequired(true); $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1); $usage->addOption($no_pool); $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3); $usage->addOption($existing_pool); $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2); $usage->addOption($new_pool); $form->addItem($usage); $usage->setValue(1); $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write"); $pools_data = array(); foreach ($questionpools as $key => $p) { $pools_data[$key] = $p['title']; } $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl"); $pools->setOptions($pools_data); $existing_pool->addSubItem($pools); $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl"); $name->setSize(50); $name->setMaxLength(50); $new_pool->addSubItem($name); } $form->addCommandButton("handleToolbarCommand", $lng->txt("submit")); $form->addCommandButton("questions", $lng->txt("cancel")); return $tpl->setContent($form->getHTML()); }
private function buildCreateQuestionForm() { global $ilUser; // form require_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setTitle($this->lng->txt('ass_create_question')); $form->setFormAction($this->ctrl->getFormAction($this)); // question type $options = array(); foreach ($this->object->getQuestionTypes(false, true) as $translation => $data) { $options[$data['type_tag']] = $translation; } require_once "Services/Form/classes/class.ilSelectInputGUI.php"; $si = new ilSelectInputGUI($this->lng->txt('question_type'), 'sel_question_types'); $si->setOptions($options); //$si->setValue($ilUser->getPref("tst_lastquestiontype")); $form->addItem($si); // content editing mode if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled()) { $ri = new ilRadioGroupInputGUI($this->lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode"); $ri->addOption(new ilRadioOption($this->lng->txt('tst_add_quest_cont_edit_mode_default'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT)); $ri->addOption(new ilRadioOption($this->lng->txt('tst_add_quest_cont_edit_mode_page_object'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT)); $ri->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $form->addItem($ri, true); } else { $hi = new ilHiddenInputGUI("question_content_editing_type"); $hi->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $form->addItem($hi, true); } // commands $form->addCommandButton('createQuestion', $this->lng->txt('create')); $form->addCommandButton('questions', $this->lng->txt('cancel')); return $form; }
/** * Called when a new question should be created from a test * * Called when a new question should be created from a test * * @access public */ function createQuestionObject() { global $ilUser; $this->getQuestionsSubTabs(); //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test"); $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write"); if ($this->object->getPoolUsage()) { global $lng, $ilCtrl, $tpl; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion")); $form->setTitle($lng->txt("ass_create_question")); include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php'; $hidden = new ilHiddenInputGUI('sel_question_types'); $hidden->setValue($_REQUEST["sel_question_types"]); $form->addItem($hidden); // content editing mode if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled()) { $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode"); $ri->addOption(new ilRadioOption($lng->txt('tst_add_quest_cont_edit_mode_default'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT)); $ri->addOption(new ilRadioOption($lng->txt('tst_add_quest_cont_edit_mode_page_object'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT)); $ri->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $form->addItem($ri, true); } else { $hi = new ilHiddenInputGUI("question_content_editing_type"); $hi->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $form->addItem($hi, true); } // use pool $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage"); $usage->setRequired(true); $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1); $usage->addOption($no_pool); $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3); $usage->addOption($existing_pool); $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2); $usage->addOption($new_pool); $form->addItem($usage); $usage->setValue(1); $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write"); $pools_data = array(); foreach ($questionpools as $key => $p) { $pools_data[$key] = $p['title']; } $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl"); $pools->setOptions($pools_data); $existing_pool->addSubItem($pools); $this->lng->loadLanguageModule('rbac'); $name = new ilTextInputGUI($this->lng->txt("rbac_create_qpl"), "txt_qpl"); $name->setSize(50); $name->setMaxLength(50); $new_pool->addSubItem($name); $form->addCommandButton("executeCreateQuestion", $lng->txt("submit")); $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel")); return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML()); } else { global $ilCtrl; $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]); $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand', '', false, false); ilUtil::redirect($link); } }