24 include_once 
"./Modules/Survey/classes/inc.SurveyConstants.php";
 
   73                 $this->ctrl->saveParameter($this, 
"q_id");
 
   74                 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"sel_question_types", 
$_GET[
"sel_question_types"]);
 
   75                 $this->cumulated = array();
 
   76                 $this->errormessages = array();
 
   81                 if (strlen($errormessage)) array_push($this->errormessages, $errormessage);
 
   86                 if (count($this->errormessages))
 
   88                         $out = implode(
"<br />", $this->errormessages);
 
   98                 $cmd = $this->ctrl->getCmd();
 
   99                 $next_class = $this->ctrl->getNextClass($this);
 
  129                 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  130                 if ((!$questiontype) and ($question_id > 0))
 
  132                         $questiontype = SurveyQuestion::_getQuestiontype($question_id);
 
  135                 $question_type_gui = $questiontype . 
"GUI";
 
  136                 $question = 
new $question_type_gui($question_id);
 
  142                 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  143                 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
  144                 $q_type = SurveyQuestion::_getQuestiontype($a_q_id);
 
  157                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.il_svy_qpl_sync_original.html", 
"Modules/SurveyQuestionPool");
 
  158                 $this->tpl->setCurrentBlock(
"adm_content");
 
  159                 $this->tpl->setVariable(
"BUTTON_YES", $this->lng->txt(
"yes"));
 
  160                 $this->tpl->setVariable(
"BUTTON_NO", $this->lng->txt(
"no"));
 
  161                 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
 
  162                 $this->tpl->parseCurrentBlock();
 
  167                 $original_id = $this->
object->original_id;
 
  170                         $this->
object->syncWithOriginal();
 
  173                 $this->ctrl->redirect($this, 
"editQuestion");
 
  179                 $this->ctrl->redirect($this, 
"editQuestion");
 
  189                 $old_id = 
$_GET[
"q_id"];
 
  190                 $result = $this->writePostData();
 
  193                         $ilUser->setPref(
"svy_lastquestiontype", $this->object->getQuestionType());
 
  194                         $ilUser->writePref(
"svy_lastquestiontype", $this->object->getQuestionType());
 
  195                         $this->
object->saveToDb();
 
  196                         $originalexists = $this->
object->_questionExists($this->object->original_id);
 
  197                         $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  198                         include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  201                                 $this->ctrl->redirect($this, 
'originalSyncForm');
 
  203                         elseif (
$_GET[
"calling_survey"])
 
  206                                 $_GET[
"ref_id"] = $_GET[
"calling_survey"];
 
  207                                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  208                                 ilUtil::redirect(
"ilias.php?baseClass=ilObjSurveyGUI&ref_id=" . $_GET[
"calling_survey"] . 
"&cmd=questions");
 
  211                         elseif (
$_GET[
"new_for_survey"] > 0)
 
  214                                 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"q_id", $this->object->getId());
 
  215                                 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"sel_question_types", 
$_GET[
"sel_question_types"]);
 
  216                                 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"new_for_survey", 
$_GET[
"new_for_survey"]);
 
  217                                 $this->ctrl->redirectByClass(
$_GET[
"cmdClass"], 
"editQuestion");
 
  223                                 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"q_id", $this->object->getId());
 
  224                                 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"sel_question_types", 
$_GET[
"sel_question_types"]);
 
  225                                 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"new_for_survey", 
$_GET[
"new_for_survey"]);
 
  226                                 $this->ctrl->redirectByClass(
$_GET[
"cmdClass"], 
"editQuestion");
 
  233                 if (
$_GET[
"calling_survey"])
 
  236                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  237                         ilUtil::redirect(
"ilias.php?baseClass=ilObjSurveyGUI&cmd=questions&ref_id=".
$_GET[
"calling_survey"]);
 
  239                 elseif (
$_GET[
"new_for_survey"])
 
  242                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  243                         ilUtil::redirect(
"ilias.php?baseClass=ilObjSurveyGUI&cmd=questions&ref_id=".
$_GET[
"new_for_survey"]);
 
  247                         $this->ctrl->redirectByClass(
"ilobjsurveyquestionpoolgui", 
"questions");
 
  258                 $this->ctrl->redirect($this, 
"editQuestion");
 
  266                 if (count($this->object->getMaterial()))
 
  268                         $template = 
new ilTemplate(
"tpl.il_svy_qpl_material.html", TRUE, TRUE, 
"Modules/SurveyQuestionPool");
 
  269                         foreach ($this->object->getMaterial() as $material)
 
  271                                 $template->setCurrentBlock(
'material');
 
  272                                 switch ($material->type)
 
  276                                                 $template->setVariable(
'MATERIAL_TYPE', 
'internallink');
 
  277                                                 $template->setVariable(
'MATERIAL_HREF', $href);
 
  280                                 $template->setVariable(
'MATERIAL_TITLE', (strlen($material->title)) ? 
ilUtil::prepareFormOutput($material->title) : $this->lng->txt(
'material'));
 
  281                                 $template->setVariable(
'TEXT_AVAILABLE_MATERIALS', $this->lng->txt(
'material'));
 
  282                                 $template->parseCurrentBlock();
 
  284                         return $template->get();
 
  298                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
