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);
 
  156                 $this->ctrl->saveParameter($this, 
"rtrn");
 
  159                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.il_svy_qpl_sync_original.html", 
"Modules/SurveyQuestionPool");
 
  160                 $this->tpl->setCurrentBlock(
"adm_content");
 
  161                 $this->tpl->setVariable(
"BUTTON_YES", $this->lng->txt(
"yes"));
 
  162                 $this->tpl->setVariable(
"BUTTON_NO", $this->lng->txt(
"no"));
 
  163                 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
 
  164                 $this->tpl->parseCurrentBlock();
 
  169                 $original_id = $this->
object->original_id;
 
  172                         $this->
object->syncWithOriginal();
 
  196                         if(
$_GET[
"calling_survey"] || 
$_GET[
"new_for_survey"])
 
  201                                         $addurl .= 
"&pgov=".$_REQUEST[
"pgov"];
 
  202                                         $addurl .= 
"&pgov_pos=".$_REQUEST[
"pgov_pos"];
 
  206                                 if(
$_GET[
"calling_survey"])
 
  211                                 else if(
$_GET[
"new_for_survey"])
 
  214                                         $addurl .= 
"&new_id=".$this->object->getId();
 
  218                                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  219                                 ilUtil::redirect(
"ilias.php?baseClass=ilObjSurveyGUI&ref_id=" . 
$_GET[
"ref_id"] . 
"&cmd=questions".$addurl);
 
  224                                 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI", 
"q_id_table_nav", 
$_SESSION[
'q_id_table_nav']);
 
  225                                 $this->ctrl->redirectByClass(
"ilObjSurveyQuestionPoolGUI", 
"questions");
 
  232                         $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"q_id", $this->object->getId());
 
  233                         $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"sel_question_types", 
$_GET[
"sel_question_types"]);
 
  234                         $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"], 
"new_for_survey", 
$_GET[
"new_for_survey"]);
 
  235                         $this->ctrl->redirectByClass(
$_GET[
"cmdClass"], 
"editQuestion");
 
  241                 $a_form->addCommandButton(
"saveReturn", $this->lng->txt(
"save_return"));
 
  242                 $a_form->addCommandButton(
"save", $this->lng->txt(
"save"));
 
  247                         if($this->object->hasCopies())
 
  249                                 $a_form->addCommandButton(
"saveSync", $this->lng->txt(
"svy_save_sync"));
 
  273         function save($a_return = 
false, $a_sync = 
false)
 
  277                 $old_id = 
$_GET[
"q_id"];
 
  278                 $result = $this->writePostData();
 
  281                         $ilUser->setPref(
"svy_lastquestiontype", $this->object->getQuestionType());
 
  282                         $ilUser->writePref(
"svy_lastquestiontype", $this->object->getQuestionType());
 
  283                         $this->
object->saveToDb();
 
  284                         $originalexists = $this->
object->_questionExists($this->object->original_id);
 
  285                         $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  286                         include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  292                                 $this->ctrl->redirect($this, 
'copySyncForm');
 
  297                                 if (
$_GET[
"calling_survey"] && $originalexists &&
 
  302                                                 $this->ctrl->setParameter($this, 
'rtrn', 1);
 
  304                                         $this->ctrl->redirect($this, 
'originalSyncForm');
 
  315                 if (
$_GET[
"calling_survey"])
 
  318                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  319                         ilUtil::redirect(
"ilias.php?baseClass=ilObjSurveyGUI&cmd=questions&ref_id=".
$_GET[
"calling_survey"]);
 
  321                 elseif (
$_GET[
"new_for_survey"])
 
  324                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  325                         ilUtil::redirect(
"ilias.php?baseClass=ilObjSurveyGUI&cmd=questions&ref_id=".
$_GET[
"new_for_survey"]);
 
  329                         $this->ctrl->redirectByClass(
"ilobjsurveyquestionpoolgui", 
"questions");
 
  340                 $this->ctrl->redirect($this, 
"editQuestion");
 
  348                 if (count($this->object->getMaterial()))
 
  350                         $template = 
new ilTemplate(
"tpl.il_svy_qpl_material.html", TRUE, TRUE, 
"Modules/SurveyQuestionPool");
 
  351                         foreach ($this->object->getMaterial() as $material)
 
  353                                 $template->setCurrentBlock(
'material');
 
  354                                 switch ($material->type)
 
  358                                                 $template->setVariable(
'MATERIAL_TYPE', 
'internallink');
 
  359                                                 $template->setVariable(
'MATERIAL_HREF', $href);
 
  362                                 $template->setVariable(
'MATERIAL_TITLE', (strlen($material->title)) ? 
ilUtil::prepareFormOutput($material->title) : $this->lng->txt(
'material'));
 
  363                                 $template->setVariable(
'TEXT_AVAILABLE_MATERIALS', $this->lng->txt(
'material'));
 
  364                                 $template->parseCurrentBlock();
 
  366                         return $template->get();
 
  380                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
'ref_id']))
 
  382                         include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  384                         $form->setFormAction($this->ctrl->getFormAction($this));
 
  385                         $form->setTitle($this->lng->txt(
'add_material'));
 
  386                         $form->setMultipart(FALSE);
 
  387                         $form->setTableWidth(
"100%");
 
  388                         $form->setId(
"material");
 
  393                         $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_lm'), 
