ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
45
51 {
52 global $lng, $ilCtrl;
53
54 $this->type = "spl";
55 $lng->loadLanguageModule("survey");
56 $this->ctrl =& $ilCtrl;
57 $this->ctrl->saveParameter($this, array("ref_id"));
58
59 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
60 }
61
65 public function executeCommand()
66 {
67 global $ilAccess, $ilNavigationHistory, $ilErr;
68
69 if (!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
70 !$ilAccess->checkAccess("read", "", $this->ref_id))
71 {
72 global $ilias;
73 $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
74 }
75
76 // add entry to navigation history
77 if (!$this->getCreationMode() &&
78 $ilAccess->checkAccess("read", "", $this->ref_id))
79 {
80 $ilNavigationHistory->addItem($this->ref_id,
81 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".$this->ref_id, "spl");
82 }
83
84 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "Modules/Survey"), "screen");
85 $this->prepareOutput();
86
87 $cmd = $this->ctrl->getCmd("questions");
88 $next_class = $this->ctrl->getNextClass($this);
89 $this->ctrl->setReturn($this, "questions");
90 if ($_GET["q_id"] < 1)
91 {
92 $q_type = ($_POST["sel_question_types"] != "")
93 ? $_POST["sel_question_types"]
94 : $_GET["sel_question_types"];
95 }
96 switch($next_class)
97 {
98 case 'ilobjectmetadatagui':
99 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
100 {
101 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
102 }
103 include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
104 $md_gui = new ilObjectMetaDataGUI($this->object);
105 $this->ctrl->forwardCommand($md_gui);
106 break;
107
108 case 'ilpermissiongui':
109 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
110 $perm_gui =& new ilPermissionGUI($this);
111 $ret =& $this->ctrl->forwardCommand($perm_gui);
112 break;
113
114 case "ilsurveyphrasesgui":
115 include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
116 $phrases_gui =& new ilSurveyPhrasesGUI($this);
117 $ret =& $this->ctrl->forwardCommand($phrases_gui);
118 break;
119
120 case 'ilobjectcopygui':
121 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
122 $cp = new ilObjectCopyGUI($this);
123 $cp->setType('spl');
124 $this->ctrl->forwardCommand($cp);
125 break;
126
127 case 'ilinfoscreengui':
128 $this->infoScreenForward();
129 break;
130
131 case "ilcommonactiondispatchergui":
132 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
134 $this->ctrl->forwardCommand($gui);
135 break;
136
137 case "":
138 $cmd.= "Object";
139 $ret =& $this->$cmd();
140 break;
141
142 default:
143 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
144 $q_gui = SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
145 // $q_gui->object->setObjId($this->object->getId());
146 $q_gui->setQuestionTabs();
147 $ret =& $this->ctrl->forwardCommand($q_gui);
148
149 // not on create
150 if($q_gui->object->isComplete())
151 {
152 $this->tpl->setTitle($this->lng->txt("question").": ".$q_gui->object->getTitle());
153 }
154 break;
155 }
156 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
157 $this->getCreationMode() != true)
158 {
159 $this->tpl->show();
160 }
161 }
162
163 protected function initEditForm()
164 {
165 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
166 $form = new ilPropertyFormGUI();
167 $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
168 $form->setTitle($this->lng->txt("properties"));
169 $form->setMultipart(false);
170 $form->setId("properties");
171
172 // title
173 $title = new ilTextInputGUI($this->lng->txt('title'),'title');
174 $title->setSubmitFormOnEnter(true);
175 $title->setValue($this->object->getTitle());
176 $title->setSize(min(40, ilObject::TITLE_LENGTH));
177 $title->setMaxLength(ilObject::TITLE_LENGTH);
178 $title->setRequired(true);
179 $form->addItem($title);
180
181 // desc
182 $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
183 $desc->setValue($this->object->getLongDescription());
184 $desc->setRows(2);
185 $desc->setCols(40);
186 $form->addItem($desc);
187
188 // online
189 $online = new ilCheckboxInputGUI($this->lng->txt("spl_online_property"), "online");
190 $online->setInfo($this->lng->txt("spl_online_property_description"));
191 $online->setChecked($this->object->getOnline());
192 $form->addItem($online);
193
194 $form->addCommandButton("saveProperties", $this->lng->txt("save"));
195
196 return $form;
197 }
198
202 public function propertiesObject(ilPropertyFormGUI $a_form = null)
203 {
204 if(!$a_form)
205 {
206 $a_form = $this->initEditForm();
207 }
208
209 $this->tpl->setVariable("ADM_CONTENT", $a_form->getHTML());
210 }
211
215 public function savePropertiesObject()
216 {
217 $form = $this->initEditForm();
218 if($form->checkInput())
219 {
220 $this->object->setTitle($form->getInput("title"));
221 $this->object->setDescription($form->getInput("desc"));
222 $this->object->setOnline((int)$form->getInput("online"));
223
224 $this->object->saveToDb();
225
226 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
227 $this->ctrl->redirect($this, "properties");
228 }
229
230 $form->setValuesByPost();
231 $this->propertiesObject($form);
232 }
233
234
238 public function copyObject()
239 {
240 if (count($_POST["q_id"]) > 0)
241 {
242 foreach ($_POST["q_id"] as $key => $value)
243 {
244 $this->object->copyToClipboard($value);
245 }
246 ilUtil::sendInfo($this->lng->txt("spl_copy_insert_clipboard"), true);
247 }
248 else
249 {
250 ilUtil::sendInfo($this->lng->txt("spl_copy_select_none"), true);
251 }
252 $this->ctrl->redirect($this, "questions");
253 }
254
258 public function moveObject()
259 {
260 if (count($_POST["q_id"]) > 0)
261 {
262 foreach ($_POST["q_id"] as $key => $value)
263 {
264 $this->object->moveToClipboard($value);
265 }
266 ilUtil::sendInfo($this->lng->txt("spl_move_insert_clipboard"), true);
267 }
268 else
269 {
270 ilUtil::sendInfo($this->lng->txt("spl_move_select_none"), true);
271 }
272 $this->ctrl->redirect($this, "questions");
273 }
274
278 public function exportQuestionObject()
279 {
280 if (is_array($_POST['q_id']) && count($_POST['q_id']) > 0)
281 {
282 $this->createExportFileObject($_POST['q_id']);
283 }
284 else
285 {
286 ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"));
287 $this->questionsObject();
288 }
289 }
290
294 public function deleteQuestionsObject()
295 {
296 global $rbacsystem;
297
298 // create an array of all checked checkboxes
299 $checked_questions = $_POST['q_id'];
300 if (count($checked_questions) > 0)
301 {
302 if (!$rbacsystem->checkAccess('write', $this->ref_id))
303 {
304 ilUtil::sendFailure($this->lng->txt("qpl_delete_rbac_error"));
305 $this->questionsObject();
306 return;
307 }
308 }
309 elseif (count($checked_questions) == 0)
310 {
311 ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
312 $this->questionsObject();
313 return;
314 }
315
316 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
317 $cgui = new ilConfirmationGUI();
318 $cgui->setHeaderText($this->lng->txt("qpl_confirm_delete_questions"));
319
320 $cgui->setFormAction($this->ctrl->getFormAction($this));
321 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteQuestions");
322 $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteQuestions");
323
324 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
325 $infos = $this->object->getQuestionInfos($checked_questions);
326 foreach ($infos as $data)
327 {
328 $txt = $data["title"]." (".
330 if($data["description"])
331 {
332 $txt .= "<div class=\"small\">".$data["description"]."</div>";
333 }
334
335 $cgui->addItem("q_id[]", $data["id"], $txt);
336 }
337
338 $this->tpl->setContent($cgui->getHTML());
339 }
340
345 {
346 // delete questions after confirmation
347 ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
348 foreach ($_POST['q_id'] as $q_id)
349 {
350 $this->object->removeQuestion($q_id);
351 }
352 $this->ctrl->redirect($this, "questions");
353 }
354
359 {
360 // delete questions after confirmation
361 $this->ctrl->redirect($this, "questions");
362 }
363
367 public function pasteObject()
368 {
369 if (array_key_exists("spl_clipboard", $_SESSION))
370 {
371 $this->object->pasteFromClipboard();
372 }
373 else
374 {
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 {
385 global $tpl;
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 {
414 $error = 1;
415 }
416 // check correct file type
417 if (!$error && strpos("xml", $_FILES["qtidoc"]["type"]) !== FALSE)
418 {
419 $error = 1;
420 }
421 if (!$error)
422 {
423 // import file into questionpool
424 // create import directory
425 $this->object->createImportDirectory();
426
427 // copy uploaded file to import directory
428 $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
429
430 include_once "./Services/Utilities/classes/class.ilUtil.php";
431 ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"],
432 $_FILES["qtidoc"]["name"], $full_path);
433 $source = $full_path;
434 $this->object->importObject($source, TRUE);
435 unlink($source);
436 }
437 $this->ctrl->redirect($this, "questions");
438 }
439
441 {
442 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
443 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
444 $table_gui->writeFilterToSession();
445 $this->ctrl->redirect($this, 'questions');
446 }
447
449 {
450 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
451 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
452 $table_gui->resetFilter();
453 $this->ctrl->redirect($this, 'questions');
454 }
455
459 public function questionsObject($arrFilter = null)
460 {
461 global $rbacsystem;
462 global $ilUser;
463 global $ilToolbar;
464
465 $this->object->purgeQuestions();
466
467 $_SESSION['q_id_table_nav'] = $_GET['q_id_table_nav'];
468
469 if ($rbacsystem->checkAccess('write', $_GET['ref_id']))
470 {
471 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
472 $qtypes = new ilSelectInputGUI("", "sel_question_types");
473 $qtypes->setValue($ilUser->getPref("svy_lastquestiontype"));
474 $ilToolbar->addInputItem($qtypes);
475
476 $options = array();
477 foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation => $data)
478 {
479 $options[$data["type_tag"]] = $translation;
480 }
481 $qtypes->setOptions($options);
482
483 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
484
485 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
486 $button = ilSubmitButton::getInstance();
487 $button->setCaption("svy_create_question");
488 $button->setCommand("createQuestion");
489 $ilToolbar->addButtonInstance($button);
490
491 $ilToolbar->addSeparator();
492
493 $button = ilSubmitButton::getInstance();
494 $button->setCaption("import");
495 $button->setCommand("importQuestions");
496 $ilToolbar->addButtonInstance($button);
497 }
498
499 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
500 $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)));
501 $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
502 $arrFilter = array();
503 foreach ($table_gui->getFilterItems() as $item)
504 {
505 if ($item->getValue() !== false)
506 {
507 $arrFilter[$item->getPostVar()] = $item->getValue();
508 }
509 }
510 $table_gui->setData($this->object->getQuestionsData($arrFilter));
511 $this->tpl->setContent($table_gui->getHTML());
512 }
513
514 public function updateObject()
515 {
516 $this->update = $this->object->update();
517 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
518 }
519
520 public function afterSave(ilObject $a_new_object)
521 {
522 // always send a message
523 ilUtil::sendSuccess($this->lng->txt("object_added"),true);
524
525 ilUtil::redirect("ilias.php?ref_id=".$a_new_object->getRefId().
526 "&baseClass=ilObjSurveyQuestionPoolGUI");
527 }
528
529 /*
530 * list all export files
531 */
532 public function exportObject()
533 {
534 global $ilToolbar;
535
536 $ilToolbar->addButton($this->lng->txt('create_export_file'),
537 $this->ctrl->getLinkTarget($this, 'createExportFile'));
538
539 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
540 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export');
541 $export_dir = $this->object->getExportDirectory();
542 $export_files = $this->object->getExportFiles($export_dir);
543 $data = array();
544 foreach ($export_files as $exp_file)
545 {
546 $file_arr = explode("__", $exp_file);
547 array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
548 }
549 $table_gui->setData($data);
550 $this->tpl->setContent($table_gui->getHTML());
551 }
552
556 public function createExportFileObject($questions = null)
557 {
558 global $rbacsystem;
559
560 if ($rbacsystem->checkAccess("write", $this->ref_id))
561 {
562 include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
563 $survey_exp = new ilSurveyQuestionpoolExport($this->object);
564 $survey_exp->buildExportFile($questions);
565 $this->ctrl->redirect($this, "export");
566 }
567 else
568 {
569 ilUtil::sendInfo("cannot_export_questionpool");
570 }
571 }
572
576 public function downloadExportFileObject()
577 {
578 if(!isset($_POST["file"]))
579 {
580 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
581 $this->ctrl->redirect($this, "export");
582 }
583
584 if (count($_POST["file"]) > 1)
585 {
586 ilUtil::sendInfo($this->lng->txt("select_max_one_item"),true);
587 $this->ctrl->redirect($this, "export");
588 }
589
590
591 $export_dir = $this->object->getExportDirectory();
592 include_once "./Services/Utilities/classes/class.ilUtil.php";
593
594 $file = basename($_POST["file"][0]);
595
596 ilUtil::deliverFile($export_dir."/".$file, $file);
597 }
598
603 {
604 if(!isset($_POST["file"]))
605 {
606 ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
607 $this->ctrl->redirect($this, "export");
608 }
609
610 ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
611 include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
612 $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export', true);
613 $export_dir = $this->object->getExportDirectory();
614 $data = array();
615 foreach ($_POST['file'] as $exp_file)
616 {
617 $file_arr = explode("__", $exp_file);
618 array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
619 }
620 $table_gui->setData($data);
621 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
622 }
623
624
629 {
630 ilSession::clear("ilExportFiles");
631 $this->ctrl->redirect($this, "export");
632 }
633
637 public function deleteExportFileObject()
638 {
639 $export_dir = $this->object->getExportDirectory();
640 foreach($_POST['file'] as $file)
641 {
642 $file = basename($file);
643
644 $exp_file = $export_dir."/".$file;
645 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
646 if (@is_file($exp_file))
647 {
648 unlink($exp_file);
649 }
650 if (@is_dir($exp_dir))
651 {
652 include_once "./Services/Utilities/classes/class.ilUtil.php";
653 ilUtil::delDir($exp_dir);
654 }
655 }
656 $this->ctrl->redirect($this, "export");
657 }
658
659 protected function initImportForm($a_new_type)
660 {
661 $form = parent::initImportForm($a_new_type);
662 $form->getItemByPostVar('importfile')->setSuffixes(array("zip", "xml"));
663
664 return $form;
665 }
666
667 protected function initCreationForms($a_new_type)
668 {
669 $form = $this->initImportForm($a_new_type);
670
671 $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
672 self::CFORM_IMPORT => $form);
673
674 return $forms;
675 }
676
680 public function importFileObject()
681 {
682 global $tpl, $ilErr;
683
684 $parent_id = $_GET["ref_id"];
685 $new_type = $_REQUEST["new_type"];
686
687 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
688 if (!$this->checkPermissionBool("create", "", $new_type))
689 {
690 $ilErr->raiseError($this->lng->txt("no_create_permission"));
691 }
692
693 $this->lng->loadLanguageModule($new_type);
694 $this->ctrl->setParameter($this, "new_type", $new_type);
695
696 $form = $this->initImportForm($new_type);
697 if ($form->checkInput())
698 {
699 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
700 $newObj = new ilObjSurveyQuestionPool();
701 $newObj->setType($new_type);
702 $newObj->setTitle("dummy");
703 $newObj->create(true);
704 $this->putObjectInTree($newObj);
705
706 $newObj->createImportDirectory();
707
708 // copy uploaded file to import directory
709 $upload = $_FILES["importfile"];
710 $file = pathinfo($upload["name"]);
711 $full_path = $newObj->getImportDirectory()."/".$upload["name"];
712 include_once "./Services/Utilities/classes/class.ilUtil.php";
713 ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"],
714 $full_path);
715
716 // import qti data
717 $qtiresult = $newObj->importObject($full_path);
718
719 ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
720 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
721 "&baseClass=ilObjSurveyQuestionPoolGUI");
722 }
723
724 // display form to correct errors
725 $form->setValuesByPost();
726 $tpl->setContent($form->getHtml());
727 }
728
732 public function &createQuestionObject()
733 {
734 global $ilUser;
735
736 $ilUser->writePref("svy_lastquestiontype", $_POST["sel_question_types"]);
737
738 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
739 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
740 $q_gui->object->setObjId($this->object->getId());
741 $q_gui->object->createNewQuestion();
742
743 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
744 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
745 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
746 }
747
751 public function &previewObject()
752 {
753 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
754 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
755 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
756 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
757 $this->ctrl->redirectByClass(get_class($q_gui), "preview");
758 }
759
766 {
767 $this->ctrl->setCmd("showSummary");
768 $this->ctrl->setCmdClass("ilinfoscreengui");
769 $this->infoScreenForward();
770 }
771
776 {
777 global $ilErr, $ilAccess;
778
779 if(!$ilAccess->checkAccess("visible", "", $this->ref_id) &&
780 !$ilAccess->checkAccess("read", "", $this->ref_id))
781 {
782 $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
783 }
784
785 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
786 $info = new ilInfoScreenGUI($this);
787 $info->enablePrivateNotes();
788
789 // standard meta data
790 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
791
792 $this->ctrl->forwardCommand($info);
793 }
794
795 public function addLocatorItems()
796 {
797 global $ilLocator;
798 switch ($this->ctrl->getCmd())
799 {
800 case "create":
801 case "importFile":
802 case "cancel":
803 break;
804 default:
805 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
806 break;
807 }
808 if ((int)$_GET["q_id"])
809 {
810 $q_id = (int)$_GET["q_id"];
811 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
812 $q_type = SurveyQuestion::_getQuestionType($q_id) . "GUI";
813 $q_title = SurveyQuestion::_getTitle($q_id);
814 if($q_title)
815 {
816 // not on create
817 $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
818 $ilLocator->addItem($q_title,
819 $this->ctrl->getLinkTargetByClass($q_type, "editQuestion"));
820 }
821 }
822 }
823
829 public function getTabs(&$tabs_gui)
830 {
831 global $ilAccess, $ilHelp;
832
833 $ilHelp->setScreenIdComponent("spl");
834
835 $next_class = $this->ctrl->getNextClass($this);
836 switch ($next_class)
837 {
838 case "":
839 case "ilpermissiongui":
840 case "ilobjectmetadatagui":
841 case "ilsurveyphrasesgui":
842 break;
843 default:
844 return;
845 break;
846 }
847
848 // questions
849 $force_active = (($this->ctrl->getCmdClass() == "" &&
850 $this->ctrl->getCmd() != "properties" && $this->ctrl->getCmd() != "infoScreen") ||
851 $this->ctrl->getCmd() == "")
852 ? true
853 : false;
854 if (!$force_active)
855 {
856 if (is_array($_GET["sort"]))
857 {
858 $force_active = true;
859 }
860 }
861
862 if ($ilAccess->checkAccess("read", "", $this->ref_id))
863 {
864 $tabs_gui->addTarget("survey_questions",
865 $this->ctrl->getLinkTarget($this,'questions'),
866 array("questions", "filterQuestionBrowser", "filter", "reset", "createQuestion",
867 "importQuestions", "deleteQuestions", "copy", "paste",
868 "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
869 "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
870 "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
871 "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
872 "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
873 "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
874 "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
875 "cancelDeleteCategory", "categories", "saveCategories",
876 "savePhrase", "addPhrase"
877 ),
878 array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"), "", $force_active);
879
880 $tabs_gui->addTarget("info_short",
881 $this->ctrl->getLinkTarget($this, "infoScreen"),
882 array("infoScreen", "showSummary"));
883 }
884
885 if ($ilAccess->checkAccess('write', '', $this->ref_id))
886 {
887 // properties
888 $tabs_gui->addTarget("settings",
889 $this->ctrl->getLinkTarget($this,'properties'),
890 array("properties", "saveProperties"),
891 "", "");
892
893 // manage phrases
894 $tabs_gui->addTarget("manage_phrases",
895 $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
896 array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase", "editPhrase", "newPhrase", "saveEditPhrase", "phraseEditor"),
897 "ilsurveyphrasesgui", "");
898
899 // meta data
900 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
901 $mdgui = new ilObjectMetaDataGUI($this->object);
902 $mdtab = $mdgui->getTab();
903 if($mdtab)
904 {
905 $tabs_gui->addTarget("meta_data",
906 $mdtab,
907 "", "ilmdeditorgui");
908 }
909
910 // export
911 $tabs_gui->addTarget("export",
912 $this->ctrl->getLinkTarget($this,'export'),
913 array("export", "createExportFile", "confirmDeleteExportFile",
914 "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
915 "", "");
916 }
917
918 if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
919 {
920 $tabs_gui->addTarget("perm_settings",
921 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
922 }
923 }
924
928 public function saveObligatoryObject()
929 {
930 $obligatory = array();
931 foreach ($_POST as $key => $value)
932 {
933 if (preg_match("/obligatory_(\d+)/", $key, $matches))
934 {
935 $obligatory[]= $matches[1];
936 }
937 }
938 $this->object->setObligatoryStates($obligatory);
939
940 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
941 $this->ctrl->redirect($this, "questions");
942 }
943
950 public static function _goto($a_target)
951 {
952 global $ilAccess, $ilErr, $lng;
953 if ($ilAccess->checkAccess("visible", "", $a_target) ||
954 $ilAccess->checkAccess("read", "", $a_target))
955 {
956 $_GET["baseClass"] = "ilObjSurveyQuestionPoolGUI";
957 $_GET["cmd"] = "infoScreen";
958 $_GET["ref_id"] = $a_target;
959 include_once("ilias.php");
960 exit;
961 }
962 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
963 {
964 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
967 }
968 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
969 }
970} // END class.ilObjSurveyQuestionPoolGUI
971?>
print $file
$_GET["client_id"]
$_SESSION["AccountId"]
static & _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
_getQuestionType($question_id)
Returns the question type of a question with a given id.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
_getTitle($question_id)
Returns the question title of a question with a given id.
const IL_CAL_UNIX
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
This class represents a file property in a property form.
Class ilInfoScreenGUI.
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
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
getTabs(&$tabs_gui)
adds tabs to tab gui object
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
ilObjSurveyQuestionPoolGUI()
Constructor @access public.
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.
initImportForm($a_new_type)
Init object import form.
importFileObject()
form for new survey object import
updateObject()
updates object entry in object_data
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
initCreateForm($a_new_type)
Init object creation form.
prepareOutput()
prepare output
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 moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info 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.
$_POST['username']
Definition: cron.php:12
$txt
Definition: error.php:12
$info
Definition: example_052.php:80
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
$cmd
Definition: sahs_server.php:35
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15