/**
  * 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");
     }
 }
 /**
  * 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");
 }
 /**
 * 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);
 }
 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");
 }