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;
 }
 /**
  * list questions of question pool
  */
 function questionsObject($arrFilter = null)
 {
     global $rbacsystem;
     global $ilUser;
     if (get_class($this->object) == "ilObjTest") {
         if ($_GET["calling_test"] > 0) {
             $ref_id = $_GET["calling_test"];
             $q_id = $_GET["q_id"];
             if ($_REQUEST['test_express_mode']) {
                 if ($q_id) {
                     ilUtil::redirect("ilias.php?ref_id=" . $ref_id . "&q_id=" . $q_id . "&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
                 } else {
                     ilUtil::redirect("ilias.php?ref_id=" . $ref_id . "&test_express_mode=1&cmd=showPage&cmdClass=iltestexpresspageobjectgui&baseClass=ilObjTestGUI");
                 }
             } else {
                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=" . $ref_id . "&cmd=questions");
             }
         }
     }
     $this->object->purgeQuestions();
     // reset test_id SESSION variable
     $_SESSION["test_id"] = "";
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_qpl_questionbrowser.html", "Modules/TestQuestionPool");
     include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
     $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', $rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false);
     $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
     $arrFilter = array();
     foreach ($table_gui->getFilterItems() as $item) {
         if ($item->getValue() !== false) {
             $arrFilter[$item->getPostVar()] = $item->getValue();
         }
     }
     $data = $this->object->getQuestionBrowserData($arrFilter);
     $table_gui->setData($data);
     $this->tpl->setVariable('TABLE', $table_gui->getHTML());
     if ($rbacsystem->checkAccess('write', $_GET['ref_id'])) {
         $this->tpl->setCurrentBlock("QTypes");
         $types =& $this->object->getQuestionTypes(false, true);
         $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
         foreach ($types as $translation => $data) {
             if ($data["type_tag"] == $lastquestiontype) {
                 $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
             }
             $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
             $this->tpl->setVariable("QUESTION_TYPE", $translation);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, 'questions'));
         $this->tpl->parseCurrentBlock();
     }
 }
 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());
 }