"lm"));
 
  394                         $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_st'), 
"st"));
 
  395                         $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_pg'), 
"pg"));
 
  396                         $material->addOption(
new ilRadioOption($this->lng->txt(
'glossary_term'), 
"glo"));
 
  397                         $form->addItem($material);
 
  399                         $form->addCommandButton(
"addMaterial", $this->lng->txt(
"add"));
 
  405                                 $form->setValuesByPost();
 
  406                                 $errors = !$form->checkInput();
 
  407                                 if (
$errors) $checkonly = 
false;
 
  409                         $add_html = $form->getHTML();
 
  414                 if (count($this->object->getMaterial()))
 
  416                         include_once 
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyMaterialsTableGUI.php";
 
  419                         foreach ($this->object->getMaterial() as $material)
 
  421                                 switch ($material->type)
 
  425                                                 $type = $this->lng->txt(
'internal_link');
 
  429                                 array_push($data, array(
'href' => $href, 
'title' => 
$title, 
'type' => $type));
 
  431                         $table_gui->setData($data);
 
  432                         $mat_html = $table_gui->getHTML();
 
  435                 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $add_html . $mat_html);
 
  441                 if (is_array(
$_POST[
'idx']))
 
  443                         $this->
object->deleteMaterials(
$_POST[
'idx']);
 
  450                 $this->ctrl->redirect($this, 
'material');
 
  462                         include_once(
"./Modules/SurveyQuestionPool/classes/class.ilMaterialExplorer.php");
 
  463                         switch (
$_POST[
"internalLinkType"])
 
  485                         $exp = 
new ilMaterialExplorer($this->ctrl->getLinkTarget($this, 
'addMaterial'), get_class($this));
 
  491                                 $exp->setForceOpenPath(
$path);
 
  495                                 $exp->setExpand(
$_GET[
"expand"]);
 
  497                         $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'addMaterial'));
 
  498                         $exp->setTargetGet(
"ref_id");
 
  499                         $exp->setRefId(
$_GET[
"ref_id"]);
 
  500                         $exp->addFilter(
$_SESSION[
"link_new_type"]);
 
  501                         $exp->setSelectableType(
$_SESSION[
"link_new_type"]);
 
  506                         $this->tpl->addBlockFile(
"ADM_CONTENT", 
"explorer", 
"tpl.il_svy_qpl_explorer.html", 
"Modules/SurveyQuestionPool");
 
  507                         $this->tpl->setVariable(
"EXPLORER_TREE",$exp->getOutput());
 
  508                         $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  509                         $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  515                 $this->
object->material = array();
 
  516                 $this->
object->saveToDb();
 
  524                 $this->ctrl->redirect($this, 
'material');
 
  529                 $this->
object->addInternalLink(
"il__pg_" . 
$_GET[
"pg"]);
 
  533                 $this->ctrl->redirect($this, 
"material");
 
  538                 $this->
object->addInternalLink(
"il__st_" . 
$_GET[
"st"]);
 
  542                 $this->ctrl->redirect($this, 
"material");
 
  547                 $this->
object->addInternalLink(
"il__git_" . 
$_GET[
"git"]);
 
  551                 $this->ctrl->redirect($this, 
"material");
 
  559                                 include_once 
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
 
  560                                 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
  562                                 $cont_obj = $cont_obj_gui->object;
 
  564                                 $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  565                                 $color_class = array(
"tblrow1", 
"tblrow2");
 
  567                                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"link_selection", 
"tpl.il_svy_qpl_internallink_selection.html", 
"Modules/SurveyQuestionPool");
 
  568                                 foreach($pages as $page)
 
  570                                         if($page[
"type"] == 
$_SESSION[
"search_link_type"])
 
  572                                                 $this->tpl->setCurrentBlock(
"linktable_row");
 
  573                                                 $this->tpl->setVariable(
"TEXT_LINK", $page[
"title"]);
 
  574                                                 $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
 
  575                                                 $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), 
