/**
  * Creates a confirmation form to delete questions from the question pool
  */
 public function deleteQuestionsObject()
 {
     global $rbacsystem;
     // create an array of all checked checkboxes
     $checked_questions = $_POST['q_id'];
     if (count($checked_questions) > 0) {
         if (!$rbacsystem->checkAccess('write', $this->ref_id)) {
             ilUtil::sendFailure($this->lng->txt("qpl_delete_rbac_error"));
             $this->questionsObject();
             return;
         }
     } elseif (count($checked_questions) == 0) {
         ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
         $this->questionsObject();
         return;
     }
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setHeaderText($this->lng->txt("qpl_confirm_delete_questions"));
     $cgui->setFormAction($this->ctrl->getFormAction($this));
     $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteQuestions");
     $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteQuestions");
     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
     $infos = $this->object->getQuestionInfos($checked_questions);
     foreach ($infos as $data) {
         $txt = $data["title"] . " (" . SurveyQuestion::_getQuestionTypeName($data["type_tag"]) . ")";
         if ($data["description"]) {
             $txt .= "<div class=\"small\">" . $data["description"] . "</div>";
         }
         $cgui->addItem("q_id[]", $data["id"], $txt);
     }
     $this->tpl->setContent($cgui->getHTML());
 }
 /**
  * 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"] : "&nbsp;");
             $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"]);
 }
 public function constraintForm($step, $postvalues, &$survey_questions, $questions = FALSE)
 {
     if (strlen($_GET["start"])) {
         $this->ctrl->setParameter($this, "start", $_GET["start"]);
     }
     $this->ctrl->saveParameter($this, "precondition");
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTableWidth("100%");
     $form->setId("constraintsForm");
     // #9366
     $title = array();
     $title_ids = $_SESSION["includeElements"];
     if (!$title_ids) {
         $title_ids = array($_GET["start"]);
     }
     foreach ($title_ids as $title_id) {
         // question block
         if ($survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["questionblock_id"] > 0) {
             $title[] = $this->lng->txt("questionblock") . ": " . $survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["questionblock_title"];
         } else {
             $title[] = $this->lng->txt($survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["type_tag"]) . ": " . $survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["title"];
         }
     }
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle(implode("<br/>", $title));
     $form->addItem($header);
     $fulfilled = new ilRadioGroupInputGUI($this->lng->txt("constraint_fulfilled"), "c");
     $fulfilled->addOption(new ilRadioOption($this->lng->txt("conjunction_and"), '0', ''));
     $fulfilled->addOption(new ilRadioOption($this->lng->txt("conjunction_or"), '1', ''));
     $fulfilled->setValue(strlen($postvalues['c']) ? $postvalues['c'] : 0);
     $form->addItem($fulfilled);
     $step1 = new ilSelectInputGUI($this->lng->txt("step") . " 1: " . $this->lng->txt("select_prior_question"), "q");
     $options = array();
     if (is_array($questions)) {
         foreach ($questions as $question) {
             $options[$question["question_id"]] = $question["title"] . " (" . SurveyQuestion::_getQuestionTypeName($question["type_tag"]) . ")";
         }
     }
     $step1->setOptions($options);
     $step1->setValue($postvalues["q"]);
     $form->addItem($step1);
     if ($step > 1) {
         $relations = $this->object->getAllRelations();
         $step2 = new ilSelectInputGUI($this->lng->txt("step") . " 2: " . $this->lng->txt("select_relation"), "r");
         $options = array();
         foreach ($relations as $rel_id => $relation) {
             if (in_array($relation["short"], $survey_questions[$postvalues["q"]]["availableRelations"])) {
                 $options[$rel_id] = $relation['short'];
             }
         }
         $step2->setOptions($options);
         $step2->setValue($postvalues["r"]);
         $form->addItem($step2);
     }
     if ($step > 2) {
         $variables =& $this->object->getVariables($postvalues["q"]);
         $question_type = $survey_questions[$postvalues["q"]]["type_tag"];
         include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
         SurveyQuestion::_includeClass($question_type);
         $question = new $question_type();
         $question->loadFromDb($postvalues["q"]);
         $step3 = $question->getPreconditionSelectValue($postvalues["v"], $this->lng->txt("step") . " 3: " . $this->lng->txt("select_value"), "v");
         $form->addItem($step3);
     }
     switch ($step) {
         case 1:
             $cmd_continue = "constraintStep2";
             $cmd_back = "constraints";
             break;
         case 2:
             $cmd_continue = "constraintStep3";
             $cmd_back = "constraintStep1";
             break;
         case 3:
             $cmd_continue = "constraintsAdd";
             $cmd_back = "constraintStep2";
             break;
     }
     $form->addCommandButton($cmd_back, $this->lng->txt("back"));
     $form->addCommandButton($cmd_continue, $this->lng->txt("continue"));
     $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
 }
 public function removeQuestionsForm($checked_questionblocks, $checked_questions, $checked_headings)
 {
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setHeaderText($this->lng->txt("survey_sure_delete_questions"));
     $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmRemoveQuestions"));
     $cgui->setCancel($this->lng->txt("cancel"), "questions");
     $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
     $counter = 0;
     $surveyquestions =& $this->object->getSurveyQuestions();
     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
     foreach ($surveyquestions as $question_id => $data) {
         if (in_array($data["question_id"], $checked_questions)) {
             $type = SurveyQuestion::_getQuestionTypeName($data["type_tag"]);
             $cgui->addItem("id_" . $data["question_id"], $data["question_id"], $type . ": " . $data["title"]);
         } else {
             if (in_array($data["questionblock_id"], $checked_questionblocks)) {
                 $type = SurveyQuestion::_getQuestionTypeName($data["type_tag"]);
                 $cgui->addItem("id_qb_" . $data["questionblock_id"], $data["questionblock_id"], $data["questionblock_title"] . " - " . $type . ": " . $data["title"]);
             } else {
                 if (in_array($data["question_id"], $checked_headings)) {
                     $cgui->addItem("id_tb_" . $data["question_id"], $data["question_id"], $data["heading"]);
                 }
             }
         }
     }
     $this->tpl->setContent($cgui->getHTML());
 }
 /**
  * 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"] : "&nbsp;");
             $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"));
 }