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