"add" . strtoupper($page[
"type"])) . 
"&" . $page[
"type"] . 
"=" . $page[
"obj_id"]);
 
  576                                                 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
 
  577                                                 $this->tpl->parseCurrentBlock();
 
  581                                 $this->tpl->setCurrentBlock(
"link_selection");
 
  582                                 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  583                                 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" . 
$_SESSION[
"search_link_type"]));
 
  584                                 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  585                                 $this->tpl->parseCurrentBlock();
 
  588                                 $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  589                                 $color_class = array(
"tblrow1", 
"tblrow2");
 
  591                                 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
 
  593                                 $cont_obj = $cont_obj_gui->object;
 
  595                                 $ctree =& $cont_obj->getLMTree();
 
  596                                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
 
  597                                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"link_selection", 
"tpl.il_svy_qpl_internallink_selection.html", 
"Modules/SurveyQuestionPool");
 
  598                                 foreach($nodes as $node)
 
  600                                         if($node[
"type"] == 
$_SESSION[
"search_link_type"])
 
  602                                                 $this->tpl->setCurrentBlock(
"linktable_row");
 
  603                                                 $this->tpl->setVariable(
"TEXT_LINK", $node[
"title"]);
 
  604                                                 $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
 
  605                                                 $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), 
"add" . strtoupper($node[
"type"])) . 
"&" . $node[
"type"] . 
"=" . $node[
"obj_id"]);
 
  606                                                 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
 
  607                                                 $this->tpl->parseCurrentBlock();
 
  611                                 $this->tpl->setCurrentBlock(
"link_selection");
 
  612                                 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  613                                 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" . 
$_SESSION[
"search_link_type"]));
 
  614                                 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  615                                 $this->tpl->parseCurrentBlock();
 
  618                                 $this->ctrl->setParameter($this, 
"q_id", $this->object->getId());
 
  619                                 $color_class = array(
"tblrow1", 
"tblrow2");
 
  621                                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"link_selection", 
"tpl.il_svy_qpl_internallink_selection.html", 
"Modules/SurveyQuestionPool");
 
  622                                 include_once 
"./Modules/Glossary/classes/class.ilObjGlossary.php";
 
  625                                 $terms = $glossary->getTermList();
 
  626                                 foreach($terms as $term)
 
  628                                         $this->tpl->setCurrentBlock(
"linktable_row");
 
  629                                         $this->tpl->setVariable(
"TEXT_LINK", $term[
"term"]);
 
  630                                         $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
 
  631                                         $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), 
"addGIT") . 
"&git=" . $term[
"id"]);
 
  632                                         $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
 
  633                                         $this->tpl->parseCurrentBlock();
 
  636                                 $this->tpl->setCurrentBlock(
"link_selection");
 
  637                                 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
 
  638                                 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"glossary_term"));
 
  639                                 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
 
  640                                 $this->tpl->parseCurrentBlock();
 
  643                                 $this->
object->addInternalLink(
"il__lm_" . 
$_GET[
"source_id"]);
 
  647                                 $this->ctrl->redirect($this, 
"material");
 
  664                 global $rbacsystem,$ilTabs;
 
  665                 $this->ctrl->setParameterByClass(
"$guiclass", 
"sel_question_types", $this->
getQuestionType());
 
  666                 $this->ctrl->setParameterByClass(
"$guiclass", 
"q_id", 
$_GET[
"q_id"]);
 
  668                 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
 
  673                         if (strlen(
$_GET[
"new_for_survey"]))
 
  675                                 $addurl = 
"&new_id=" . 
$_GET[
"q_id"];
 
  679                                 $addurl .= 
"&pgov=".$_REQUEST[
"pgov"];
 
  680                                 $addurl .= 
"&pgov_pos=".$_REQUEST[
"pgov_pos"];
 
  682                         $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"), 
"ilias.php?baseClass=ilObjSurveyGUI&ref_id=$ref_id&cmd=questions" . $addurl);
 
  686                         $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI", 
