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->addNonTabbedLink(
"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 $tpl =
new ilTemplate(
"tpl.il_svy_qpl_preview.html",
true,
true,
"Modules/SurveyQuestionPool");
561 if ($this->object->getObligatory())
563 $tpl->setCurrentBlock(
"required");
564 $tpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
565 $tpl->parseCurrentBlock();
570 include_once
"Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
572 $panel->setBody(
$tpl->get());
574 $this->tpl->setContent($panel->getHTML());
582 abstract public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null);
589 if (count($this->object->getMaterial()))
591 $template =
new ilTemplate(
"tpl.il_svy_qpl_material.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
592 foreach ($this->object->getMaterial() as $material)
594 $template->setCurrentBlock(
'material');
595 switch ($material->type)
599 $template->setVariable(
'MATERIAL_TYPE',
'internallink');
600 $template->setVariable(
'MATERIAL_HREF', $href);
603 $template->setVariable(
'MATERIAL_TITLE', (strlen($material->title)) ?
ilUtil::prepareFormOutput($material->title) : $this->lng->txt(
'material'));
604 $template->setVariable(
'TEXT_AVAILABLE_MATERIALS', $this->lng->txt(
'material'));
605 $template->parseCurrentBlock();
607 return $template->get();
621 include_once
"Services/Chart/classes/class.ilChart.php";
623 $chart->setsize(700, 400);
626 $chart->setLegend($legend);
627 $chart->setYAxisToInteger(
true);
630 $data->setLabel($this->lng->txt(
"users_answered"));
631 $data->setBarOptions(0.5,
"center");
635 if(
sizeof($a_variables) <= $max)
640 foreach($a_variables as $idx => $points)
642 $data->addPoint($idx, $points[
"selected"]);
645 $chart->addData($data);
647 $chart->setTicks($labels,
false,
true);
650 return "<div style=\"margin:10px\">".$chart->getHTML().
"</div>";
654 $chart_legend = array();
656 foreach($a_variables as $idx => $points)
658 $data->addPoint($idx, $points[
"selected"]);
659 $labels[$idx] = ($idx+1).
".";
662 $chart->addData($data);
664 $chart->setTicks($labels,
false,
true);
667 foreach($chart_legend as $number => $caption)
669 $legend .=
"<tr valign=\"top\"><td>".$number.
".</td><td>".$caption.
"</td></tr>";
671 $legend .=
"</table>";
673 return "<div style=\"margin:10px\"><table><tr valign=\"bottom\"><td>".
674 $chart->getHTML().
"</td><td class=\"small\" style=\"padding-left:15px\">".
675 $legend.
"</td></tr></table></div>";
690 global $rbacsystem, $ilTabs;
692 $ilTabs->activateTab(
"material");
695 if ($rbacsystem->checkAccess(
'write',
$_GET[
'ref_id']))
697 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
699 $form->setFormAction($this->ctrl->getFormAction($this));
700 $form->setTitle($this->lng->txt(
'add_material'));
701 $form->setMultipart(FALSE);
702 $form->setTableWidth(
"100%");
703 $form->setId(
"material");
708 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_lm'),
"lm"));
709 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_st'),
"st"));
710 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_pg'),
"pg"));
711 $material->addOption(
new ilRadioOption($this->lng->txt(
'glossary_term'),
"glo"));
712 $form->addItem($material);
714 $form->addCommandButton(
"addMaterial", $this->lng->txt(
"add"));
720 $form->setValuesByPost();
721 $errors = !$form->checkInput();
722 if (
$errors) $checkonly =
false;
724 $add_html = $form->getHTML();
729 if (count($this->object->getMaterial()))
731 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyMaterialsTableGUI.php";
734 foreach ($this->object->getMaterial() as $material)
736 switch ($material->type)
740 $type = $this->lng->txt(
'internal_link');
744 array_push($data, array(
'href' => $href,
'title' => $title,
'type' => $type));
746 $table_gui->setData($data);
747 $mat_html = $table_gui->getHTML();
750 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $add_html . $mat_html);
756 if (is_array(
$_POST[
'idx']))
758 $this->
object->deleteMaterials(
$_POST[
'idx']);
765 $this->ctrl->redirect($this,
'material');
773 global $tree, $ilTabs, $ilToolbar;
775 $ilTabs->activateTab(
"material");
777 $ilToolbar->addButton($this->lng->txt(
"cancel"),
778 $this->ctrl->getLinkTarget($this,
"material"));
782 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilMaterialExplorer.php");
783 switch (
$_POST[
"internalLinkType"])
804 $exp->setPathOpen((
int)
$_GET[
"ref_id"]);
805 if (!$exp->handleCommand())
807 include_once
"Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
809 $panel->setHeading($this->lng->txt(
"select_object_to_link"));
810 $panel->setBody($exp->getHTML());
812 $this->tpl->setContent($panel->getHTML());
819 $this->
object->material = array();
820 $this->
object->saveToDb();
828 $this->ctrl->redirect($this,
'material');
833 $this->
object->addInternalLink(
"il__pg_" .
$_GET[
"pg"]);
837 $this->ctrl->redirect($this,
"material");
842 $this->
object->addInternalLink(
"il__st_" .
$_GET[
"st"]);
846 $this->ctrl->redirect($this,
"material");
851 $this->
object->addInternalLink(
"il__git_" .
$_GET[
"git"]);
855 $this->ctrl->redirect($this,
"material");
862 $selectable_items = array();
864 $source_id =
$_GET[
"source_id"];
869 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
870 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
872 $cont_obj = $cont_obj_gui->object;
874 foreach($pages as $page)
876 if($page[
"type"] ==
$_SESSION[
"search_link_type"])
878 $selectable_items[] = array(
879 "item_type" => $page[
"type"]
880 ,
"item_id" => $page[
"obj_id"]
881 ,
"title" => $page[
"title"]
888 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
890 $cont_obj = $cont_obj_gui->object;
892 $ctree =& $cont_obj->getLMTree();
893 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
894 foreach($nodes as $node)
896 if($node[
"type"] ==
$_SESSION[
"search_link_type"])
898 $selectable_items[] = array(
899 "item_type" => $node[
"type"]
900 ,
"item_id" => $node[
"obj_id"]
901 ,
"title" => $node[
"title"]
908 include_once
"./Modules/Glossary/classes/class.ilObjGlossary.php";
911 $terms = $glossary->getTermList();
912 foreach($terms as $term)
914 $selectable_items[] = array(
916 ,
"item_id" => $term[
"id"]
917 ,
"title" => $term[
"term"]
923 $this->
object->addInternalLink(
"il__lm_" . $source_id);
927 if(
sizeof($selectable_items))
929 $ilTabs->activateTab(
"material");
930 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
931 $this->ctrl->setParameter($this,
"source_id", $source_id);
933 include_once
"Modules/SurveyQuestionPool/classes/tables/class.SurveyMaterialsSourceTableGUI.php";
935 $tbl->setData($selectable_items);
936 $this->tpl->setContent($tbl->getHTML());
940 if(
$_SESSION[
"search_link_type"] ==
"lm")
946 $this->ctrl->redirect($this,
"material");
951 $this->ctrl->redirect($this,
"addMaterial");
963 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
965 $form->setFormAction($this->ctrl->getFormAction($this,
"addSelectedPhrase"));
966 $form->setTitle($this->lng->txt(
"add_phrase"));
971 $form->addItem($group);
973 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
978 $opt =
new ilRadioOption($phrase_array[
"title"], $phrase_id);
979 $opt->setInfo(join($categories,
","));
980 $group->addOption($opt);
982 if($phrase_array[
"org_title"] ==
"dp_standard_numbers")
987 $opt->addSubItem($min);
992 $opt->addSubItem($max);
996 $form->addCommandButton(
"addSelectedPhrase", $this->lng->txt(
"add_phrase"));
997 $form->addCommandButton(
"editQuestion", $this->lng->txt(
"cancel"));
1009 $ilTabs->activateTab(
"edit_properties");
1016 $this->
object->saveToDb();
1022 $this->tpl->setContent($a_form->getHTML());
1028 if($form->checkInput())
1030 $phrase_id = $form->getInput(
"phrases");
1033 if (strcmp($this->object->getPhrase($phrase_id),
"dp_standard_numbers") != 0)
1035 $this->
object->addPhrase($phrase_id);
1039 $min = $form->getInput(
"lower_limit");
1040 $max = $form->getInput(
"upper_limit");
1044 $max_field = $form->getItemByPostVar(
"upper_limit");
1045 $max_field->setAlert($this->lng->txt(
"upper_limit_must_be_greater"));
1050 $this->
object->addStandardNumbers($min, $max);
1056 $this->
object->saveToDb();
1059 $this->ctrl->redirect($this,
'editQuestion');
1063 $form->setValuesByPost();
1074 global $ilTabs, $ilToolbar;
1076 $ilTabs->activateTab(
"edit_properties");
1083 $this->
object->saveToDb();
1087 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
1089 $ilToolbar->addInputItem(
$txt,
true);
1090 $ilToolbar->addFormButton($this->lng->txt(
"confirm"),
"confirmSavePhrase");
1091 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
1093 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveySavePhraseTableGUI.php";
1095 $table_gui->setDescription($this->lng->txt(
"save_phrase_introduction"));
1098 if(method_exists($this->
object,
"getCategories"))
1100 $categories = $this->
object->getCategories();
1104 $categories = $this->
object->getColumns();
1108 for ($i = 0; $i < $categories->getCategoryCount(); $i++)
1110 $cat = $categories->getCategory($i);
1113 "answer" => $cat->title,
1114 "other" => $cat->other,
1115 "scale" => $cat->scale,
1116 "neutral" => $cat->neutral
1119 $table_gui->setData($data);
1122 $this->tpl->setContent($table_gui->getHTML());
1132 $title =
$_POST[
"phrase_title"];
1140 else if ($this->object->phraseExists($title))
1148 $this->
object->savePhrase($title);
1151 $this->ctrl->redirect($this,
"editQuestion");