ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
195 $form = new ilPropertyFormGUI();
196 $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
197 $form->setTitle($this->lng->txt("properties"));
198 $form->setMultipart(false);
199 $form->setId("properties");
200
201 // title
202 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
203 $title->setSubmitFormOnEnter(true);
204 $title->setValue($this->object->getTitle());
205 $title->setSize(min(40, ilObject::TITLE_LENGTH));
206 $title->setMaxLength(ilObject::TITLE_LENGTH);
207 $title->setRequired(true);
208 $form->addItem($title);
209
210 // desc
211 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
212 $desc->setValue($this->object->getLongDescription());
213 $desc->setRows(2);
214 $desc->setCols(40);
215 $form->addItem($desc);
216
217 // online
218 $online = new ilCheckboxInputGUI($this->lng->txt("spl_online_property"), "online");
219 $online->setInfo($this->lng->txt("spl_online_property_description"));
220 $online->setChecked($this->object->getOnline());
221 $form->addItem($online);
222
223 $form->addCommandButton("saveProperties", $this->lng->txt("save"));
224
225 return $form;
226 }
227
231 public function propertiesObject(ilPropertyFormGUI $a_form = null)
232 {
233 if (!$a_form) {
234 $a_form = $this->initEditForm();
235 }
236
237 $this->tpl->setVariable("ADM_CONTENT", $a_form->getHTML());
238 }
239
243 public function savePropertiesObject()
244 {
245 $form = $this->initEditForm();
246 if ($form->checkInput()) {
247 $this->object->setTitle($form->getInput("title"));
248 $this->object->setDescription($form->getInput("desc"));
249 $this->object->setOnline((int) $form->getInput("online"));
250
251 $this->object->saveToDb();
252
253 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
254 $this->ctrl->redirect($this, "properties");
255 }
256
257 $form->setValuesByPost();
258 $this->propertiesObject($form);
259 }
260
261
265 public function copyObject()
266 {
267 if (count($_POST["q_id"]) > 0) {
268 foreach ($_POST["q_id"] as $key => $value) {
269 $this->object->copyToClipboard($value);
270 }
271 ilUtil::sendInfo($this->lng->txt("spl_copy_insert_clipboard"), true);
272 } else {
273 ilUtil::sendInfo($this->lng->txt("spl_copy_select_none"), true);
274 }
275 $this->ctrl->redirect($this, "questions");
276 }
277
281 public function moveObject()
282 {
283 if (count($_POST["q_id"]) > 0) {
284 foreach ($_POST["q_id"] as $key => $value) {
285 $this->object->moveToClipboard($value);
286 }
287 ilUtil::sendInfo($this->lng->txt("spl_move_insert_clipboard"), true);
288 } else {
289 ilUtil::sendInfo($this->lng->txt("spl_move_select_none"), true);
290 }
291 $this->ctrl->redirect($this, "questions");
292 }
293
297 public function exportQuestionObject()
298 {
299 if (is_array($_POST['q_id']) && count($_POST['q_id']) > 0) {
300 $this->createExportFileObject($_POST['q_id']);
301 } else {
302 ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"));
303 $this->questionsObject();
304 }
305 }
306
310 public function deleteQuestionsObject()
311 {
312 $this->checkPermission('write');
313
314 // create an array of all checked checkboxes
315 $checked_questions = $_POST['q_id'];
316 if (count($checked_questions) == 0) {
317 ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
318 $this->questionsObject();
319 return;
320 }
321
322 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
323 $cgui = new ilConfirmationGUI();
324 $cgui->setHeaderText($this->lng->txt("qpl_confirm_delete_questions"));
325
326 $cgui->setFormAction($this->ctrl->getFormAction($this));
327 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteQuestions");
328 $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteQuestions");
329
330 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
331 $infos = $this->object->getQuestionInfos($checked_questions);
332 foreach ($infos as $data) {
333 $txt = $data["title"] . " (" .
335 if ($data["description"]) {
336 $txt .= "<div class=\"small\">" . $data["description"] . "</div>";
337 }
338
339 $cgui->addItem("q_id[]", $data["id"], $txt);
340 }
341
342 $this->tpl->setContent($cgui->getHTML());
343 }
344
349 {
350 // delete questions after confirmation
351 ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
352 foreach ($_POST['q_id'] as $q_id) {
353 $this->object->removeQuestion($q_id);
354 }
355 $this->ctrl->redirect($this, "questions");
356 }
357
362 {
363 // delete questions after confirmation
364 $this->ctrl->redirect($this, "questions");
365 }
366
370 public function pasteObject()
371 {
372 if (array_key_exists("spl_clipboard", $_SESSION)) {
373 $this->object->pasteFromClipboard();
374 } else {
375 ilUtil::sendInfo($this->lng->txt("spl_paste_no_objects"), true);
376 }
377 $this->ctrl->redirect($this, "questions");
378 }
379
383 public function importQuestionsObject()
384 {
386
387 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
388 $form = new ilPropertyFormGUI();
389 $form->setFormAction($this->ctrl->getFormAction($this, "uploadQuestions"));
390 $form->setTitle($this->lng->txt("import_question"));
391
392 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
393 $fi = new ilFileInputGUI($this->lng->txt("select_file"), "qtidoc");
394 $fi->setSuffixes(array("xml", "zip"));
395 $fi->setRequired(true);
396 $form->addItem($fi);
397
398 $form->addCommandButton("uploadQuestions", $this->lng->txt("import"));
399 $form->addCommandButton("questions", $this->lng->txt("cancel"));
400
401 $tpl->setContent($form->getHTML());
402 }
403
407 public function uploadQuestionsObject()
408 {
409 // check if file was uploaded
410 $source = $_FILES["qtidoc"]["tmp_name"];
411 $error = 0;
412 if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK) {
413 $error = 1;
414 }
415 // check correct file type
416 if (!$error && strpos("xml", $_FILES["qtidoc"]["type"]) !== false) {
417 $error = 1;
418 }
419 if (!$error) {
420 // import file into questionpool
421 // create import directory
422 $this->object->createImportDirectory();
423
424 // copy uploaded file to import directory
425 $full_path = $this->object->getImportDirectory() . "/" . $_FILES["qtidoc"]["name"];
426
427 ilUtil::moveUploadedFile(
428 $_FILES["qtidoc"]["tmp_name"],
429 $_FILES["qtidoc"]["name"],
430 $full_path
431 );
432 $source = $full_path;
433 $this->object->importObject($source, true);
434 unlink($source);
435 }
436 $this->ctrl->redirect($this, "questions");
437 }
438
440 {
441 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
442 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
443 $table_gui->writeFilterToSession();
444 $this->ctrl->redirect($this, 'questions');
445 }
446
448 {
449 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
450 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
451 $table_gui->resetFilter();
452 $this->ctrl->redirect($this, 'questions');
453 }
454
458 public function questionsObject($arrFilter = null)
459 {
461 $ilToolbar = $this->toolbar;
462
463 $this->object->purgeQuestions();
464
465 $_SESSION['q_id_table_nav'] = $_GET['q_id_table_nav'];
466
467 if ($this->checkPermissionBool('write')) {
468 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
469 $qtypes = new ilSelectInputGUI("", "sel_question_types");
470 $qtypes->setValue($ilUser->getPref("svy_lastquestiontype"));
471 $ilToolbar->addInputItem($qtypes);
472
473 $options = array();
474 foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation => $data) {
475 $options[$data["type_tag"]] = $translation;
476 }
477 $qtypes->setOptions($options);
478
479 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
480
481 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
482 $button = ilSubmitButton::getInstance();
483 $button->setCaption("svy_create_question");
484 $button->setCommand("createQuestion");
485 $ilToolbar->addButtonInstance($button);
486
487 $ilToolbar->addSeparator();
488
489 $button = ilSubmitButton::getInstance();
490 $button->setCaption("import");
491 $button->setCommand("importQuestions");
492 $ilToolbar->addButtonInstance($button);
493 }
494
495 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
496 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions', (($this->checkPermissionBool('write') ? true : false)));
497 $table_gui->setEditable($this->checkPermissionBool('write'));
498 $arrFilter = array();
499 foreach ($table_gui->getFilterItems() as $item) {
500 if ($item->getValue() !== false) {
501 $arrFilter[$item->getPostVar()] = $item->getValue();
502 }
503 }
504 $table_gui->setData($this->object->getQuestionsData($arrFilter));
505 $this->tpl->setContent($table_gui->getHTML());
506 }
507
508 public function updateObject()
509 {
510 $this->update = $this->object->update();
511 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
512 }
513
514 public function afterSave(ilObject $a_new_object)
515 {
516 // always send a message
517 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
518
519 ilUtil::redirect("ilias.php?ref_id=" . $a_new_object->getRefId() .
520 "&baseClass=ilObjSurveyQuestionPoolGUI");
521 }
522
523 /*
524 * list all export files
525 */
526 public function exportObject()
527 {
528 $ilToolbar = $this->toolbar;
529
530 $ilToolbar->addButton(
531 $this->lng->txt('create_export_file'),
532 $this->ctrl->getLinkTarget($this, 'createExportFile')
533 );
534
535 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
536 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export');
537 $export_dir = $this->object->getExportDirectory();
538 $export_files = $this->object->getExportFiles($export_dir);
539 $data = array();
540 foreach ($export_files as $exp_file) {
541 $file_arr = explode("__", $exp_file);
542 array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir . "/" . $exp_file)));
543 }
544 $table_gui->setData($data);
545 $this->tpl->setContent($table_gui->getHTML());
546 }
547
551 public function createExportFileObject($questions = null)
552 {
553 $this->checkPermission("write");
554
555 include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
556 $survey_exp = new ilSurveyQuestionpoolExport($this->object);
557 $survey_exp->buildExportFile($questions);
558 $this->ctrl->redirect($this, "export");
559 }
560
564 public function downloadExportFileObject()
565 {
566 if (!isset($_POST["file"])) {
567 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
568 $this->ctrl->redirect($this, "export");
569 }
570
571 if (count($_POST["file"]) > 1) {
572 ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
573 $this->ctrl->redirect($this, "export");
574 }
575
576
577 $export_dir = $this->object->getExportDirectory();
578
579 $file = basename($_POST["file"][0]);
580
581 ilUtil::deliverFile($export_dir . "/" . $file, $file);
582 }
583
588 {
589 if (!isset($_POST["file"])) {
590 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
591 $this->ctrl->redirect($this, "export");
592 }
593
594 ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
595 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
596 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export', true);
597 $export_dir = $this->object->getExportDirectory();
598 $data = array();
599 foreach ($_POST['file'] as $exp_file) {
600 $file_arr = explode("__", $exp_file);
601 array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir . "/" . $exp_file)));
602 }
603 $table_gui->setData($data);
604 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
605 }
606
607
612 {
613 ilSession::clear("ilExportFiles");
614 $this->ctrl->redirect($this, "export");
615 }
616
620 public function deleteExportFileObject()
621 {
622 $export_dir = $this->object->getExportDirectory();
623 foreach ($_POST['file'] as $file) {
624 $file = basename($file);
625
626 $exp_file = $export_dir . "/" . $file;
627 $exp_dir = $export_dir . "/" . substr($file, 0, strlen($file) - 4);
628 if (@is_file($exp_file)) {
629 unlink($exp_file);
630 }
631 if (@is_dir($exp_dir)) {
632 ilUtil::delDir($exp_dir);
633 }
634 }
635 $this->ctrl->redirect($this, "export");
636 }
637
638 protected function initImportForm($a_new_type)
639 {
640 $form = parent::initImportForm($a_new_type);
641 $form->getItemByPostVar('importfile')->setSuffixes(array("zip", "xml"));
642
643 return $form;
644 }
645
646 protected function initCreationForms($a_new_type)
647 {
648 $form = $this->initImportForm($a_new_type);
649
650 $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
651 self::CFORM_IMPORT => $form);
652
653 return $forms;
654 }
655
659 public function importFileObject($parent_id = null, $a_catch_errors = true)
660 {
663
664 if (!$parent_id) {
665 $parent_id = $_GET["ref_id"];
666 }
667 $new_type = $_REQUEST["new_type"];
668
669 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
670 if (!$this->checkPermissionBool("create", "", $new_type)) {
671 $ilErr->raiseError($this->lng->txt("no_create_permission"));
672 }
673
674 $this->lng->loadLanguageModule($new_type);
675 $this->ctrl->setParameter($this, "new_type", $new_type);
676
677 $form = $this->initImportForm($new_type);
678 if ($form->checkInput()) {
679 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
680 $newObj = new ilObjSurveyQuestionPool();
681 $newObj->setType($new_type);
682 $newObj->setTitle("dummy");
683 $newObj->create(true);
684 $this->putObjectInTree($newObj);
685
686 $newObj->createImportDirectory();
687
688 // copy uploaded file to import directory
689 $upload = $_FILES["importfile"];
690 $file = pathinfo($upload["name"]);
691 $full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
692 ilUtil::moveUploadedFile(
693 $upload["tmp_name"],
694 $upload["name"],
695 $full_path
696 );
697
698 // import qti data
699 $qtiresult = $newObj->importObject($full_path);
700
701 ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
702 ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() .
703 "&baseClass=ilObjSurveyQuestionPoolGUI");
704 }
705
706 // display form to correct errors
707 $form->setValuesByPost();
708 $tpl->setContent($form->getHtml());
709 }
710
714 public function &createQuestionObject()
715 {
717
718 $ilUser->writePref("svy_lastquestiontype", $_POST["sel_question_types"]);
719
720 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
721 $q_gui =&SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
722 $q_gui->object->setObjId($this->object->getId());
723 $q_gui->object->createNewQuestion();
724
725 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
726 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
727 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
728 }
729
733 public function &previewObject()
734 {
735 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
736 $q_gui =&SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
737 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
738 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
739 $this->ctrl->redirectByClass(get_class($q_gui), "preview");
740 }
741
747 public function infoScreenObject()
748 {
749 $this->ctrl->setCmd("showSummary");
750 $this->ctrl->setCmdClass("ilinfoscreengui");
751 $this->infoScreenForward();
752 }
753
757 public function infoScreenForward()
758 {
759 if (!$this->checkPermissionBool("read")) {
760 $this->checkPermission("visible");
761 }
762
763 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
764 $info = new ilInfoScreenGUI($this);
765 $info->enablePrivateNotes();
766
767 // standard meta data
768 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
769
770 $this->ctrl->forwardCommand($info);
771 }
772
773 public function addLocatorItems()
774 {
775 $ilLocator = $this->locator;
776 switch ($this->ctrl->getCmd()) {
777 case "create":
778 case "importFile":
779 case "cancel":
780 break;
781 default:
782 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
783 break;
784 }
785 if ((int) $_GET["q_id"]) {
786 $q_id = (int) $_GET["q_id"];
787 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
788 $q_type = SurveyQuestion::_getQuestionType($q_id) . "GUI";
789 $q_title = SurveyQuestion::_getTitle($q_id);
790 if ($q_title) {
791 // not on create
792 $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
793 $ilLocator->addItem(
794 $q_title,
795 $this->ctrl->getLinkTargetByClass($q_type, "editQuestion")
796 );
797 }
798 }
799 }
800
806 public function getTabs()
807 {
808 $ilHelp = $this->help;
809
810 $ilHelp->setScreenIdComponent("spl");
811
812 $next_class = $this->ctrl->getNextClass($this);
813 switch ($next_class) {
814 case "":
815 case "ilpermissiongui":
816 case "ilobjectmetadatagui":
817 case "ilsurveyphrasesgui":
818 break;
819 default:
820 return;
821 break;
822 }
823
824 // questions
825 $force_active = (($this->ctrl->getCmdClass() == "" &&
826 $this->ctrl->getCmd() != "properties" && $this->ctrl->getCmd() != "infoScreen") ||
827 $this->ctrl->getCmd() == "")
828 ? true
829 : false;
830 if (!$force_active) {
831 if (is_array($_GET["sort"])) {
832 $force_active = true;
833 }
834 }
835
836 if ($this->checkPermissionBool("read")) {
837 $this->tabs_gui->addTarget(
838 "survey_questions",
839 $this->ctrl->getLinkTarget($this, 'questions'),
840 array("questions", "filterQuestionBrowser", "filter", "reset", "createQuestion",
841 "importQuestions", "deleteQuestions", "copy", "paste",
842 "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
843 "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
844 "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
845 "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
846 "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
847 "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
848 "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
849 "cancelDeleteCategory", "categories", "saveCategories",
850 "savePhrase", "addPhrase"
851 ),
852 array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"),
853 "",
854 $force_active
855 );
856
857 $this->tabs_gui->addTarget(
858 "info_short",
859 $this->ctrl->getLinkTarget($this, "infoScreen"),
860 array("infoScreen", "showSummary")
861 );
862 }
863
864 if ($this->checkPermissionBool('write')) {
865 // properties
866 $this->tabs_gui->addTarget(
867 "settings",
868 $this->ctrl->getLinkTarget($this, 'properties'),
869 array("properties", "saveProperties"),
870 "",
871 ""
872 );
873
874 // manage phrases
875 $this->tabs_gui->addTarget(
876 "manage_phrases",
877 $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
878 array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase", "editPhrase", "newPhrase", "saveEditPhrase", "phraseEditor"),
879 "ilsurveyphrasesgui",
880 ""
881 );
882
883 // meta data
884 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
885 $mdgui = new ilObjectMetaDataGUI($this->object);
886 $mdtab = $mdgui->getTab();
887 if ($mdtab) {
888 $this->tabs_gui->addTarget(
889 "meta_data",
890 $mdtab,
891 "",
892 "ilmdeditorgui"
893 );
894 }
895
896 // export
897 $this->tabs_gui->addTarget(
898 "export",
899 $this->ctrl->getLinkTarget($this, 'export'),
900 array("export", "createExportFile", "confirmDeleteExportFile",
901 "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
902 "",
903 ""
904 );
905 }
906
907 if ($this->checkPermissionBool("edit_permission")) {
908 $this->tabs_gui->addTarget(
909 "perm_settings",
910 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
911 array("perm","info","owner"),
912 'ilpermissiongui'
913 );
914 }
915 }
916
920 public function saveObligatoryObject()
921 {
922 $obligatory = array();
923 foreach ($_POST as $key => $value) {
924 if (preg_match("/obligatory_(\d+)/", $key, $matches)) {
925 $obligatory[]= $matches[1];
926 }
927 }
928 $this->object->setObligatoryStates($obligatory);
929
930 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
931 $this->ctrl->redirect($this, "questions");
932 }
933
940 public static function _goto($a_target)
941 {
942 global $DIC;
943
944 $ilAccess = $DIC->access();
945 $lng = $DIC->language();
946
947 if ($ilAccess->checkAccess("visible", "", $a_target) ||
948 $ilAccess->checkAccess("read", "", $a_target)) {
949 $_GET["baseClass"] = "ilObjSurveyQuestionPoolGUI";
950 $_GET["cmd"] = "infoScreen";
951 $_GET["ref_id"] = $a_target;
952 include_once("ilias.php");
953 exit;
954 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
956 $lng->txt("msg_no_perm_read_item"),
958 ), true);
960 }
961 }
962} // END class.ilObjSurveyQuestionPoolGUI
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$source
Definition: linkback.php:22
$_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)
Format a date @access public.
@classDescription Date and time handling
This class represents a file property 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 sendSuccess($a_info="", $a_keep=false)
Send Success Message 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
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18