"q_id_table_nav", 
$_SESSION[
'q_id_table_nav']);
 
  687                         $ilTabs->setBackTarget($this->lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI", 
"questions"));
 
  691                         $ilTabs->addTarget(
"preview",
 
  692                                                                          $this->ctrl->getLinkTargetByClass(
"$guiclass", 
"preview"), 
"preview",
 
  695                 if ($rbacsystem->checkAccess(
'edit', 
$_GET[
"ref_id"])) {
 
  696                         $ilTabs->addTarget(
"edit_properties",
 
  697                                                                          $this->ctrl->getLinkTargetByClass(
"$guiclass", 
"editQuestion"), 
 
  698                                                                          array(
"editQuestion", 
"save", 
"cancel", 
"originalSyncForm"),
 
  703                         $ilTabs->addTarget(
"material",
 
  704                                                                          $this->ctrl->getLinkTargetByClass(
"$guiclass", 
"material"), 
 
  705                                                                         array(
"material", 
"cancelExplorer", 
"linkChilds", 
"addGIT", 
"addST",
 
  706                                                                                          "addPG", 
"addMaterial", 
"removeMaterial"),
 
  710                 if ($this->object->getId() > 0) 
 
  712                         $title = $this->lng->txt(
"edit") . 
" "" . $this->
object->getTitle() . 
""";
 
  719                 $this->tpl->setVariable(
"HEADER", 
$title);
 
  730                 return $this->
object->getQuestionType();
 
  752                 $questiontext = $this->
object->getQuestiontext();
 
  753                 if (preg_match(
"/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches))
 
  755                         $questiontext = $matches[1];
 
  757                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  758                 if ($this->object->getObligatory($survey_id))
 
  760                         $template->setVariable(
"OBLIGATORY_TEXT", 
' *');
 
  767                 $a_cmds[] = 
"saveReturn";
 
  768             return in_array($this->ctrl->getCmd(), $a_cmds);
 
  778                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.il_svy_qpl_preview.html", 
"Modules/SurveyQuestionPool");
 
  779                 $question_output = $this->getWorkingForm();
 
  781                 if ($this->object->getObligatory())
 
  783                         $this->tpl->setCurrentBlock(
"required");
 
  784                         $this->tpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
 
  785                         $this->tpl->parseCurrentBlock();
 
  788                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
 
  793                 include_once 
"Services/Chart/classes/class.ilChart.php";
 
  794                 $chart = 
new ilChart($a_id, 700, 400);
 
  798                 $chart->setYAxisToInteger(
true);
 
  801                 $data->setLabel($this->lng->txt(
"users_answered"));
 
  802                 $data->setBarOptions(0.5, 
"center");
 
  806                 if(
sizeof($a_variables) <= $max)
 
  811                                 foreach($a_variables as $idx => $points)
 
  813                                         $data->addPoint($idx, $points[
"selected"]);             
 
  816                                 $chart->addData(
$data);
 
  818                                 $chart->setTicks($labels, 
false, 
true);
 
  821                         return "<div style=\"margin:10px\">".$chart->getHTML().
"</div>";                
 
  825                         $chart_legend = array();                        
 
  827                         foreach($a_variables as $idx => $points)
 
  829                                 $data->addPoint($idx, $points[
"selected"]);             
 
  830                                 $labels[$idx] = ($idx+1).
".";                           
 
  833                         $chart->addData(
$data);
 
  835                         $chart->setTicks($labels, 
false, 
true);
 
  838                         foreach($chart_legend as $number => $caption)
 
  840                                 $legend .= 
"<tr valign=\"top\"><td>".$number.
".</td><td>".$caption.
"</td></tr>";
 
  844                         return "<div style=\"margin:10px\"><table><tr valign=\"bottom\"><td>".
 
  845                                 $chart->getHTML().
"</td><td class=\"small\" style=\"padding-left:15px\">".
 
  846                                 $legend.
"</td></tr></table></div>";                                     
 
  852                 include_once 
"Modules/SurveyQuestionPool/classes/class.ilSurveySyncTableGUI.php";
 
  855                 $this->tpl->setContent($tbl->getHTML());                
 
  860                 global 
$lng, $ilAccess;
 
  862                 if(!
sizeof(
$_POST[
"qid"]))
 
  868                 foreach($this->object->getCopyIds(
true) as $survey_id => $questions)
 
  875                                 if($ilAccess->checkAccess(
"edit", 
"", $ref_id))
 
  884                                 foreach($questions as $qid)
 
  886                                         if(in_array($qid, 
$_POST[
"qid"]))
 
  888                                                 $id = $this->
object->getId();
 
  890                                                 $this->
object->setId($qid);
 
  891                                                 $this->
object->setOriginalId($id);
 
  892                                                 $this->
object->saveToDb();
 
  894                                                 $this->
object->setId($id);
 
  895                                                 $this->
object->setOriginalId(null);