'ref_id']))
 
  300                         include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  302                         $form->setFormAction($this->ctrl->getFormAction($this));
 
  303                         $form->setTitle($this->lng->txt(
'add_material'));
 
  304                         $form->setMultipart(FALSE);
 
  305                         $form->setTableWidth(
"100%");
 
  306                         $form->setId(
"material");
 
  311                         $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_lm'), 
"lm"));
 
  312                         $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_st'), 
"st"));
 
  313                         $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_pg'), 
"pg"));
 
  314                         $material->addOption(
new ilRadioOption($this->lng->txt(
'glossary_term'), 
"glo"));
 
  315                         $form->addItem($material);
 
  317                         $form->addCommandButton(
"addMaterial", $this->lng->txt(
"add"));
 
  323                                 $form->setValuesByPost();
 
  324                                 $errors = !$form->checkInput();
 
  325                                 if (
$errors) $checkonly = 
false;
 
  327                         $add_html = $form->getHTML();
 
  332                 if (count($this->object->getMaterial()))
 
  334                         include_once 
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyMaterialsTableGUI.php";
 
  337                         foreach ($this->object->getMaterial() as $material)
 
  339                                 switch ($material->type)
 
  343                                                 $type = $this->lng->txt(
'internal_link');
 
  347                                 array_push($data, array(
'href' => $href, 
'title' => 
$title, 
'type' => $type));
 
  349                         $table_gui->setData($data);
 
  350                         $mat_html = $table_gui->getHTML();
 
  353                 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $add_html . $mat_html);
 
  359                 if (is_array(
$_POST[
'idx']))
 
  361                         $this->
object->deleteMaterials(
$_POST[
'idx']);
 
  368                 $this->ctrl->redirect($this, 
'material');
 
  380                         include_once(
"./Modules/SurveyQuestionPool/classes/class.ilMaterialExplorer.php");
 
  381                         switch (
$_POST[
"internalLinkType"])
 
  403                         $exp = 
new ilMaterialExplorer($this->ctrl->getLinkTarget($this, 
'addMaterial'), get_class($this));
 
  409                                 $exp->setForceOpenPath(
$path);
 
  413                                 $exp->setExpand(
$_GET[
"expand"]);
 
  415                         $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'addMaterial'));
 
  416                         $exp->setTargetGet(
"ref_id");
 
  417                         $exp->setRefId(
$_GET[
"ref_id"]);
 
  418                         $exp->addFilter(
$_SESSION[
"link_new_type"]);
 
  419                         $exp->setSelectableType(
$_SESSION[
"link_new_type"]);
 
  424                         $this->tpl->addBlockFile(
"ADM_CONTENT", 
"explorer", 
"tpl.il_svy_qpl_explorer.html", 
"Modules/SurveyQuestionPool");
 
  425                         $this->tpl->setVariable(
"EXPLORER_TREE",$exp->getOutput());
 
  426                         $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  427                         $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  433                 $this->
object->material = array();
 
  434                 $this->
object->saveToDb();
 
  442                 $this->ctrl->redirect($this, 
'material');
 
  447                 $this->
object->addInternalLink(
"il__pg_" . 
$_GET[
"pg"]);
 
  451                 $this->ctrl->redirect($this, 
"material");
 
  456                 $this->
object->addInternalLink(
"il__st_" . 
$_GET[
"st"]);
 
  460                 $this->ctrl->redirect($this, 
"material");
 
  465                 $this->
object->addInternalLink(
"il__git_" . 
$_GET[
"git"]);
 
  469                 $this->ctrl->redirect($this, 
"material");
 
  477                                 include_once 
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
 
  478                                 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
  480                                 $cont_obj = $cont_obj_gui->object;
 
  482                                 $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  483                                 $color_class = array(
"tblrow1", 
"tblrow2");
 
  485                                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"link_selection", 
"tpl.il_svy_qpl_internallink_selection.html", 
"Modules/SurveyQuestionPool");
 
  486                                 foreach($pages as $page)
 
  488                                         if($page[
"type"] == 
$_SESSION[
"search_link_type"])
 
  490                                                 $this->tpl->setCurrentBlock(
"linktable_row");
 
  491                                                 $this->tpl->setVariable(
"TEXT_LINK", $page[
"title"]);
 
  492                                                 $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
 
  493                                                 $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), 
"add" . strtoupper($page[
"type"])) . 
"&" . $page[
"type"] . 
"=" . $page[
"obj_id"]);
 
  494                                                 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
 
  495                                                 $this->tpl->parseCurrentBlock();
 
  499                                 $this->tpl->setCurrentBlock(
"link_selection");
 
  500                                 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  501                                 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" . 
