/** * Returns a question gui object to a given questiontype and question id * * @result object Resulting question gui object * @access public */ function getQuestionGUI($questiontype, $question_id) { include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php"; return SurveyQuestionGUI::_getQuestionGUI($questiontype, $question_id); }
/** * Call add question to survey form * * @param int $a_type question type * @param bool $a_use_pool add question to pool * @param int $a_pos target position * @param string $a_special_position special positions (toolbar | page_end) */ protected function addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position) { global $ilCtrl; // get translated type include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $questiontypes = ilObjSurveyQuestionPool::_getQuestiontypes(); foreach ($questiontypes as $item) { if ($item["questiontype_id"] == $a_type) { $type_trans = $item["type_tag"]; } } $id = $a_pos; // new page behind current (from toolbar) if ($a_special_position == "toolbar") { $id = $this->object->getSurveyPages(); if ($a_pos && $a_pos != "fst") { $id = $id[$a_pos - 1]; $id = array_pop($id); $id = $id["question_id"] . "c"; } else { $id = "0c"; } } else { if ($a_special_position == "page_end") { $id = $this->object->getSurveyPages(); $id = $id[$this->current_page - 1]; $id = array_pop($id); $id = $id["question_id"] . "a"; } else { $id .= "b"; } } if ($a_use_pool) { $_GET["sel_question_types"] = $type_trans; $_REQUEST["pgov_pos"] = $id; $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $id); if (!$_POST["usage"]) { $this->editor_gui->createQuestionObject(); } else { $this->editor_gui->executeCreateQuestionObject(); } return true; } else { // create question and redirect to question form include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php"; $q_gui = SurveyQuestionGUI::_getQuestionGUI($type_trans); $q_gui->object->setObjId($this->object->getId()); $q_gui->object->createNewQuestion(); $q_gui_class = get_class($q_gui); $this->ctrl->setParameterByClass($q_gui_class, "pgov", $this->current_page); $this->ctrl->setParameterByClass($q_gui_class, "pgov_pos", $id); $this->ctrl->setParameterByClass($q_gui_class, "ref_id", $this->ref_id); $this->ctrl->setParameterByClass($q_gui_class, "new_for_survey", $this->ref_id); $this->ctrl->setParameterByClass($q_gui_class, "q_id", $q_gui->object->getId()); $this->ctrl->setParameterByClass($q_gui_class, "sel_question_types", $q_gui->getQuestionType()); $this->ctrl->redirectByClass($q_gui_class, "editQuestion"); } }
function _getGUIClassNameForId($a_q_id) { include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php"; $q_type = SurveyQuestion::_getQuestiontype($a_q_id); $class_name = SurveyQuestionGUI::_getClassNameForQType($q_type); return $class_name; }
/** * create preview of object */ public function &previewObject() { include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php"; $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]); $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType()); $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]); $this->ctrl->redirectByClass(get_class($q_gui), "preview"); }
/** * fill row * * @access public * @param * @return */ public function fillRow($data) { global $ilUser, $ilAccess; include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php"; $class = strtolower(SurveyQuestionGUI::_getGUIClassNameForId($data["question_id"])); $guiclass = $class . "GUI"; $this->ctrl->setParameterByClass(strtolower($guiclass), "q_id", $data["question_id"]); if ($this->getEditable()) { $url_edit = $this->ctrl->getLinkTargetByClass(strtolower($guiclass), "editQuestion"); $this->tpl->setCurrentBlock("title_link_bl"); $this->tpl->setVariable("QUESTION_TITLE_LINK", $data["title"]); $this->tpl->setVariable("URL_TITLE", $url_edit); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("title_nolink_bl"); $this->tpl->setVariable("QUESTION_TITLE", $data["title"]); $this->tpl->parseCurrentBlock(); } if ($data["complete"] == 0) { $this->tpl->setCurrentBlock("qpl_warning"); $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("icon_alert.svg")); $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete")); $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete")); $this->tpl->parseCurrentBlock(); } foreach ($this->getSelectedColumns() as $c) { if (strcmp($c, 'description') == 0) { $this->tpl->setCurrentBlock('description'); $this->tpl->setVariable("QUESTION_COMMENT", strlen($data["description"]) ? $data["description"] : " "); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'type') == 0) { $this->tpl->setCurrentBlock('type'); $this->tpl->setVariable("QUESTION_TYPE", SurveyQuestion::_getQuestionTypeName($data["type_tag"])); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'author') == 0) { $this->tpl->setCurrentBlock('author'); $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'created') == 0) { $this->tpl->setCurrentBlock('created'); $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'], IL_CAL_UNIX))); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'updated') == 0) { $this->tpl->setCurrentBlock('updated'); $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"], IL_CAL_UNIX))); $this->tpl->parseCurrentBlock(); } } // actions include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; $list = new ilAdvancedSelectionListGUI(); $list->setId($data["question_id"]); $list->setListTitle($this->lng->txt("actions")); if ($url_edit) { $list->addItem($this->lng->txt("edit"), "", $url_edit); } $list->addItem($this->lng->txt("preview"), "", $this->ctrl->getLinkTargetByClass(strtolower($guiclass), "preview")); $this->tpl->setVariable("ACTION", $list->getHTML()); $this->tpl->parseCurrentBlock(); // obligatory if ($this->getEditable()) { $checked = $data["obligatory"] ? " checked=\"checked\"" : ""; $obligatory = "<input type=\"checkbox\" name=\"obligatory_" . $data["question_id"] . "\" value=\"1\"" . $checked . " />"; } else { if ($data["obligatory"]) { $obligatory = "<img src=\"" . ilUtil::getImagePath("obligatory.png", "Modules/Survey") . "\" alt=\"" . $this->lng->txt("question_obligatory") . "\" title=\"" . $this->lng->txt("question_obligatory") . "\" />"; } } $this->tpl->setVariable("OBLIGATORY", $obligatory); if ($this->getWriteAccess()) { $this->tpl->setVariable('CBOX_ID', $data["question_id"]); } $this->tpl->setVariable('QUESTION_ID', $data["question_id"]); }
function executeCreateQuestionObject() { $_SESSION["svy_qpool_choice"] = $_POST["usage"]; $q_type = $_GET["sel_question_types"]; // no pool if ($_POST["usage"] == 1) { $ref_id = $this->object->getRefId(); } else { if ($_POST["usage"] == 3 && strlen($_POST["sel_spl"])) { $ref_id = $_POST["sel_spl"]; } elseif ($_POST["usage"] == 2 && strlen($_POST["name_spl"])) { $ref_id = $this->createQuestionPool($_POST["name_spl"]); } else { if (!$_POST["usage"]) { ilUtil::sendFailure($this->lng->txt("select_one"), true); } else { ilUtil::sendFailure($this->lng->txt("err_no_pool_name"), true); } $this->ctrl->setParameter($this, "sel_question_types", $q_type); $this->ctrl->redirect($this, "createQuestion"); } } // create question and redirect to question form include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php"; $q_gui = SurveyQuestionGUI::_getQuestionGUI($q_type); $q_gui->object->setObjId($this->object->getId()); $q_gui->object->createNewQuestion(); $q_gui_class = get_class($q_gui); if ($_REQUEST["pgov"]) { $this->ctrl->setParameterByClass($q_gui_class, "pgov", $_REQUEST["pgov"]); $this->ctrl->setParameterByClass($q_gui_class, "pgov_pos", $_REQUEST["pgov_pos"]); } $this->ctrl->setParameterByClass($q_gui_class, "ref_id", $ref_id); $this->ctrl->setParameterByClass($q_gui_class, "new_for_survey", $this->object->getRefId()); $this->ctrl->setParameterByClass($q_gui_class, "q_id", $q_gui->object->getId()); $this->ctrl->setParameterByClass($q_gui_class, "sel_question_types", $q_gui->getQuestionType()); $this->ctrl->redirectByClass($q_gui_class, "editQuestion"); }
/** * fill row * * @access public * @param * @return */ public function fillRow($data) { global $ilUser, $ilAccess; include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php"; $class = strtolower(SurveyQuestionGUI::_getGUIClassNameForId($data["question_id"])); $guiclass = $class . "GUI"; $this->ctrl->setParameterByClass(strtolower($guiclass), "q_id", $data["question_id"]); if ($this->getEditable()) { $this->tpl->setCurrentBlock("edit_link"); $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit")); $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTargetByClass(strtolower($guiclass), "editQuestion")); $this->tpl->parseCurrentBlock(); } if ($data["complete"] == 0) { $this->tpl->setCurrentBlock("qpl_warning"); $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.png")); $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete")); $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete")); $this->tpl->parseCurrentBlock(); } foreach ($this->getSelectedColumns() as $c) { if (strcmp($c, 'description') == 0) { $this->tpl->setCurrentBlock('description'); $this->tpl->setVariable("QUESTION_COMMENT", strlen($data["description"]) ? $data["description"] : " "); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'type') == 0) { $this->tpl->setCurrentBlock('type'); $this->tpl->setVariable("QUESTION_TYPE", SurveyQuestion::_getQuestionTypeName($data["type_tag"])); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'author') == 0) { $this->tpl->setCurrentBlock('author'); $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'created') == 0) { $this->tpl->setCurrentBlock('created'); $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'], IL_CAL_UNIX))); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'updated') == 0) { $this->tpl->setCurrentBlock('updated'); $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data["tstamp"], IL_CAL_UNIX))); $this->tpl->parseCurrentBlock(); } } $this->tpl->setVariable('QUESTION_ID', $data["question_id"]); $this->tpl->setVariable("QUESTION_TITLE", $data["title"]); $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt("preview")); $this->tpl->setVariable("LINK_PREVIEW", $this->ctrl->getLinkTargetByClass(strtolower($guiclass), "preview")); }