ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjSurveyQuestionPoolGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once "./Services/Object/classes/class.ilObjectGUI.php";
25
43{
47 protected $nav_history;
48
52 protected $error;
53
57 protected $help;
58
62 protected $log;
63
65
70 public function __construct()
71 {
72 global $DIC;
73
74 $this->lng = $DIC->language();
75 $this->nav_history = $DIC["ilNavigationHistory"];
76 $this->tpl = $DIC["tpl"];
77 $this->user = $DIC->user();
78 $this->toolbar = $DIC->toolbar();
79 $this->error = $DIC["ilErr"];
80 $this->locator = $DIC["ilLocator"];
81 $this->help = $DIC["ilHelp"];
82 $lng = $DIC->language();
83 $ilCtrl = $DIC->ctrl();
84
85 $this->type = "spl";
86 $lng->loadLanguageModule("survey");
87 $this->ctrl = $ilCtrl;
88 $this->ctrl->saveParameter($this, array("ref_id"));
89
90 parent::__construct("", $_GET["ref_id"], true, false);
91
92 $this->log = ilLoggerFactory::getLogger('svy');
93 }
94
98 public function executeCommand()
99 {
100 $ilNavigationHistory = $this->nav_history;
101
102 if (!$this->checkPermissionBool("visible") &&
103 !$this->checkPermissionBool("read")) {
104 $this->checkPermission("read");
105 }
106
107 // add entry to navigation history
108 if (!$this->getCreationMode() &&
109 $this->checkPermissionBool("read")) {
110 $ilNavigationHistory->addItem(
111 $this->ref_id,
112 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=" . $this->ref_id,
113 "spl"
114 );
115 }
116
117 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "Modules/Survey"), "screen");
118 $this->prepareOutput();
119
120 $cmd = $this->ctrl->getCmd("questions");
121 $next_class = $this->ctrl->getNextClass($this);
122 $this->ctrl->setReturn($this, "questions");
123 if ($_GET["q_id"] < 1) {
124 $q_type = ($_POST["sel_question_types"] != "")
125 ? $_POST["sel_question_types"]
126 : $_GET["sel_question_types"];
127 }
128
129 $this->log->debug("- cmd=" . $cmd . " next_class=" . $next_class);
130 switch ($next_class) {
131 case 'ilobjectmetadatagui':
132 $this->checkPermission('write');
133 include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
134 $md_gui = new ilObjectMetaDataGUI($this->object);
135 $this->ctrl->forwardCommand($md_gui);
136 break;
137
138 case 'ilpermissiongui':
139 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
140 $perm_gui = new ilPermissionGUI($this);
141 $ret = &$this->ctrl->forwardCommand($perm_gui);
142 break;
143
144 case "ilsurveyphrasesgui":
145 include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
146 $phrases_gui = new ilSurveyPhrasesGUI($this);
147 $ret = &$this->ctrl->forwardCommand($phrases_gui);
148 break;
149
150 case 'ilobjectcopygui':
151 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
152 $cp = new ilObjectCopyGUI($this);
153 $cp->setType('spl');
154 $this->ctrl->forwardCommand($cp);
155 break;
156
157 case 'ilinfoscreengui':
158 $this->infoScreenForward();
159 break;
160
161 case "ilcommonactiondispatchergui":
162 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
164 $this->ctrl->forwardCommand($gui);
165 break;
166
167 case "":
168 $cmd .= "Object";
169 $ret = &$this->$cmd();
170 break;
171
172 default:
173 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
174 $q_gui = SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
175 $this->log->debug("- This is the switch/case default, going to question id =" . $_GET["q_id"]);
176 // $q_gui->object->setObjId($this->object->getId());
177 $q_gui->setQuestionTabs();
178 $ret = &$this->ctrl->forwardCommand($q_gui);
179
180 // not on create
181 if ($q_gui->object->isComplete()) {
182 $this->tpl->setTitle($this->lng->txt("question") . ": " . $q_gui->object->getTitle());
183 }
184 break;
185 }
186 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
187 $this->getCreationMode() != true) {
188 $this->tpl->show();
189 }
190 }
191
192 protected function initEditForm()
193 {
194 $obj_service = $this->object_service;
195
196 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
197 $form = new ilPropertyFormGUI();
198 $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
199 $form->setTitle($this->lng->txt("properties"));
200 $form->setMultipart(false);
201 $form->setId("properties");
202
203 // title
204 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
205 $title->setSubmitFormOnEnter(true);
206 $title->setValue($this->object->getTitle());
207 $title->setSize(min(40, ilObject::TITLE_LENGTH));
208 $title->setMaxLength(ilObject::TITLE_LENGTH);
209 $title->setRequired(true);
210 $form->addItem($title);
211
212 // desc
213 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
214 $desc->setValue($this->object->getLongDescription());
215 $desc->setRows(2);
216 $desc->setCols(40);
217 $form->addItem($desc);
218
219 // online
220 $online = new ilCheckboxInputGUI($this->lng->txt("spl_online_property"), "online");
221 $online->setInfo($this->lng->txt("spl_online_property_description"));
222 $online->setChecked($this->object->getOnline());
223 $form->addItem($online);
224
226 $section->setTitle($this->lng->txt('obj_presentation'));
227 $form->addItem($section);
228
229 // tile image
230 $obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
231
232
233 $form->addCommandButton("saveProperties", $this->lng->txt("save"));
234
235 return $form;
236 }
237
241 public function propertiesObject(ilPropertyFormGUI $a_form = null)
242 {
243 if (!$a_form) {
244 $a_form = $this->initEditForm();
245 }
246
247 $this->tpl->setVariable("ADM_CONTENT", $a_form->getHTML());
248 }
249
253 public function savePropertiesObject()
254 {
255 $obj_service = $this->object_service;
256 $form = $this->initEditForm();
257 if ($form->checkInput()) {
258 $this->object->setTitle($form->getInput("title"));
259 $this->object->setDescription($form->getInput("desc"));
260 $this->object->setOnline((int) $form->getInput("online"));
261
262 $this->object->saveToDb();
263
264 // tile image
265 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
266
267
268 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
269 $this->ctrl->redirect($this, "properties");
270 }
271
272 $form->setValuesByPost();
273 $this->propertiesObject($form);
274 }
275
276
280 public function copyObject()
281 {
282 if (count($_POST["q_id"]) > 0) {
283 foreach ($_POST["q_id"] as $key => $value) {
284 $this->object->copyToClipboard($value);
285 }
286 ilUtil::sendInfo($this->lng->txt("spl_copy_insert_clipboard"), true);
287 } else {
288 ilUtil::sendInfo($this->lng->txt("spl_copy_select_none"), true);
289 }
290 $this->ctrl->redirect($this, "questions");
291 }
292
296 public function moveObject()
297 {
298 if (count($_POST["q_id"]) > 0) {
299 foreach ($_POST["q_id"] as $key => $value) {
300 $this->object->moveToClipboard($value);
301 }
302 ilUtil::sendInfo($this->lng->txt("spl_move_insert_clipboard"), true);
303 } else {
304 ilUtil::sendInfo($this->lng->txt("spl_move_select_none"), true);
305 }
306 $this->ctrl->redirect($this, "questions");
307 }
308
312 public function exportQuestionObject()
313 {
314 if (is_array($_POST['q_id']) && count($_POST['q_id']) > 0) {
315 $this->createExportFileObject($_POST['q_id']);
316 } else {
317 ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"));
318 $this->questionsObject();
319 }
320 }
321
325 public function deleteQuestionsObject()
326 {
327 $this->checkPermission('write');
328
329 // create an array of all checked checkboxes
330 $checked_questions = $_POST['q_id'];
331 if (count($checked_questions) == 0) {
332 ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
333 $this->questionsObject();
334 return;
335 }
336
337 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
338 $cgui = new ilConfirmationGUI();
339 $cgui->setHeaderText($this->lng->txt("qpl_confirm_delete_questions"));
340
341 $cgui->setFormAction($this->ctrl->getFormAction($this));
342 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteQuestions");
343 $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteQuestions");
344
345 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
346 $infos = $this->object->getQuestionInfos($checked_questions);
347 foreach ($infos as $data) {
348 $txt = $data["title"] . " (" .
350 if ($data["description"]) {
351 $txt .= "<div class=\"small\">" . $data["description"] . "</div>";
352 }
353
354 $cgui->addItem("q_id[]", $data["id"], $txt);
355 }
356
357 $this->tpl->setContent($cgui->getHTML());
358 }
359
364 {
365 // delete questions after confirmation
366 ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
367 foreach ($_POST['q_id'] as $q_id) {
368 $this->object->removeQuestion($q_id);
369 }
370 $this->ctrl->redirect($this, "questions");
371 }
372
377 {
378 // delete questions after confirmation
379 $this->ctrl->redirect($this, "questions");
380 }
381
385 public function pasteObject()
386 {
387 if (array_key_exists("spl_clipboard", $_SESSION)) {
388 $this->object->pasteFromClipboard();
389 } else {
390 ilUtil::sendInfo($this->lng->txt("spl_paste_no_objects"), true);
391 }
392 $this->ctrl->redirect($this, "questions");
393 }
394
398 public function importQuestionsObject()
399 {
401
402 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
403 $form = new ilPropertyFormGUI();
404 $form->setFormAction($this->ctrl->getFormAction($this, "uploadQuestions"));
405 $form->setTitle($this->lng->txt("import_question"));
406
407 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
408 $fi = new ilFileInputGUI($this->lng->txt("select_file"), "qtidoc");
409 $fi->setSuffixes(array("xml", "zip"));
410 $fi->setRequired(true);
411 $form->addItem($fi);
412
413 $form->addCommandButton("uploadQuestions", $this->lng->txt("import"));
414 $form->addCommandButton("questions", $this->lng->txt("cancel"));
415
416 $tpl->setContent($form->getHTML());
417 }
418
422 public function uploadQuestionsObject()
423 {
424 // check if file was uploaded
425 $source = $_FILES["qtidoc"]["tmp_name"];
426 $error = 0;
427 if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK) {
428 $error = 1;
429 }
430 // check correct file type
431 if (!$error && strpos("xml", $_FILES["qtidoc"]["type"]) !== false) {
432 $error = 1;
433 }
434 if (!$error) {
435 // import file into questionpool
436 // create import directory
437 $this->object->createImportDirectory();
438
439 // copy uploaded file to import directory
440 $full_path = $this->object->getImportDirectory() . "/" . $_FILES["qtidoc"]["name"];
441
442 ilUtil::moveUploadedFile(
443 $_FILES["qtidoc"]["tmp_name"],
444 $_FILES["qtidoc"]["name"],
445 $full_path
446 );
447 $source = $full_path;
448 $this->object->importObject($source, true);
449 unlink($source);
450 }
451 $this->ctrl->redirect($this, "questions");
452 }
453
455 {
456 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
457 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
458 $table_gui->writeFilterToSession();
459 $this->ctrl->redirect($this, 'questions');
460 }
461
463 {
464 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
465 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
466 $table_gui->resetFilter();
467 $this->ctrl->redirect($this, 'questions');
468 }
469
473 public function questionsObject($arrFilter = null)
474 {
476 $ilToolbar = $this->toolbar;
477
478 $this->object->purgeQuestions();
479
480 $_SESSION['q_id_table_nav'] = $_GET['q_id_table_nav'];
481
482 if ($this->checkPermissionBool('write')) {
483 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
484 $qtypes = new ilSelectInputGUI("", "sel_question_types");
485 $qtypes->setValue($ilUser->getPref("svy_lastquestiontype"));
486 $ilToolbar->addInputItem($qtypes);
487
488 $options = array();
489 foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation => $data) {
490 $options[$data["type_tag"]] = $translation;
491 }
492 $qtypes->setOptions($options);
493
494 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
495
496 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
497 $button = ilSubmitButton::getInstance();
498 $button->setCaption("svy_create_question");
499 $button->setCommand("createQuestion");
500 $ilToolbar->addButtonInstance($button);
501
502 $ilToolbar->addSeparator();
503
504 $button = ilSubmitButton::getInstance();
505 $button->setCaption("import");
506 $button->setCommand("importQuestions");
507 $ilToolbar->addButtonInstance($button);
508 }
509
510 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
511 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions', (($this->checkPermissionBool('write') ? true : false)));
512 $table_gui->setEditable($this->checkPermissionBool('write'));
513 $arrFilter = array();
514 foreach ($table_gui->getFilterItems() as $item) {
515 if ($item->getValue() !== false) {
516 $arrFilter[$item->getPostVar()] = $item->getValue();
517 }
518 }
519 $table_gui->setData($this->object->getQuestionsData($arrFilter));
520 $this->tpl->setContent($table_gui->getHTML());
521 }
522
523 public function updateObject()
524 {
525 $this->update = $this->object->update();
526 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
527 }
528
529 public function afterSave(ilObject $a_new_object)
530 {
531 // always send a message
532 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
533
534 ilUtil::redirect("ilias.php?ref_id=" . $a_new_object->getRefId() .
535 "&baseClass=ilObjSurveyQuestionPoolGUI");
536 }
537
538 /*
539 * list all export files
540 */
541 public function exportObject()
542 {
543 $ilToolbar = $this->toolbar;
544
545 $ilToolbar->addButton(
546 $this->lng->txt('create_export_file'),
547 $this->ctrl->getLinkTarget($this, 'createExportFile')
548 );
549
550 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
551 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export');
552 $export_dir = $this->object->getExportDirectory();
553 $export_files = $this->object->getExportFiles($export_dir);
554 $data = array();
555 foreach ($export_files as $exp_file) {
556 $file_arr = explode("__", $exp_file);
557 array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir . "/" . $exp_file)));
558 }
559 $table_gui->setData($data);
560 $this->tpl->setContent($table_gui->getHTML());
561 }
562
566 public function createExportFileObject($questions = null)
567 {
568 $this->checkPermission("write");
569
570 include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
571 $survey_exp = new ilSurveyQuestionpoolExport($this->object);
572 $survey_exp->buildExportFile($questions);
573 $this->ctrl->redirect($this, "export");
574 }
575
579 public function downloadExportFileObject()
580 {
581 if (!isset($_POST["file"])) {
582 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
583 $this->ctrl->redirect($this, "export");
584 }
585
586 if (count($_POST["file"]) > 1) {
587 ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
588 $this->ctrl->redirect($this, "export");
589 }
590
591
592 $export_dir = $this->object->getExportDirectory();
593
594 $file = basename($_POST["file"][0]);
595
596 ilUtil::deliverFile($export_dir . "/" . $file, $file);
597 }
598
603 {
604 if (!isset($_POST["file"])) {
605 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
606 $this->ctrl->redirect($this, "export");
607 }
608
609 ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
610 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
611 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export', true);
612 $export_dir = $this->object->getExportDirectory();
613 $data = array();
614 foreach ($_POST['file'] as $exp_file) {
615 $file_arr = explode("__", $exp_file);
616 array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir . "/" . $exp_file)));
617 }
618 $table_gui->setData($data);
619 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
620 }
621
622
627 {
628 ilSession::clear("ilExportFiles");
629 $this->ctrl->redirect($this, "export");
630 }
631
635 public function deleteExportFileObject()
636 {
637 $export_dir = $this->object->getExportDirectory();
638 foreach ($_POST['file'] as $file) {
639 $file = basename($file);
640
641 $exp_file = $export_dir . "/" . $file;
642 $exp_dir = $export_dir . "/" . substr($file, 0, strlen($file) - 4);
643 if (@is_file($exp_file)) {
644 unlink($exp_file);
645 }
646 if (@is_dir($exp_dir)) {
647 ilUtil::delDir($exp_dir);
648 }
649 }
650 $this->ctrl->redirect($this, "export");
651 }
652
653 protected function initImportForm($a_new_type)
654 {
655 $form = parent::initImportForm($a_new_type);
656 $form->getItemByPostVar('importfile')->setSuffixes(array("zip", "xml"));
657
658 return $form;
659 }
660
661 protected function initCreationForms($a_new_type)
662 {
663 $form = $this->initImportForm($a_new_type);
664
665 $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
666 self::CFORM_IMPORT => $form);
667
668 return $forms;
669 }
670
674 public function importFileObject($parent_id = null, $a_catch_errors = true)
675 {
678
679 if (!$parent_id) {
680 $parent_id = $_GET["ref_id"];
681 }
682 $new_type = $_REQUEST["new_type"];
683
684 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
685 if (!$this->checkPermissionBool("create", "", $new_type)) {
686 $ilErr->raiseError($this->lng->txt("no_create_permission"));
687 }
688
689 $this->lng->loadLanguageModule($new_type);
690 $this->ctrl->setParameter($this, "new_type", $new_type);
691
692 $form = $this->initImportForm($new_type);
693 if ($form->checkInput()) {
694 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
695 $newObj = new ilObjSurveyQuestionPool();
696 $newObj->setType($new_type);
697 $newObj->setTitle("dummy");
698 $newObj->create(true);
699 $this->putObjectInTree($newObj);
700
701 $newObj->createImportDirectory();
702
703 // copy uploaded file to import directory
704 $upload = $_FILES["importfile"];
705 $file = pathinfo($upload["name"]);
706 $full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
707 ilUtil::moveUploadedFile(
708 $upload["tmp_name"],
709 $upload["name"],
710 $full_path
711 );
712
713 // import qti data
714 $qtiresult = $newObj->importObject($full_path);
715
716 ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
717 ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() .
718 "&baseClass=ilObjSurveyQuestionPoolGUI");
719 }
720
721 // display form to correct errors
722 $form->setValuesByPost();
723 $tpl->setContent($form->getHtml());
724 }
725
729 public function &createQuestionObject()
730 {
732
733 $ilUser->writePref("svy_lastquestiontype", $_POST["sel_question_types"]);
734
735 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
736 $q_gui = &SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
737 $q_gui->object->setObjId($this->object->getId());
738 $q_gui->object->createNewQuestion();
739
740 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
741 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
742 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
743 }
744
748 public function &previewObject()
749 {
750 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
751 $q_gui = &SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
752 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
753 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
754 $this->ctrl->redirectByClass(get_class($q_gui), "preview");
755 }
756
762 public function infoScreenObject()
763 {
764 $this->ctrl->setCmd("showSummary");
765 $this->ctrl->setCmdClass("ilinfoscreengui");
766 $this->infoScreenForward();
767 }
768
772 public function infoScreenForward()
773 {
774 if (!$this->checkPermissionBool("read")) {
775 $this->checkPermission("visible");
776 }
777
778 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
779 $info = new ilInfoScreenGUI($this);
780 $info->enablePrivateNotes();
781
782 // standard meta data
783 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
784
785 $this->ctrl->forwardCommand($info);
786 }
787
788 public function addLocatorItems()
789 {
790 $ilLocator = $this->locator;
791 switch ($this->ctrl->getCmd()) {
792 case "create":
793 case "importFile":
794 case "cancel":
795 break;
796 default:
797 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
798 break;
799 }
800 if ((int) $_GET["q_id"]) {
801 $q_id = (int) $_GET["q_id"];
802 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
803 $q_type = SurveyQuestion::_getQuestionType($q_id) . "GUI";
804 $q_title = SurveyQuestion::_getTitle($q_id);
805 if ($q_title) {
806 // not on create
807 $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
808 $ilLocator->addItem(
809 $q_title,
810 $this->ctrl->getLinkTargetByClass($q_type, "editQuestion")
811 );
812 }
813 }
814 }
815
821 public function getTabs()
822 {
823 $ilHelp = $this->help;
824
825 $ilHelp->setScreenIdComponent("spl");
826
827 $next_class = $this->ctrl->getNextClass($this);
828 switch ($next_class) {
829 case "":
830 case "ilpermissiongui":
831 case "ilobjectmetadatagui":
832 case "ilsurveyphrasesgui":
833 break;
834 default:
835 return;
836 break;
837 }
838
839 // questions
840 $force_active = (($this->ctrl->getCmdClass() == "" &&
841 $this->ctrl->getCmd() != "properties" && $this->ctrl->getCmd() != "infoScreen") ||
842 $this->ctrl->getCmd() == "")
843 ? true
844 : false;
845 if (!$force_active) {
846 if (is_array($_GET["sort"])) {
847 $force_active = true;
848 }
849 }
850
851 if ($this->checkPermissionBool("read")) {
852 $this->tabs_gui->addTarget(
853 "survey_questions",
854 $this->ctrl->getLinkTarget($this, 'questions'),
855 array("questions", "filterQuestionBrowser", "filter", "reset", "createQuestion",
856 "importQuestions", "deleteQuestions", "copy", "paste",
857 "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
858 "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
859 "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
860 "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
861 "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
862 "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
863 "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
864 "cancelDeleteCategory", "categories", "saveCategories",
865 "savePhrase", "addPhrase"
866 ),
867 array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"),
868 "",
869 $force_active
870 );
871
872 $this->tabs_gui->addTarget(
873 "info_short",
874 $this->ctrl->getLinkTarget($this, "infoScreen"),
875 array("infoScreen", "showSummary")
876 );
877 }
878
879 if ($this->checkPermissionBool('write')) {
880 // properties
881 $this->tabs_gui->addTarget(
882 "settings",
883 $this->ctrl->getLinkTarget($this, 'properties'),
884 array("properties", "saveProperties"),
885 "",
886 ""
887 );
888
889 // manage phrases
890 $this->tabs_gui->addTarget(
891 "manage_phrases",
892 $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
893 array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase", "editPhrase", "newPhrase", "saveEditPhrase", "phraseEditor"),
894 "ilsurveyphrasesgui",
895 ""
896 );
897
898 // meta data
899 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
900 $mdgui = new ilObjectMetaDataGUI($this->object);
901 $mdtab = $mdgui->getTab();
902 if ($mdtab) {
903 $this->tabs_gui->addTarget(
904 "meta_data",
905 $mdtab,
906 "",
907 "ilmdeditorgui"
908 );
909 }
910
911 // export
912 $this->tabs_gui->addTarget(
913 "export",
914 $this->ctrl->getLinkTarget($this, 'export'),
915 array("export", "createExportFile", "confirmDeleteExportFile",
916 "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
917 "",
918 ""
919 );
920 }
921
922 if ($this->checkPermissionBool("edit_permission")) {
923 $this->tabs_gui->addTarget(
924 "perm_settings",
925 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
926 array("perm","info","owner"),
927 'ilpermissiongui'
928 );
929 }
930 }
931
935 public function saveObligatoryObject()
936 {
937 $obligatory = array();
938 foreach ($_POST as $key => $value) {
939 if (preg_match("/obligatory_(\d+)/", $key, $matches)) {
940 $obligatory[] = $matches[1];
941 }
942 }
943 $this->object->setObligatoryStates($obligatory);
944
945 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
946 $this->ctrl->redirect($this, "questions");
947 }
948
955 public static function _goto($a_target)
956 {
957 global $DIC;
958
959 $ilAccess = $DIC->access();
960 $lng = $DIC->language();
961
962 if ($ilAccess->checkAccess("visible", "", $a_target) ||
963 $ilAccess->checkAccess("read", "", $a_target)) {
964 $_GET["baseClass"] = "ilObjSurveyQuestionPoolGUI";
965 $_GET["cmd"] = "infoScreen";
966 $_GET["ref_id"] = $a_target;
967 include_once("ilias.php");
968 exit;
969 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
970 ilUtil::sendFailure(sprintf(
971 $lng->txt("msg_no_perm_read_item"),
973 ), true);
975 }
976 }
977} // END class.ilObjSurveyQuestionPoolGUI
user()
Definition: user.php:4
$section
Definition: Utf8Test.php:83
$source
Definition: linkback.php:22
exit
Definition: backend.php:16
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static _getTitle($question_id)
Returns the question title of a question with a given id.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
const IL_CAL_UNIX
error($a_errmsg)
set error message @access public
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
This class represents a file property in a property form.
This class represents a section header in a property form.
Class ilInfoScreenGUI.
static getLogger($a_component_id)
Get component logger.
Class ilObjSurveyQuestionPoolGUI.
uploadQuestionsObject()
imports question(s) into the questionpool
copyObject()
Copies checked questions in the questionpool to a clipboard.
createExportFileObject($questions=null)
create export file
__construct()
Constructor @access public.
savePropertiesObject()
Save questionpool properties.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
propertiesObject(ilPropertyFormGUI $a_form=null)
Questionpool properties.
cancelDeleteExportFileObject()
cancel deletion of export files
pasteObject()
paste questios from the clipboard into the question pool
questionsObject($arrFilter=null)
list questions of question pool
initCreationForms($a_new_type)
Init creation froms.
importQuestionsObject()
display the import form to import questions into the questionpool
deleteQuestionsObject()
Creates a confirmation form to delete questions from the question pool.
cancelDeleteQuestionsObject()
cancel delete questions
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
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
static _goto($a_target)
Redirect script to call a survey question pool reference id.
importFileObject($parent_id=null, $a_catch_errors=true)
form for new survey object import
initImportForm($a_new_type)
Init object import form.
updateObject()
updates object entry in object_data
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
prepareOutput($a_show_subobjects=true)
prepare output
initCreateForm($a_new_type)
Init object creation form.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
getCreationMode()
get creation mode
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
const TITLE_LENGTH
max length of object title
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
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($a_var)
Unset a value.
static getInstance()
Factory.
Survey phrases GUI class.
Export class for survey questionpools.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$key
Definition: croninfo.php:18
$txt
Definition: error.php:11
global $ilCtrl
Definition: ilias.php:18
$info
Definition: index.php:5
update($pash, $contents, Config $config)
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18