83 $this->rbacsystem = $DIC->rbac()->system();
84 $this->
user = $DIC->user();
85 $this->access = $DIC->access();
86 $this->tree = $DIC->repositoryTree();
87 $this->toolbar = $DIC->toolbar();
88 $lng = $DIC->language();
95 $this->ctrl->saveParameter($this,
"q_id");
96 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"sel_question_types",
$_GET[
"sel_question_types"]);
97 $this->cumulated =
array();
98 $this->tabs = $DIC->tabs();
103 $this->
object->loadFromDb($a_id);
113 $cmd = $this->ctrl->getCmd();
114 $next_class = $this->ctrl->getNextClass($this);
115 switch ($next_class) {
117 $ret =&$this->$cmd();
136 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
137 if ((!$questiontype) and ($question_id > 0)) {
138 $questiontype = SurveyQuestion::_getQuestiontype($question_id);
141 $question_type_gui = $questiontype .
"GUI";
142 $question =
new $question_type_gui($question_id);
148 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
149 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
150 $q_type = SurveyQuestion::_getQuestiontype($a_q_id);
168 return $this->
object->getQuestionType();
173 $questiontext = $this->
object->getQuestiontext();
174 if (preg_match(
"/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches)) {
175 $questiontext = $matches[1];
177 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
178 if ($this->
object->getObligatory($survey_id)) {
179 $template->setVariable(
"OBLIGATORY_TEXT",
' *');
185 $this->parent_url = $a_url;
193 $this->ctrl->setParameterByClass($guiclass,
"sel_question_types", $this->
getQuestionType());
194 $this->ctrl->setParameterByClass($guiclass,
"q_id",
$_GET[
"q_id"]);
196 if ($this->parent_url) {
198 if (strlen(
$_GET[
"new_for_survey"])) {
199 $addurl =
"&new_id=" .
$_GET[
"q_id"];
201 $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"), $this->parent_url . $addurl);
203 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI",
"q_id_table_nav",
$_SESSION[
'q_id_table_nav']);
204 $ilTabs->setBackTarget($this->lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI",
"questions"));
207 $ilTabs->addNonTabbedLink(
209 $this->lng->txt(
"preview"),
210 $this->ctrl->getLinkTargetByClass($guiclass,
"preview")
217 $this->lng->txt(
"properties"),
218 $this->ctrl->getLinkTargetByClass($guiclass,
"editQuestion")
221 if (stristr($guiclass,
"matrix")) {
224 $this->lng->txt(
"layout"),
225 $this->ctrl->getLinkTargetByClass($guiclass,
"layout")
232 $this->lng->txt(
"material"),
233 $this->ctrl->getLinkTargetByClass($guiclass,
"material")
237 if ($this->
object->getId() > 0) {
238 $title = $this->lng->txt(
"edit") .
" "" . $this->
object->getTitle() .
""";
243 $this->tpl->setVariable(
"HEADER",
$title);
253 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
255 $form->setFormAction($this->ctrl->getFormAction($this,
"save"));
256 $form->setTitle($this->lng->txt($this->getQuestionType()));
257 $form->setMultipart(
false);
258 $form->setTableWidth(
"100%");
263 $title->setRequired(
true);
268 $label->
setInfo($this->lng->txt(
"label_info"));
269 $label->setRequired(
false);
270 $form->addItem($label);
273 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
275 $form->addItem($author);
285 $question->setRows(10);
286 $question->setCols(80);
287 $question->setUseRte(
true);
288 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
290 $question->addPlugin(
"latex");
291 $question->addButton(
"latex");
292 $question->addButton(
"pastelatex");
293 $question->setRTESupport($this->
object->getId(),
"spl",
"survey");
294 $form->addItem($question);
299 $shuffle->setRequired(
false);
300 $form->addItem($shuffle);
308 $label->setValue($this->
object->label);
309 $author->setValue($this->
object->getAuthor());
311 $question->setValue($this->
object->prepareTextareaOutput($this->object->getQuestiontext()));
312 $shuffle->setChecked($this->
object->getObligatory());
319 $a_form->addCommandButton(
"saveReturn", $this->lng->txt(
"save_return"));
320 $a_form->addCommandButton(
"save", $this->lng->txt(
"save"));
324 if ($this->
object->hasCopies()) {
325 $a_form->addCommandButton(
"saveSync", $this->lng->txt(
"svy_save_sync"));
334 $ilTabs->activateTab(
"edit_properties");
339 $this->tpl->setContent($a_form->getHTML());
344 $this->
save($_REQUEST[
"rtrn"],
true);
355 if (
$form->checkInput()) {
357 $this->
object->setTitle(
$form->getInput(
"title"));
358 $this->
object->label = (
$form->getInput(
"label"));
359 $this->
object->setAuthor(
$form->getInput(
"author"));
360 $this->
object->setDescription(
$form->getInput(
"description"));
361 $this->
object->setQuestiontext(
$form->getInput(
"question"));
362 $this->
object->setObligatory(
$form->getInput(
"obligatory"));
367 $this->
object->saveToDb();
373 $form->setValuesByPost();
378 protected function save($a_return =
false, $a_sync =
false)
390 $ilUser->setPref(
"svy_lastquestiontype", $this->
object->getQuestionType());
391 $ilUser->writePref(
"svy_lastquestiontype", $this->
object->getQuestionType());
394 $this->ctrl->setParameter($this,
"q_id", $this->
object->getId());
395 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
400 $this->ctrl->redirect($this,
'copySyncForm');
403 if ($originalexists &&
406 $this->ctrl->setParameter($this,
'rtrn', 1);
408 $this->ctrl->redirect($this,
'originalSyncForm');
421 $ilTabs->activateTab(
"edit_properties");
423 include_once
"Modules/SurveyQuestionPool/classes/class.ilSurveySyncTableGUI.php";
426 $this->tpl->setContent(
$tbl->getHTML());
434 if (!
sizeof(
$_POST[
"qid"])) {
439 foreach ($this->
object->getCopyIds(
true) as $survey_id => $questions) {
443 foreach ($ref_ids as $ref_id) {
444 if ($ilAccess->checkAccess(
"edit",
"", $ref_id)) {
451 foreach ($questions as $qid) {
452 if (in_array($qid,
$_POST[
"qid"])) {
453 $id = $this->
object->getId();
455 $this->
object->setId($qid);
456 $this->
object->setOriginalId(
$id);
457 $this->
object->saveToDb();
459 $this->
object->setId(
$id);
460 $this->
object->setOriginalId(null);
477 $ilTabs->activateTab(
"edit_properties");
479 $this->ctrl->saveParameter($this,
"rtrn");
481 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
483 $cgui->setHeaderText($this->lng->txt(
"confirm_sync_questions"));
485 $cgui->setFormAction($this->ctrl->getFormAction($this,
"confirmRemoveQuestions"));
486 $cgui->setCancel($this->lng->txt(
"no"),
"cancelSync");
487 $cgui->setConfirm($this->lng->txt(
"yes"),
"sync");
489 $this->tpl->setContent($cgui->getHTML());
494 $original_id = $this->
object->original_id;
496 $this->
object->syncWithOriginal();
519 if ($this->parent_url) {
521 if (strlen(
$_GET[
"new_for_survey"])) {
522 $addurl =
"&new_id=" .
$_GET[
"q_id"];
528 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI",
"q_id_table_nav",
$_SESSION[
'q_id_table_nav']);
529 $this->ctrl->redirectByClass(
"ilObjSurveyQuestionPoolGUI",
"questions");
534 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"q_id", $this->
object->getId());
535 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"sel_question_types",
$_GET[
"sel_question_types"]);
536 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"new_for_survey",
$_GET[
"new_for_survey"]);
537 $this->ctrl->redirectByClass(
$_GET[
"cmdClass"],
"editQuestion");
543 if ($this->parent_url) {
546 $this->ctrl->redirectByClass(
"ilobjsurveyquestionpoolgui",
"questions");
558 abstract public function getPrintView($question_title = 1, $show_questiontext = 1);
562 switch ($question_title) {
567 #19448 get rid of showing only the label without title 574 if (trim($this->
object->getLabel())) {
591 $ilTabs->activateTab(
"preview");
593 $tpl =
new ilTemplate(
"tpl.il_svy_qpl_preview.html",
true,
true,
"Modules/SurveyQuestionPool");
595 if ($this->
object->getObligatory()) {
596 $tpl->setCurrentBlock(
"required");
597 $tpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
598 $tpl->parseCurrentBlock();
603 include_once
"Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
605 $panel->setBody(
$tpl->get());
607 $this->tpl->setContent($panel->getHTML());
615 abstract public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null);
622 if (count($this->
object->getMaterial())) {
623 $template =
new ilTemplate(
"tpl.il_svy_qpl_material.html",
true,
true,
"Modules/SurveyQuestionPool");
624 foreach ($this->
object->getMaterial() as $material) {
626 switch ($material->type) {
629 $template->setVariable(
'MATERIAL_TYPE',
'internallink');
630 $template->setVariable(
'MATERIAL_HREF', $href);
634 $template->setVariable(
'TEXT_AVAILABLE_MATERIALS', $this->lng->txt(
'material'));
654 $ilTabs->activateTab(
"material");
658 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
660 $form->setFormAction($this->ctrl->getFormAction($this));
661 $form->setTitle($this->lng->txt(
'add_material'));
662 $form->setMultipart(
false);
663 $form->setTableWidth(
"100%");
664 $form->setId(
"material");
669 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_lm'),
"lm"));
670 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_st'),
"st"));
671 $material->addOption(
new ilRadioOption($this->lng->txt(
'obj_pg'),
"pg"));
672 $material->addOption(
new ilRadioOption($this->lng->txt(
'glossary_term'),
"glo"));
673 $form->addItem($material);
675 $form->addCommandButton(
"addMaterial", $this->lng->txt(
"add"));
680 $form->setValuesByPost();
686 $add_html =
$form->getHTML();
691 if (count($this->
object->getMaterial())) {
692 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyMaterialsTableGUI.php";
695 foreach ($this->
object->getMaterial() as $material) {
696 switch ($material->type) {
699 $type = $this->lng->txt(
'internal_link');
703 array_push($data,
array(
'href' => $href,
'title' =>
$title,
'type' =>
$type));
705 $table_gui->setData($data);
706 $mat_html = $table_gui->getHTML();
710 $this->tpl->setVariable(
"ADM_CONTENT", $add_html . $mat_html);
717 if (is_array(
$_POST[
'idx'])) {
718 $this->
object->deleteMaterials(
$_POST[
'idx']);
723 $this->ctrl->redirect($this,
'material');
735 $ilTabs->activateTab(
"material");
737 $ilToolbar->addButton(
738 $this->lng->txt(
"cancel"),
739 $this->ctrl->getLinkTarget($this,
"material")
743 include_once(
"./Modules/SurveyQuestionPool/classes/class.ilMaterialExplorer.php");
744 switch (
$_POST[
"internalLinkType"]) {
764 $exp->setPathOpen((
int)
$_GET[
"ref_id"]);
765 if (!$exp->handleCommand()) {
766 include_once
"Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
768 $panel->setHeading($this->lng->txt(
"select_object_to_link"));
769 $panel->setBody($exp->getHTML());
771 $this->tpl->setContent($panel->getHTML());
778 $this->
object->material =
array();
779 $this->
object->saveToDb();
787 $this->ctrl->redirect($this,
'material');
792 $this->
object->addInternalLink(
"il__pg_" .
$_GET[
"pg"]);
796 $this->ctrl->redirect($this,
"material");
801 $this->
object->addInternalLink(
"il__st_" .
$_GET[
"st"]);
805 $this->ctrl->redirect($this,
"material");
810 $this->
object->addInternalLink(
"il__git_" .
$_GET[
"git"]);
814 $this->ctrl->redirect($this,
"material");
821 $selectable_items =
array();
823 $source_id =
$_GET[
"source_id"];
827 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
828 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
830 $cont_obj = $cont_obj_gui->object;
832 foreach ($pages as $page) {
833 if ($page[
"type"] ==
$_SESSION[
"search_link_type"]) {
834 $selectable_items[] =
array(
835 "item_type" => $page[
"type"]
836 ,
"item_id" => $page[
"obj_id"]
837 ,
"title" => $page[
"title"]
844 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
846 $cont_obj = $cont_obj_gui->object;
848 $ctree =&$cont_obj->getLMTree();
849 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
850 foreach ($nodes as $node) {
851 if ($node[
"type"] ==
$_SESSION[
"search_link_type"]) {
852 $selectable_items[] =
array(
853 "item_type" => $node[
"type"]
854 ,
"item_id" => $node[
"obj_id"]
855 ,
"title" => $node[
"title"]
862 include_once
"./Modules/Glossary/classes/class.ilObjGlossary.php";
865 $terms = $glossary->getTermList();
866 foreach ($terms as $term) {
867 $selectable_items[] =
array(
869 ,
"item_id" => $term[
"id"]
870 ,
"title" => $term[
"term"]
876 $this->
object->addInternalLink(
"il__lm_" . $source_id);
880 if (
sizeof($selectable_items)) {
881 $ilTabs->activateTab(
"material");
882 $this->ctrl->setParameter($this,
"q_id", $this->
object->getId());
883 $this->ctrl->setParameter($this,
"source_id", $source_id);
885 include_once
"Modules/SurveyQuestionPool/classes/tables/class.SurveyMaterialsSourceTableGUI.php";
887 $tbl->setData($selectable_items);
888 $this->tpl->setContent(
$tbl->getHTML());
890 if (
$_SESSION[
"search_link_type"] ==
"lm") {
895 $this->ctrl->redirect($this,
"material");
898 $this->ctrl->redirect($this,
"addMaterial");
910 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
912 $form->setFormAction($this->ctrl->getFormAction($this,
"addSelectedPhrase"));
913 $form->setTitle($this->lng->txt(
"add_phrase"));
918 $form->addItem($group);
920 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
924 $opt =
new ilRadioOption($phrase_array[
"title"], $phrase_id);
925 $opt->setInfo(join($categories,
","));
926 $group->addOption($opt);
928 if ($phrase_array[
"org_title"] ==
"dp_standard_numbers") {
932 $opt->addSubItem($min);
937 $opt->addSubItem($max);
941 $form->addCommandButton(
"addSelectedPhrase", $this->lng->txt(
"add_phrase"));
942 $form->addCommandButton(
"editQuestion", $this->lng->txt(
"cancel"));
954 $ilTabs->activateTab(
"edit_properties");
959 $this->
object->saveToDb();
965 $this->tpl->setContent($a_form->
getHTML());
971 if (
$form->checkInput()) {
972 $phrase_id =
$form->getInput(
"phrases");
975 if (strcmp($this->
object->getPhrase($phrase_id),
"dp_standard_numbers") != 0) {
976 $this->
object->addPhrase($phrase_id);
978 $min =
$form->getInput(
"lower_limit");
979 $max =
$form->getInput(
"upper_limit");
982 $max_field =
$form->getItemByPostVar(
"upper_limit");
983 $max_field->setAlert($this->lng->txt(
"upper_limit_must_be_greater"));
986 $this->
object->addStandardNumbers($min, $max);
991 $this->
object->saveToDb();
994 $this->ctrl->redirect($this,
'editQuestion');
998 $form->setValuesByPost();
1012 $ilTabs->activateTab(
"edit_properties");
1017 $this->
object->saveToDb();
1021 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
1023 $ilToolbar->addInputItem(
$txt,
true);
1024 $ilToolbar->addFormButton($this->lng->txt(
"confirm"),
"confirmSavePhrase");
1025 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
1027 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveySavePhraseTableGUI.php";
1029 $table_gui->setDescription($this->lng->txt(
"save_phrase_introduction"));
1032 if (method_exists($this->
object,
"getCategories")) {
1033 $categories = $this->
object->getCategories();
1035 $categories = $this->
object->getColumns();
1039 for (
$i = 0;
$i < $categories->getCategoryCount();
$i++) {
1040 $cat = $categories->getCategory(
$i);
1043 "answer" => $cat->title,
1044 "other" => $cat->other,
1045 "scale" => $cat->scale,
1046 "neutral" => $cat->neutral
1049 $table_gui->setData(
$data);
1052 $this->tpl->setContent($table_gui->getHTML());
1074 $this->
object->savePhrase(
$title);
1077 $this->ctrl->redirect($this,
"editQuestion");
1086 $html[] =
'<div class="ilTableOuter table-responsive">';
1087 $html[] =
'<table class="table table-striped">';
1089 $html[] =
"<thead>";
1091 foreach ($a_head as $col) {
1094 $html[] = ($col !=
"") ? $col :
" ";
1098 $html[] =
"</thead>";
1100 $html[] =
"<tbody>";
1101 foreach ($a_rows as
$row) {
1103 foreach ($row as $col) {
1106 $html[] = ($col !=
"") ? $col :
" ";
1111 $html[] =
"</tbody>";
1114 $html[] =
"<tfoot>";
1116 foreach ($a_foot as $col) {
1119 $html[] = ($col !=
"") ? $col :
" ";
1123 $html[] =
"</tfoot>";
1126 $html[] =
"</table>";
1128 return implode(
"\n",
$html);
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
setQuestionTabsForClass($guiclass)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
This class represents an option in a radio group.
getMaterialOutput()
Creates the HTML output of the question material(s)
static _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
Survey sync table GUI class.
redirectAfterSaving($a_return=false)
Redirect to calling survey or to edit form.
getPrintView($question_title=1, $show_questiontext=1)
outQuestionText($template)
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _isComplete($question_id)
Checks whether the question is complete or not.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
addPhrase(ilPropertyFormGUI $a_form=null)
Creates an output for the addition of phrases.
TableGUI class for survey question source materials.
getQuestionType()
Returns the question type string.
TableGUI class for survey question materials.
static _getClassNameForQType($q_type)
material($checkonly=false)
Material tab of the survey questions.
renderStatisticsDetailsTable(array $a_head, array $a_rows, array $a_foot=null)
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static _getAllReferences($a_id)
get all reference ids of object
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
preview()
Creates a preview of the question.
addMaterial()
Add materials to a question.
getWorkingForm($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
if(isset($_POST['submit'])) $form
addFieldsToEditForm(ilPropertyFormGUI $a_form)
special template class to simplify handling of ITX/PEAR
static _questionExists($question_id)
Returns true if the question already exists in the database.
validateEditForm(ilPropertyFormGUI $a_form)
This class represents a text property in a property form.
addCommandButtons($a_form)
static _getInternalLinkHref($target="", $a_parent_ref_id=null)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
savePhrase($a_reload=false)
Creates an output to save the current answers as a phrase.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
importEditFormValues(ilPropertyFormGUI $a_form)
static getInstance()
Get instance.
static _getGUIClassNameForId($a_q_id)
save($a_return=false, $a_sync=false)
Create new PHPExcel object
obj_idprivate
This class represents a text area property in a property form.
editQuestion(ilPropertyFormGUI $a_form=null)
static _getAvailablePhrases($useronly=0)
Gets the available phrases from the database.
Class ilObjContentObjectGUI.
confirmSavePhrase()
Save a new phrase to the database.
static getLogger($a_component_id)
Get component logger.
getPrintViewQuestionTitle($question_title=1)
static getPageList($lm_id)
static
static redirect($a_script)
Basic class for all survey question types.
Confirmation screen class.