$_SESSION[
"search_link_type"]));
 
  502                                 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  503                                 $this->tpl->parseCurrentBlock();
 
  506                                 $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  507                                 $color_class = array(
"tblrow1", 
"tblrow2");
 
  509                                 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
  511                                 $cont_obj = $cont_obj_gui->object;
 
  513                                 $ctree =& $cont_obj->getLMTree();
 
  514                                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
 
  515                                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"link_selection", 
"tpl.il_svy_qpl_internallink_selection.html", 
"Modules/SurveyQuestionPool");
 
  516                                 foreach($nodes as $node)
 
  518                                         if($node[
"type"] == 
$_SESSION[
"search_link_type"])
 
  520                                                 $this->tpl->setCurrentBlock(
"linktable_row");
 
  521                                                 $this->tpl->setVariable(
"TEXT_LINK", $node[
"title"]);
 
  522                                                 $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
 
  523                                                 $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), 
"add" . strtoupper($node[
"type"])) . 
"&" . $node[
"type"] . 
"=" . $node[
"obj_id"]);
 
  524                                                 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
 
  525                                                 $this->tpl->parseCurrentBlock();
 
  529                                 $this->tpl->setCurrentBlock(
"link_selection");
 
  530                                 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  531                                 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" . 
$_SESSION[
"search_link_type"]));
 
  532                                 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  533                                 $this->tpl->parseCurrentBlock();
 
  536                                 $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  537                                 $color_class = array(
"tblrow1", 
"tblrow2");
 
  539                                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"link_selection", 
"tpl.il_svy_qpl_internallink_selection.html", 
"Modules/SurveyQuestionPool");
 
  540                                 include_once 
"./Modules/Glossary/classes/class.ilObjGlossary.php";
 
  543                                 $terms = $glossary->getTermList();
 
  544                                 foreach($terms as $term)
 
  546                                         $this->tpl->setCurrentBlock(
"linktable_row");
 
  547                                         $this->tpl->setVariable(
"TEXT_LINK", $term[
"term"]);
 
  548                                         $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
 
  549                                         $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), 
"addGIT") . 
"&git=" . $term[
"id"]);
 
  550                                         $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
 
  551                                         $this->tpl->parseCurrentBlock();
 
  554                                 $this->tpl->setCurrentBlock(
"link_selection");
 
  555                                 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  556                                 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"glossary_term"));
 
  557                                 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  558                                 $this->tpl->parseCurrentBlock();
 
  561                                 $this->
object->addInternalLink(
"il__lm_" . 
$_GET[
"source_id"]);
 
  565                                 $this->ctrl->redirect($this, 
"material");
 
  582                 global $rbacsystem,$ilTabs;
 
  583                 $this->ctrl->setParameterByClass(
"$guiclass", 
"sel_question_types", $this->
getQuestionType());
 
  584                 $this->ctrl->setParameterByClass(
"$guiclass", 
"q_id", 
$_GET[
"q_id"]);
 
  586                 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
 
  591                         if (strlen(
$_GET[
"new_for_survey"]))
 
  593                                 $addurl = 
"&new_id=" . 
$_GET[
"q_id"];
 
  595                         $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"), 
"ilias.php?baseClass=ilObjSurveyGUI&ref_id=$ref_id&cmd=questions" . $addurl);
 
  599                         $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI", 
"q_id_table_nav", 
$_SESSION[
'q_id_table_nav']);
 
  600                         $ilTabs->setBackTarget($this->lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI", 
"questions"));
 
  604                         $ilTabs->addTarget(
"preview",
 
  605                                                                          $this->ctrl->getLinkTargetByClass(
"$guiclass", 
"preview"), 
"preview",
 
  608                 if ($rbacsystem->checkAccess(
'edit', 
$_GET[
"ref_id"])) {
 
  609                         $ilTabs->addTarget(
"edit_properties",
 
  610                                                                          $this->ctrl->getLinkTargetByClass(
"$guiclass", 
"editQuestion"), 
 
  611                                                                          array(
"editQuestion", 
"save", 
"cancel", 
"originalSyncForm"),
 
  616                         $ilTabs->addTarget(
"material",
 
  617                                                                          $this->ctrl->getLinkTargetByClass(
"$guiclass", 
"material"), 
 
  618                                                                         array(
"material", 
"cancelExplorer", 
"linkChilds", 
"addGIT", 
"addST",
 
  619                                                                                          "addPG", 
"addMaterial", 
"removeMaterial"),
 
  623                 if ($this->object->getId() > 0) 
 
  625                         $title = $this->lng->txt(
"edit") . 
" "" . $this->
object->getTitle() . 
""";
 
  632                 $this->tpl->setVariable(
"HEADER", 
$title);
 
  643                 return $this->
object->getQuestionType();
 
  665                 $questiontext = $this->
object->getQuestiontext();
 
  666                 if (preg_match(
"/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches))
 
  668                         $questiontext = $matches[1];
 
  670                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  671                 if ($this->object->getObligatory($survey_id))
 
  673                         $template->setVariable(
"OBLIGATORY_TEXT", 
' *');