ILIAS  release_8 Revision v8.24
class.ilObjSurveyQuestionPoolGUI.php
Go to the documentation of this file.
1<?php
2
20
33{
34 protected \ILIAS\SurveyQuestionPool\Editing\EditManager $edit_manager;
35 protected bool $update;
38 protected ilHelpGUI $help;
39 protected ilLogger $log;
40 public string $defaultscript;
41
42 public function __construct()
43 {
44 global $DIC;
45
46 $this->nav_history = $DIC["ilNavigationHistory"];
47 $this->toolbar = $DIC->toolbar();
48 $this->help = $DIC["ilHelp"];
49
50 $this->edit_request = $DIC->surveyQuestionPool()
51 ->internal()
52 ->gui()
53 ->editing()
54 ->request();
55 $this->edit_manager = $DIC->surveyQuestionPool()
56 ->internal()
57 ->domain()
58 ->editing();
59
60 $this->type = "spl";
61
63 "",
64 $this->edit_request->getRefId(),
65 true,
66 false
67 );
68 $this->lng->loadLanguageModule("survey");
69 $this->ctrl->saveParameter($this, array("ref_id"));
70 $this->log = ilLoggerFactory::getLogger('svy');
71 }
72
73 public function executeCommand(): void
74 {
75 $ilNavigationHistory = $this->nav_history;
76
77 if (!$this->checkPermissionBool("visible") &&
78 !$this->checkPermissionBool("read")) {
79 $this->checkPermission("read");
80 }
81
82 // add entry to navigation history
83 if (!$this->getCreationMode() &&
84 $this->checkPermissionBool("read")) {
85 $ilNavigationHistory->addItem(
86 $this->ref_id,
87 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=" . $this->ref_id,
88 "spl"
89 );
90 }
91
92 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "Modules/Survey"), "screen");
93 $this->prepareOutput();
94
95 $cmd = $this->ctrl->getCmd("questions");
96 $next_class = $this->ctrl->getNextClass($this);
97 $this->ctrl->setReturn($this, "questions");
98 $q_type = "";
99 if ($this->edit_request->getQuestionId() < 1) {
100 $q_type = $this->edit_request->getSelectedQuestionTypes();
101 }
102
103 $this->log->debug("- cmd=" . $cmd . " next_class=" . $next_class);
104 switch ($next_class) {
105 case 'ilobjectmetadatagui':
106 $this->checkPermission('write');
107 $md_gui = new ilObjectMetaDataGUI($this->object);
108 $this->ctrl->forwardCommand($md_gui);
109 break;
110
111 case 'ilpermissiongui':
112 $perm_gui = new ilPermissionGUI($this);
113 $this->ctrl->forwardCommand($perm_gui);
114 break;
115
116 case "ilsurveyphrasesgui":
117 $phrases_gui = new ilSurveyPhrasesGUI($this);
118 $this->ctrl->forwardCommand($phrases_gui);
119 break;
120
121 case 'ilobjectcopygui':
122 $cp = new ilObjectCopyGUI($this);
123 $cp->setType('spl');
124 $this->ctrl->forwardCommand($cp);
125 break;
126
127 case 'ilinfoscreengui':
128 $this->infoScreenForward();
129 break;
130
131 case "ilcommonactiondispatchergui":
133 $this->ctrl->forwardCommand($gui);
134 break;
135
136 case "":
137 $cmd .= "Object";
138 $this->$cmd();
139 break;
140
141 default:
143 $q_type,
144 $this->edit_request->getQuestionId()
145 );
146 $this->log->debug("- This is the switch/case default, going to question id =" . $this->edit_request->getQuestionId());
147 $q_gui->setQuestionTabs();
148 $this->ctrl->forwardCommand($q_gui);
149
150 // not on create
151 if ($q_gui->object->isComplete()) {
152 $this->tpl->setTitle($this->lng->txt("question") . ": " . $q_gui->object->getTitle());
153 }
154 break;
155 }
156 if (strtolower($this->edit_request->getBaseClass()) !== "iladministrationgui" &&
157 $this->getCreationMode() !== true) {
158 $this->tpl->printToStdout();
159 }
160 }
161
162 protected function initEditForm(): ilPropertyFormGUI
163 {
164 $obj_service = $this->object_service;
165
166 $form = new ilPropertyFormGUI();
167 $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
168 $form->setTitle($this->lng->txt("properties"));
169 $form->setMultipart(false);
170 $form->setId("properties");
171
172 // title
173 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
174 $title->setSubmitFormOnEnter(true);
175 $title->setValue($this->object->getTitle());
176 $title->setSize(min(40, ilObject::TITLE_LENGTH));
177 $title->setMaxLength(ilObject::TITLE_LENGTH);
178 $title->setRequired(true);
179 $form->addItem($title);
180
181 // desc
182 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
183 $desc->setValue($this->object->getLongDescription());
184 $desc->setRows(2);
185 $desc->setCols(40);
186 $form->addItem($desc);
187
188 // online
189 $online = new ilCheckboxInputGUI($this->lng->txt("spl_online_property"), "online");
190 $online->setInfo($this->lng->txt("spl_online_property_description"));
191 $online->setChecked($this->object->getOnline());
192 $form->addItem($online);
193
194 $section = new ilFormSectionHeaderGUI();
195 $section->setTitle($this->lng->txt('obj_presentation'));
196 $form->addItem($section);
197
198 // tile image
199 $obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
200
201 $form->addCommandButton("saveProperties", $this->lng->txt("save"));
202
203 return $form;
204 }
205
209 public function propertiesObject(ilPropertyFormGUI $a_form = null): void
210 {
211 if (!$a_form) {
212 $a_form = $this->initEditForm();
213 }
214
215 $this->tpl->setVariable("ADM_CONTENT", $a_form->getHTML());
216 }
217
218 public function savePropertiesObject(): void
219 {
220 $obj_service = $this->object_service;
221 $form = $this->initEditForm();
222 if ($form->checkInput()) {
223 $this->object->setTitle($form->getInput("title"));
224 $this->object->setDescription($form->getInput("desc"));
225 $this->object->setOnline((int) $form->getInput("online"));
226
227 $this->object->saveToDb();
228
229 // tile image
230 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
231
232 $this->tpl->setOnScreenMessage('success', $this->lng->txt("saved_successfully"), true);
233 $this->ctrl->redirect($this, "properties");
234 }
235
236 $form->setValuesByPost();
237 $this->propertiesObject($form);
238 }
239
240
244 public function copyObject(): void
245 {
246 $qids = $this->edit_request->getQuestionIds();
247 if (count($qids) > 0) {
248 foreach ($qids as $key => $value) {
249 $this->object->copyToClipboard($value);
250 }
251 $this->tpl->setOnScreenMessage('info', $this->lng->txt("spl_copy_insert_clipboard"), true);
252 } else {
253 $this->tpl->setOnScreenMessage('info', $this->lng->txt("spl_copy_select_none"), true);
254 }
255 $this->ctrl->redirect($this, "questions");
256 }
257
261 public function moveObject(): void
262 {
263 $qids = $this->edit_request->getQuestionIds();
264 if (count($qids) > 0) {
265 foreach ($qids as $key => $value) {
266 $this->object->moveToClipboard($value);
267 }
268 $this->tpl->setOnScreenMessage('info', $this->lng->txt("spl_move_insert_clipboard"), true);
269 } else {
270 $this->tpl->setOnScreenMessage('info', $this->lng->txt("spl_move_select_none"), true);
271 }
272 $this->ctrl->redirect($this, "questions");
273 }
274
278 public function exportQuestionObject(): void
279 {
280 $qids = $this->edit_request->getQuestionIds();
281 if (count($qids) > 0) {
282 $this->createExportFileObject($qids);
283 } else {
284 $this->tpl->setOnScreenMessage('info', $this->lng->txt("qpl_export_select_none"));
285 $this->questionsObject();
286 }
287 }
288
292 public function deleteQuestionsObject(): void
293 {
294 $this->checkPermission('write');
295
296 // create an array of all checked checkboxes
297 $checked_questions = $this->edit_request->getQuestionIds();
298 if (count($checked_questions) === 0) {
299 $this->tpl->setOnScreenMessage('info', $this->lng->txt("qpl_delete_select_none"));
300 $this->questionsObject();
301 return;
302 }
303
304 $cgui = new ilConfirmationGUI();
305 $cgui->setHeaderText($this->lng->txt("qpl_confirm_delete_questions"));
306
307 $cgui->setFormAction($this->ctrl->getFormAction($this));
308 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteQuestions");
309 $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteQuestions");
310
311 $infos = $this->object->getQuestionInfos($checked_questions);
312 foreach ($infos as $data) {
313 $txt = $data["title"] . " (" .
315 if ($data["description"]) {
316 $txt .= "<div class=\"small\">" . $data["description"] . "</div>";
317 }
318
319 $cgui->addItem("q_id[]", $data["id"], $txt);
320 }
321
322 $this->tpl->setContent($cgui->getHTML());
323 }
324
325 public function confirmDeleteQuestionsObject(): void
326 {
327 // delete questions after confirmation
328 $this->tpl->setOnScreenMessage('success', $this->lng->txt("qpl_questions_deleted"), true);
329 $qids = $this->edit_request->getQuestionIds();
330 foreach ($qids as $q_id) {
331 $this->object->removeQuestion($q_id);
332 }
333 $this->ctrl->redirect($this, "questions");
334 }
335
336 public function cancelDeleteQuestionsObject(): void
337 {
338 // delete questions after confirmation
339 $this->ctrl->redirect($this, "questions");
340 }
341
345 public function pasteObject(): void
346 {
347 $clip_questions = $this->edit_manager->getQuestionsFromClipboard();
348 if (count($clip_questions) > 0) {
349 $this->object->pasteFromClipboard();
350 } else {
351 $this->tpl->setOnScreenMessage('info', $this->lng->txt("spl_paste_no_objects"), true);
352 }
353 $this->ctrl->redirect($this, "questions");
354 }
355
359 public function importQuestionsObject(): void
360 {
362 $form = $this->getImportForm();
363 $tpl->setContent($form->getHTML());
364 }
365
367 {
368 $form = new ilPropertyFormGUI();
369 $form->setFormAction($this->ctrl->getFormAction($this, "uploadQuestions"));
370 $form->setTitle($this->lng->txt("import_question"));
371
372 $fi = new ilFileInputGUI($this->lng->txt("select_file"), "qtidoc");
373 $fi->setSuffixes(array("xml", "zip"));
374 $fi->setRequired(true);
375 $form->addItem($fi);
376
377 $form->addCommandButton("uploadQuestions", $this->lng->txt("import"));
378 $form->addCommandButton("questions", $this->lng->txt("cancel"));
379 return $form;
380 }
381
385 public function uploadQuestionsObject(): void
386 {
387 $form = $this->getImportForm();
388 if ($form->checkInput()) {
389 // check if file was uploaded
390 $source = $_FILES["qtidoc"]["tmp_name"];
391 $error = 0;
392 if (($source === 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK) {
393 $error = 1;
394 }
395 // check correct file type
396 if (!$error && strpos("xml", $_FILES["qtidoc"]["type"]) !== false) {
397 $error = 1;
398 }
399 if (!$error) {
400 // import file into questionpool
401 // create import directory
402 $this->object->createImportDirectory();
403
404 // copy uploaded file to import directory
405 $full_path = $this->object->getImportDirectory() . "/" . $_FILES["qtidoc"]["name"];
406
408 $_FILES["qtidoc"]["tmp_name"],
409 $_FILES["qtidoc"]["name"],
410 $full_path
411 );
412 $source = $full_path;
413 $this->object->importObject($source, true);
414 unlink($source);
415 }
416 $this->ctrl->redirect($this, "questions");
417 } else {
418 $form->setValuesByPost();
420 $tpl->setContent($form->getHTML());
421 }
422 }
423
424 public function filterQuestionBrowserObject(): void
425 {
426 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
427 $table_gui->writeFilterToSession();
428 $this->ctrl->redirect($this, 'questions');
429 }
430
431 public function resetfilterQuestionBrowserObject(): void
432 {
433 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
434 $table_gui->resetFilter();
435 $this->ctrl->redirect($this, 'questions');
436 }
437
441 public function questionsObject(): void
442 {
444 $ilToolbar = $this->toolbar;
445
446 $this->object->purgeQuestions();
447
448 if ($this->checkPermissionBool('write')) {
449 $qtypes = new ilSelectInputGUI("", "sel_question_types");
450 $qtypes->setValue($ilUser->getPref("svy_lastquestiontype"));
451 $ilToolbar->addInputItem($qtypes);
452
453 $options = array();
454 foreach (ilObjSurveyQuestionPool::_getQuestiontypes() as $translation => $data) {
455 $options[$data["type_tag"]] = $translation;
456 }
457 $qtypes->setOptions($options);
458
459 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
460
461 $button = ilSubmitButton::getInstance();
462 $button->setCaption("svy_create_question");
463 $button->setCommand("createQuestion");
464 $ilToolbar->addButtonInstance($button);
465
466 $ilToolbar->addSeparator();
467
468 $button = ilSubmitButton::getInstance();
469 $button->setCaption("import");
470 $button->setCommand("importQuestions");
471 $ilToolbar->addButtonInstance($button);
472 }
473
474 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions', $this->checkPermissionBool('write'));
475 $table_gui->setEditable($this->checkPermissionBool('write'));
476 $arrFilter = array();
477 foreach ($table_gui->getFilterItems() as $item) {
478 if ($item->getValue() !== false) {
479 $arrFilter[$item->getPostVar()] = $item->getValue();
480 }
481 }
482 $table_gui->setData($this->object->getQuestionsData($arrFilter));
483 $this->tpl->setContent($table_gui->getHTML());
484 }
485
486 public function updateObject(): void
487 {
488 $this->update = $this->object->update();
489 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
490 }
491
492 protected function afterSave(ilObject $new_object): void
493 {
494 // always send a message
495 $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
496
497 ilUtil::redirect("ilias.php?ref_id=" . $new_object->getRefId() .
498 "&baseClass=ilObjSurveyQuestionPoolGUI");
499 }
500
504 public function exportObject(): void
505 {
506 $ilToolbar = $this->toolbar;
507
508 $ilToolbar->addButton(
509 $this->lng->txt('create_export_file'),
510 $this->ctrl->getLinkTarget($this, 'createExportFile')
511 );
512
513 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export');
514 $export_dir = $this->object->getExportDirectory();
515 $export_files = $this->object->getExportFiles($export_dir);
516 $data = array();
517 foreach ($export_files as $exp_file) {
518 $file_arr = explode("__", $exp_file);
519 $data[] = array('file' => $exp_file,
520 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)),
521 'size' => filesize($export_dir . "/" . $exp_file)
522 );
523 }
524 $table_gui->setData($data);
525 $this->tpl->setContent($table_gui->getHTML());
526 }
527
531 public function createExportFileObject($questions = null): void
532 {
533 $this->checkPermission("write");
534
536 $svy = $this->object;
537 $survey_exp = new ilSurveyQuestionpoolExport($svy);
538 $survey_exp->buildExportFile($questions);
539 $this->ctrl->redirect($this, "export");
540 }
541
545 public function downloadExportFileObject(): void
546 {
547 $files = $this->edit_request->getFiles();
548 if (count($files) === 0) {
549 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
550 $this->ctrl->redirect($this, "export");
551 }
552
553 if (count($files) > 1) {
554 $this->tpl->setOnScreenMessage('info', $this->lng->txt("select_max_one_item"), true);
555 $this->ctrl->redirect($this, "export");
556 }
557
558
559 $export_dir = $this->object->getExportDirectory();
560
561 $file = basename($files[0]);
562
563 ilFileDelivery::deliverFileLegacy($export_dir . "/" . $file, $file);
564 }
565
569 public function confirmDeleteExportFileObject(): void
570 {
571 $files = $this->edit_request->getFiles();
572 if (count($files) === 0) {
573 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
574 $this->ctrl->redirect($this, "export");
575 }
576
577 $this->tpl->setOnScreenMessage('question', $this->lng->txt("info_delete_sure"));
578 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export', true);
579 $export_dir = $this->object->getExportDirectory();
580 $data = array();
581 foreach ($files as $exp_file) {
582 $file_arr = explode("__", $exp_file);
583 $data[] = array('file' => $exp_file,
584 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)),
585 'size' => filesize($export_dir . "/" . $exp_file)
586 );
587 }
588 $table_gui->setData($data);
589 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
590 }
591
592 public function cancelDeleteExportFileObject(): void
593 {
594 ilSession::clear("ilExportFiles");
595 $this->ctrl->redirect($this, "export");
596 }
597
598 public function deleteExportFileObject(): void
599 {
600 $export_dir = $this->object->getExportDirectory();
601 $files = $this->edit_request->getFiles();
602 foreach ($files as $file) {
603 $file = basename($file);
604
605 $exp_file = $export_dir . "/" . $file;
606 $exp_dir = $export_dir . "/" . substr($file, 0, -4);
607 if (is_file($exp_file)) {
608 unlink($exp_file);
609 }
610 if (is_dir($exp_dir)) {
611 ilFileUtils::delDir($exp_dir);
612 }
613 }
614 $this->ctrl->redirect($this, "export");
615 }
616
617 protected function initImportForm(string $new_type): ilPropertyFormGUI
618 {
619 $form = parent::initImportForm($new_type);
620 $form->getItemByPostVar('importfile')->setSuffixes(array("zip", "xml"));
621
622 return $form;
623 }
624
625 protected function initCreationForms(string $new_type): array
626 {
627 $form = $this->initImportForm($new_type);
628
629 $forms = array(self::CFORM_NEW => $this->initCreateForm($new_type),
630 self::CFORM_IMPORT => $form);
631
632 return $forms;
633 }
634
635 protected function importFileObject(int $parent_id = null): void
636 {
638
639 if (!$parent_id) {
640 $parent_id = $this->edit_request->getRefId();
641 }
642 $new_type = $this->edit_request->getNewType();
643
644 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
645 if (!$this->checkPermissionBool("create", "", $new_type)) {
646 throw new ilPermissionException($this->lng->txt("no_create_permission"));
647 }
648
649 $this->lng->loadLanguageModule($new_type);
650 $this->ctrl->setParameter($this, "new_type", $new_type);
651
652 $form = $this->initImportForm($new_type);
653 if ($form->checkInput()) {
654 $newObj = new ilObjSurveyQuestionPool();
655 $newObj->setType($new_type);
656 $newObj->setTitle("dummy");
657 $newObj->create(true);
658 $this->putObjectInTree($newObj);
659
660 $newObj->createImportDirectory();
661
662 // copy uploaded file to import directory
663 $upload = $_FILES["importfile"];
664 $file = pathinfo($upload["name"]);
665 $full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
667 $upload["tmp_name"],
668 $upload["name"],
669 $full_path
670 );
671
672 // import qti data
673 $newObj->importObject($full_path);
674
675 $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_imported"), true);
676 ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() .
677 "&baseClass=ilObjSurveyQuestionPoolGUI");
678 }
679
680 // display form to correct errors
681 $form->setValuesByPost();
682 $tpl->setContent($form->getHTML());
683 }
684
688 public function createQuestionObject(): void
689 {
691
692 $ilUser->writePref(
693 "svy_lastquestiontype",
694 $this->edit_request->getSelectedQuestionTypes()
695 );
696
698 $this->edit_request->getSelectedQuestionTypes()
699 );
700 $q_gui->object->setObjId($this->object->getId());
701 $q_gui->object->createNewQuestion();
702
703 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
704 $this->ctrl->setParameterByClass(
705 get_class($q_gui),
706 "sel_question_types",
707 $this->edit_request->getSelectedQuestionTypes()
708 );
709 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
710 }
711
715 public function previewObject(): void
716 {
718 "",
719 $this->edit_request->getPreview()
720 );
721 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
722 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $this->edit_request->getPreview());
723 $this->ctrl->redirectByClass(get_class($q_gui), "preview");
724 }
725
729 public function infoScreenObject(): void
730 {
731 $this->ctrl->setCmd("showSummary");
732 $this->ctrl->setCmdClass("ilinfoscreengui");
733 $this->infoScreenForward();
734 }
735
739 public function infoScreenForward(): void
740 {
741 if (!$this->checkPermissionBool("read")) {
742 $this->checkPermission("visible");
743 }
744
745 $info = new ilInfoScreenGUI($this);
746 $info->enablePrivateNotes();
747
748 // standard meta data
749 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
750
751 $this->ctrl->forwardCommand($info);
752 }
753
754 protected function addLocatorItems(): void
755 {
756 $ilLocator = $this->locator;
757 switch ($this->ctrl->getCmd()) {
758 case "create":
759 case "importFile":
760 case "cancel":
761 break;
762 default:
763 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->edit_request->getRefId());
764 break;
765 }
766 if ($this->edit_request->getQuestionId() > 0) {
767 $q_id = $this->edit_request->getQuestionId();
768 $q_type = SurveyQuestion::_getQuestionType($q_id) . "GUI";
769 $q_title = SurveyQuestion::_getTitle($q_id);
770 if ($q_title) {
771 // not on create
772 $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
773 $ilLocator->addItem(
774 $q_title,
775 $this->ctrl->getLinkTargetByClass($q_type, "editQuestion")
776 );
777 }
778 }
779 }
780
781 protected function getTabs(): void
782 {
783 $ilHelp = $this->help;
784
785 $ilHelp->setScreenIdComponent("spl");
786
787 $next_class = $this->ctrl->getNextClass($this);
788 switch ($next_class) {
789 case "":
790 case "ilpermissiongui":
791 case "ilobjectmetadatagui":
792 case "ilsurveyphrasesgui":
793 break;
794 default:
795 return;
796 }
797
798 // questions
799 $force_active = ($this->ctrl->getCmdClass() === "" &&
800 $this->ctrl->getCmd() !== "properties" && $this->ctrl->getCmd() !== "infoScreen") ||
801 ($this->ctrl->getCmd() === "" || $this->ctrl->getCmd() === null);
802 if (!$force_active) {
803 $sort = $this->edit_request->getSort();
804 if (count($sort) > 0) {
805 $force_active = true;
806 }
807 }
808
809 if ($this->checkPermissionBool("read")) {
810 $this->tabs_gui->addTarget(
811 "survey_questions",
812 $this->ctrl->getLinkTarget($this, 'questions'),
813 array("questions", "filterQuestionBrowser", "filter", "reset", "createQuestion",
814 "importQuestions", "deleteQuestions", "copy", "paste",
815 "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
816 "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
817 "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
818 "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
819 "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
820 "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
821 "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
822 "cancelDeleteCategory", "categories", "saveCategories",
823 "savePhrase", "addPhrase"
824 ),
825 array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"),
826 "",
827 $force_active
828 );
829
830 $this->tabs_gui->addTarget(
831 "info_short",
832 $this->ctrl->getLinkTarget($this, "infoScreen"),
833 array("infoScreen", "showSummary")
834 );
835 }
836
837 if ($this->checkPermissionBool('write')) {
838 // properties
839 $this->tabs_gui->addTarget(
840 "settings",
841 $this->ctrl->getLinkTarget($this, 'properties'),
842 array("properties", "saveProperties"),
843 "",
844 ""
845 );
846
847 // manage phrases
848 $this->tabs_gui->addTarget(
849 "manage_phrases",
850 $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
851 array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase", "editPhrase", "newPhrase", "saveEditPhrase", "phraseEditor"),
852 "ilsurveyphrasesgui",
853 ""
854 );
855
856 // meta data
857 $mdgui = new ilObjectMetaDataGUI($this->object);
858 $mdtab = $mdgui->getTab();
859 if ($mdtab) {
860 $this->tabs_gui->addTarget(
861 "meta_data",
862 $mdtab,
863 "",
864 "ilmdeditorgui"
865 );
866 }
867
868 // export
869 $this->tabs_gui->addTarget(
870 "export",
871 $this->ctrl->getLinkTarget($this, 'export'),
872 array("export", "createExportFile", "confirmDeleteExportFile",
873 "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
874 "",
875 ""
876 );
877 }
878
879 if ($this->checkPermissionBool("edit_permission")) {
880 $this->tabs_gui->addTarget(
881 "perm_settings",
882 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
883 array("perm","info","owner"),
884 'ilpermissiongui'
885 );
886 }
887 }
888
892 public function saveObligatoryObject(): void
893 {
894 $obligatory = $this->edit_request->getObligatory();
895 $this->object->setObligatoryStates($obligatory);
896
897 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
898 $this->ctrl->redirect($this, "questions");
899 }
900
904 public static function _goto(string $a_target): void
905 {
906 global $DIC;
907 $main_tpl = $DIC->ui()->mainTemplate();
908
909 $ctrl = $DIC->ctrl();
910 $ilAccess = $DIC->access();
911 $lng = $DIC->language();
912
913 if ($ilAccess->checkAccess("visible", "", $a_target) ||
914 $ilAccess->checkAccess("read", "", $a_target)) {
915 $ctrl->setParameterByClass("ilObjSurveyQuestionPoolGUI", "ref_id", $a_target);
916 $ctrl->redirectByClass("ilObjSurveyQuestionPoolGUI", "infoScreen");
917 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
918 $main_tpl->setOnScreenMessage('failure', sprintf(
919 $lng->txt("msg_no_perm_read_item"),
921 ), true);
923 }
924 }
925}
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
static _getTitle(int $question_id)
Returns the question title of a question with a given id.
static _getQuestionTypeName(string $type_tag)
Return the translation for a given question type.
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
const IL_CAL_UNIX
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
This class represents a file property in a property form.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Help GUI class.
setScreenIdComponent(string $a_comp)
Class ilInfoScreenGUI.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
Navigation History of Repository Items.
Class ilObjSurveyQuestionPoolGUI.
uploadQuestionsObject()
imports question(s) into the questionpool
copyObject()
Copies checked questions in the questionpool to a clipboard.
ILIAS SurveyQuestionPool Editing EditManager $edit_manager
static _goto(string $a_target)
Redirect script to call a survey question pool reference id.
afterSave(ilObject $new_object)
Post (successful) object creation hook.
infoScreenObject()
this one is called from the info button in the repository
propertiesObject(ilPropertyFormGUI $a_form=null)
Edit question pool properties.
getTabs()
@abstract overwrite in derived GUI class of your object type
pasteObject()
paste questions from the clipboard into the question pool
importQuestionsObject()
display the import form to import questions into the question pool
initCreationForms(string $new_type)
Init creation forms.
deleteQuestionsObject()
Creates a confirmation form to delete questions from the question pool.
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
moveObject()
mark one or more question objects for moving
confirmDeleteExportFileObject()
confirmation screen for export file deletion
questionsObject()
list questions of question pool
updateObject()
updates object entry in object_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getQuestiontypes()
Get all available question types.
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
ilGlobalTemplateInterface $tpl
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilObjectService $object_service
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilErrorHandling $error
ilToolbarGUI $toolbar
ilLocatorGUI $locator
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
initCreateForm(string $new_type)
putObjectInTree(ilObject $obj, int $parent_node_id=null)
Add object to tree at given position.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TITLE_LENGTH
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a selection list property in a property form.
static clear(string $a_var)
Survey phrases GUI class The ilSurveyPhrases GUI class creates the GUI output for survey phrases (col...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
addButton(string $a_txt, string $a_cmd, string $a_target="", ?int $a_acc_key=null, string $a_additional_attrs='', string $a_id="", string $a_class='submit')
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect(string $a_script)
const ROOT_FOLDER_ID
Definition: constants.php:32
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
setContent(string $a_html)
Sets content for standard template.
$source
Definition: metadata.php:93
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193