51 $this->ctrl->saveParameter($this,
"q_id");
52 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"sel_question_types",
$_GET[
"sel_question_types"]);
53 $this->cumulated = array();
59 $this->
object->loadFromDb($a_id);
68 $cmd = $this->ctrl->getCmd();
69 $next_class = $this->ctrl->getNextClass($this);
92 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
93 if ((!$questiontype) and ($question_id > 0))
95 $questiontype = SurveyQuestion::_getQuestiontype($question_id);
98 $question_type_gui = $questiontype .
"GUI";
99 $question =
new $question_type_gui($question_id);
105 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
106 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
107 $q_type = SurveyQuestion::_getQuestiontype($a_q_id);
125 return $this->
object->getQuestionType();
130 $questiontext = $this->
object->getQuestiontext();
131 if (preg_match(
"/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches))
133 $questiontext = $matches[1];
135 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
136 if ($this->object->getObligatory($survey_id))
138 $template->setVariable(
"OBLIGATORY_TEXT",
' *');
144 $this->parent_url = $a_url;
149 global $rbacsystem,$ilTabs;
151 $this->ctrl->setParameterByClass($guiclass,
"sel_question_types", $this->
getQuestionType());
152 $this->ctrl->setParameterByClass($guiclass,
"q_id",
$_GET[
"q_id"]);
154 if ($this->parent_url)
157 if (strlen(
$_GET[
"new_for_survey"]))
159 $addurl =
"&new_id=" .
$_GET[
"q_id"];
161 $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"), $this->parent_url . $addurl);
165 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI",
"q_id_table_nav",
$_SESSION[
'q_id_table_nav']);
166 $ilTabs->setBackTarget($this->lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI",
"questions"));
170 $ilTabs->addTab(
"preview",
171 $this->lng->txt(
"preview"),
172 $this->ctrl->getLinkTargetByClass($guiclass,
"preview"));
175 if ($rbacsystem->checkAccess(
'edit',
$_GET[
"ref_id"]))
177 $ilTabs->addTab(
"edit_properties",
178 $this->lng->txt(
"properties"),
179 $this->ctrl->getLinkTargetByClass($guiclass,
"editQuestion"));
181 if(stristr($guiclass,
"matrix"))
183 $ilTabs->addTab(
"layout",
184 $this->lng->txt(
"layout"),
185 $this->ctrl->getLinkTargetByClass($guiclass,
"layout"));
190 $ilTabs->addTab(
"material",
191 $this->lng->txt(
"material"),
192 $this->ctrl->getLinkTargetByClass($guiclass,
"material"));
195 if ($this->object->getId() > 0)
197 $title = $this->lng->txt(
"edit") .
" "" . $this->
object->getTitle() .
""";
201 $title = $this->lng->txt(
"create_new") .
" " . $this->lng->txt($this->
getQuestionType());
204 $this->tpl->setVariable(
"HEADER", $title);
214 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
216 $form->setFormAction($this->ctrl->getFormAction($this,
"save"));
217 $form->setTitle($this->lng->txt($this->getQuestionType()));
218 $form->setMultipart(FALSE);
219 $form->setTableWidth(
"100%");
225 $form->addItem($title);
229 $label->
setInfo($this->lng->txt(
"label_info"));
230 $label->setRequired(
false);
231 $form->addItem($label);
234 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
236 $form->addItem($author);
239 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
241 $form->addItem($description);
246 $question->setRows(10);
247 $question->setCols(80);
248 $question->setUseRte(TRUE);
249 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
251 $question->addPlugin(
"latex");
252 $question->addButton(
"latex");
253 $question->addButton(
"pastelatex");
254 $question->setRTESupport($this->object->getId(),
"spl",
"survey");
255 $form->addItem($question);
260 $shuffle->setRequired(FALSE);
261 $form->addItem($shuffle);
268 $title->setValue($this->object->getTitle());
269 $label->setValue($this->object->label);
270 $author->setValue($this->object->getAuthor());
271 $description->setValue($this->object->getDescription());
272 $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
273 $shuffle->setChecked($this->object->getObligatory());
280 $a_form->addCommandButton(
"saveReturn", $this->lng->txt(
"save_return"));
281 $a_form->addCommandButton(
"save", $this->lng->txt(
"save"));
286 if($this->object->hasCopies())
288 $a_form->addCommandButton(
"saveSync", $this->lng->txt(
"svy_save_sync"));
297 $ilTabs->activateTab(
"edit_properties");
303 $this->tpl->setContent($a_form->getHTML());
319 if($form->checkInput())
323 $this->
object->setTitle($form->getInput(
"title"));
324 $this->
object->label = ($form->getInput(
"label"));
325 $this->
object->setAuthor($form->getInput(
"author"));
326 $this->
object->setDescription($form->getInput(
"description"));
327 $this->
object->setQuestiontext($form->getInput(
"question"));
328 $this->
object->setObligatory($form->getInput(
"obligatory"));
333 $this->
object->saveToDb();
339 $form->setValuesByPost();
344 protected function save($a_return =
false, $a_sync =
false)
358 $ilUser->setPref(
"svy_lastquestiontype", $this->object->getQuestionType());
359 $ilUser->writePref(
"svy_lastquestiontype", $this->object->getQuestionType());
361 $originalexists = $this->
object->_questionExists($this->object->original_id);
362 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
363 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
369 $this->ctrl->redirect($this,
'copySyncForm');
374 if ($originalexists &&
379 $this->ctrl->setParameter($this,
'rtrn', 1);
381 $this->ctrl->redirect($this,
'originalSyncForm');
394 $ilTabs->activateTab(
"edit_properties");
396 include_once
"Modules/SurveyQuestionPool/classes/class.ilSurveySyncTableGUI.php";
399 $this->tpl->setContent($tbl->getHTML());
404 global
$lng, $ilAccess;
406 if(!
sizeof(
$_POST[
"qid"]))
412 foreach($this->object->getCopyIds(
true) as $survey_id => $questions)
419 if($ilAccess->checkAccess(
"edit",
"", $ref_id))
428 foreach($questions as $qid)
430 if(in_array($qid,
$_POST[
"qid"]))
432 $id = $this->
object->getId();
434 $this->
object->setId($qid);
435 $this->
object->setOriginalId($id);
436 $this->
object->saveToDb();
438 $this->
object->setId($id);
439 $this->
object->setOriginalId(null);
456 $ilTabs->activateTab(
"edit_properties");
458 $this->ctrl->saveParameter($this,
"rtrn");
460 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
462 $cgui->setHeaderText($this->lng->txt(
"confirm_sync_questions"));
464 $cgui->setFormAction($this->ctrl->getFormAction($this,
"confirmRemoveQuestions"));
465 $cgui->setCancel($this->lng->txt(
"no"),
"cancelSync");
466 $cgui->setConfirm($this->lng->txt(
"yes"),
"sync");
468 $this->tpl->setContent($cgui->getHTML());
473 $original_id = $this->
object->original_id;
476 $this->
object->syncWithOriginal();
500 if($this->parent_url)
503 if (strlen(
$_GET[
"new_for_survey"]))
505 $addurl =
"&new_id=" .
$_GET[
"q_id"];
512 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI",
"q_id_table_nav",
$_SESSION[
'q_id_table_nav']);
513 $this->ctrl->redirectByClass(
"ilObjSurveyQuestionPoolGUI",
"questions");
519 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"q_id", $this->object->getId());
520 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"sel_question_types",
$_GET[
"sel_question_types"]);
521 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"new_for_survey",
$_GET[
"new_for_survey"]);
522 $this->ctrl->redirectByClass(
$_GET[
"cmdClass"],
"editQuestion");
528 if ($this->parent_url)
534 $this->ctrl->redirectByClass(
"ilobjsurveyquestionpoolgui",
"questions");
546 abstract public function getPrintView($question_title = 1, $show_questiontext = 1);
557 $ilTabs->activateTab(
"preview");
559 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
562 if ($this->object->getObligatory())
564 $this->tpl->setCurrentBlock(
"required");
565 $this->tpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
566 $this->tpl->parseCurrentBlock();
569 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
577 abstract public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null);
584 if (count($this->object->getMaterial()))
586 $template =
new ilTemplate(
"tpl.il_svy_qpl_material.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
587 foreach ($this->object->getMaterial() as $material)
589 $template->setCurrentBlock(
'material');
590 switch ($material->type)
594 $template->setVariable(
'MATERIAL_TYPE',
'internallink');
595 $template->setVariable(
'MATERIAL_HREF', $href);
598 $template->setVariable(
'MATERIAL_TITLE', (strlen($material->title)) ?
ilUtil::prepareFormOutput($material->title) : $this->lng->txt(
'material'));
599 $template->setVariable(
'TEXT_AVAILABLE_MATERIALS', $this->lng->txt(
'material'));
600 $template->parseCurrentBlock();
602 return $template->get();
616 include_once
"Services/Chart/classes/class.ilChart.php";
617 $chart =
new ilChart($a_id, 700, 400);
620 $chart->setLegend($legend);
621 $chart->setYAxisToInteger(
true);
624 $data->setLabel($this->lng->txt(
"users_answered"));
625 $data->setBarOptions(0.5,
"center");
629 if(
sizeof($a_variables) <= $max)
634 foreach($a_variables as $idx => $points)
636 $data->addPoint($idx, $points[
"selected"]);
639 $chart->addData($data);
641 $chart->setTicks($labels,
false,
true);
644 return "<div style=\"margin:10px\">".$chart->getHTML().
"</div>";
648 $chart_legend = array();
650 foreach($a_variables as $idx => $points)
652 $data->addPoint($idx, $points[
"selected"]);
653 $labels[$idx] = ($idx+1).
".";
656 $chart->addData($data);
658 $chart->setTicks($labels,
false,
true);
661 foreach($chart_legend as $number => $caption)
663 $legend .=
"<tr valign=\"top\"><td>".$number.
".</td><td>".$caption.
"</td></tr>";
665 $legend .=
"</table>";
667 return "<div style=\"margin:10px\"><table><tr valign=\"bottom\"><td>".
668 $chart->getHTML().
"</td><td class=\"small\" style=\"padding-left:15px\">".
669 $legend.
"</td></tr></table></div>";
684 global $rbacsystem, $ilTabs;
686 $ilTabs->activateTab(
"material");
689 if ($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']))
691 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
693 $form->setFormAction($this->ctrl->getFormAction($this));
694 $form->setTitle($this->lng->txt(
'add_material'));
695 $form->setMultipart(FALSE);
696 $form->setTableWidth(
"100%");
697 $form->setId(
"material");
702 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_lm'),
"lm"));
703 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_st'),
"st"));
704 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_pg'),
"pg"));
705 $material->addOption(
new ilRadioOption($this->lng->txt(
'glossary_term'),
"glo"));
706 $form->addItem($material);
708 $form->addCommandButton(
"addMaterial", $this->lng->txt(
"add"));
714 $form->setValuesByPost();
715 $errors = !$form->checkInput();
716 if (
$errors) $checkonly =
false;
718 $add_html = $form->getHTML();
723 if (count($this->object->getMaterial()))
725 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyMaterialsTableGUI.php";
728 foreach ($this->object->getMaterial() as $material)
730 switch ($material->type)
734 $type = $this->lng->txt(
'internal_link');
738 array_push($data, array(
'href' => $href,
'title' => $title,
'type' => $type));
740 $table_gui->setData($data);
741 $mat_html = $table_gui->getHTML();
744 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $add_html . $mat_html);
750 if (is_array(
$_POST[
'idx']))
752 $this->
object->deleteMaterials(
$_POST[
'idx']);
759 $this->ctrl->redirect($this,
'material');
767 global $tree, $ilTabs;
769 $ilTabs->activateTab(
"material");
773 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilMaterialExplorer.php");
774 switch (
$_POST[
"internalLinkType"])
796 $exp =
new ilMaterialExplorer($this->ctrl->getLinkTarget($this,
'addMaterial'), get_class($this));
802 $exp->setForceOpenPath(
$path);
806 $exp->setExpand(
$_GET[
"expand"]);
808 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'addMaterial'));
809 $exp->setTargetGet(
"ref_id");
810 $exp->setRefId(
$_GET[
"ref_id"]);
811 $exp->addFilter(
$_SESSION[
"link_new_type"]);
812 $exp->setSelectableType(
$_SESSION[
"link_new_type"]);
817 $this->tpl->addBlockFile(
"ADM_CONTENT",
"explorer",
"tpl.il_svy_qpl_explorer.html",
"Modules/SurveyQuestionPool");
818 $this->tpl->setVariable(
"EXPLORER_TREE",$exp->getOutput());
819 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
820 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
826 $this->
object->material = array();
827 $this->
object->saveToDb();
835 $this->ctrl->redirect($this,
'material');
840 $this->
object->addInternalLink(
"il__pg_" .
$_GET[
"pg"]);
844 $this->ctrl->redirect($this,
"material");
849 $this->
object->addInternalLink(
"il__st_" .
$_GET[
"st"]);
853 $this->ctrl->redirect($this,
"material");
858 $this->
object->addInternalLink(
"il__git_" .
$_GET[
"git"]);
862 $this->ctrl->redirect($this,
"material");
870 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
871 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
873 $cont_obj = $cont_obj_gui->object;
875 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
876 $color_class = array(
"tblrow1",
"tblrow2");
878 $this->tpl->addBlockFile(
"ADM_CONTENT",
"link_selection",
"tpl.il_svy_qpl_internallink_selection.html",
"Modules/SurveyQuestionPool");
879 foreach($pages as $page)
881 if($page[
"type"] ==
$_SESSION[
"search_link_type"])
883 $this->tpl->setCurrentBlock(
"linktable_row");
884 $this->tpl->setVariable(
"TEXT_LINK", $page[
"title"]);
885 $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
886 $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($page[
"type"])) .
"&" . $page[
"type"] .
"=" . $page[
"obj_id"]);
887 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
888 $this->tpl->parseCurrentBlock();
892 $this->tpl->setCurrentBlock(
"link_selection");
893 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
894 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" .
$_SESSION[
"search_link_type"]));
895 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
896 $this->tpl->parseCurrentBlock();
899 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
900 $color_class = array(
"tblrow1",
"tblrow2");
902 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
904 $cont_obj = $cont_obj_gui->object;
906 $ctree =& $cont_obj->getLMTree();
907 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
908 $this->tpl->addBlockFile(
"ADM_CONTENT",
"link_selection",
"tpl.il_svy_qpl_internallink_selection.html",
"Modules/SurveyQuestionPool");
909 foreach($nodes as $node)
911 if($node[
"type"] ==
$_SESSION[
"search_link_type"])
913 $this->tpl->setCurrentBlock(
"linktable_row");
914 $this->tpl->setVariable(
"TEXT_LINK", $node[
"title"]);
915 $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
916 $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($node[
"type"])) .
"&" . $node[
"type"] .
"=" . $node[
"obj_id"]);
917 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
918 $this->tpl->parseCurrentBlock();
922 $this->tpl->setCurrentBlock(
"link_selection");
923 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
924 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" .
$_SESSION[
"search_link_type"]));
925 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
926 $this->tpl->parseCurrentBlock();
929 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
930 $color_class = array(
"tblrow1",
"tblrow2");
932 $this->tpl->addBlockFile(
"ADM_CONTENT",
"link_selection",
"tpl.il_svy_qpl_internallink_selection.html",
"Modules/SurveyQuestionPool");
933 include_once
"./Modules/Glossary/classes/class.ilObjGlossary.php";
936 $terms = $glossary->getTermList();
937 foreach($terms as $term)
939 $this->tpl->setCurrentBlock(
"linktable_row");
940 $this->tpl->setVariable(
"TEXT_LINK", $term[
"term"]);
941 $this->tpl->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
942 $this->tpl->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"addGIT") .
"&git=" . $term[
"id"]);
943 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
944 $this->tpl->parseCurrentBlock();
947 $this->tpl->setCurrentBlock(
"link_selection");
948 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
949 $this->tpl->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"glossary_term"));
950 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
951 $this->tpl->parseCurrentBlock();
954 $this->
object->addInternalLink(
"il__lm_" .
$_GET[
"source_id"]);
958 $this->ctrl->redirect($this,
"material");
970 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
972 $form->setFormAction($this->ctrl->getFormAction($this,
"addSelectedPhrase"));
973 $form->setTitle($this->lng->txt(
"add_phrase"));
978 $form->addItem($group);
980 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
985 $opt =
new ilRadioOption($phrase_array[
"title"], $phrase_id);
986 $opt->setInfo(join($categories,
","));
987 $group->addOption($opt);
989 if($phrase_array[
"org_title"] ==
"dp_standard_numbers")
994 $opt->addSubItem($min);
999 $opt->addSubItem($max);
1003 $form->addCommandButton(
"addSelectedPhrase", $this->lng->txt(
"add_phrase"));
1004 $form->addCommandButton(
"editQuestion", $this->lng->txt(
"cancel"));
1016 $ilTabs->activateTab(
"edit_properties");
1023 $this->
object->saveToDb();
1029 $this->tpl->setContent($a_form->getHTML());
1035 if($form->checkInput())
1037 $phrase_id = $form->getInput(
"phrases");
1040 if (strcmp($this->object->getPhrase($phrase_id),
"dp_standard_numbers") != 0)
1042 $this->
object->addPhrase($phrase_id);
1046 $min = $form->getInput(
"lower_limit");
1047 $max = $form->getInput(
"upper_limit");
1051 $max_field = $form->getItemByPostVar(
"upper_limit");
1052 $max_field->setAlert($this->lng->txt(
"upper_limit_must_be_greater"));
1057 $this->
object->addStandardNumbers($min, $max);
1063 $this->
object->saveToDb();
1066 $this->ctrl->redirect($this,
'editQuestion');
1070 $form->setValuesByPost();
1081 global $ilTabs, $ilToolbar;
1083 $ilTabs->activateTab(
"edit_properties");
1090 $this->
object->saveToDb();
1094 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
1095 $txt =
new ilTextInputGUI($this->lng->txt(
"enter_phrase_title"),
"phrase_title");
1096 $ilToolbar->addInputItem($txt,
true);
1097 $ilToolbar->addFormButton($this->lng->txt(
"confirm"),
"confirmSavePhrase");
1098 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
1100 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveySavePhraseTableGUI.php";
1102 $table_gui->setDescription($this->lng->txt(
"save_phrase_introduction"));
1105 if(method_exists($this->
object,
"getCategories"))
1107 $categories = $this->
object->getCategories();
1111 $categories = $this->
object->getColumns();
1115 for ($i = 0; $i < $categories->getCategoryCount(); $i++)
1117 $cat = $categories->getCategory($i);
1120 "answer" => $cat->title,
1121 "other" => $cat->other,
1122 "scale" => $cat->scale,
1123 "neutral" => $cat->neutral
1126 $table_gui->setData($data);
1129 $this->tpl->setContent($table_gui->getHTML());
1139 $title =
$_POST[
"phrase_title"];
1147 else if ($this->object->phraseExists($title))
1155 $this->
object->savePhrase($title);
1158 $this->ctrl->redirect($this,
"editQuestion");