ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
24 include_once "./Services/Object/classes/class.ilObjectGUI.php";
25 
43 {
47  protected $log;
48 
50 
55  public function __construct()
56  {
57  global $lng, $ilCtrl;
58 
59  $this->type = "spl";
60  $lng->loadLanguageModule("survey");
61  $this->ctrl = $ilCtrl;
62  $this->ctrl->saveParameter($this, array("ref_id"));
63 
64  parent::__construct("", $_GET["ref_id"], true, false);
65 
66  $this->log = ilLoggerFactory::getLogger('svy');
67  }
68 
72  public function executeCommand()
73  {
74  global $ilNavigationHistory;
75 
76  if (!$this->checkPermissionBool("visible") &&
77  !$this->checkPermissionBool("read"))
78  {
79  $this->checkPermission("read");
80  }
81 
82  // add entry to navigation history
83  if (!$this->getCreationMode() &&
84  $this->checkPermissionBool("read"))
85  {
86  $ilNavigationHistory->addItem($this->ref_id,
87  "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".$this->ref_id, "spl");
88  }
89 
90  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "Modules/Survey"), "screen");
91  $this->prepareOutput();
92 
93  $cmd = $this->ctrl->getCmd("questions");
94  $next_class = $this->ctrl->getNextClass($this);
95  $this->ctrl->setReturn($this, "questions");
96  if ($_GET["q_id"] < 1)
97  {
98  $q_type = ($_POST["sel_question_types"] != "")
99  ? $_POST["sel_question_types"]
100  : $_GET["sel_question_types"];
101  }
102 
103  $this->log->debug("- cmd=".$cmd." next_class=".$next_class);
104  switch($next_class)
105  {
106  case 'ilobjectmetadatagui':
107  $this->checkPermission('write');
108  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
109  $md_gui = new ilObjectMetaDataGUI($this->object);
110  $this->ctrl->forwardCommand($md_gui);
111  break;
112 
113  case 'ilpermissiongui':
114  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
115  $perm_gui = new ilPermissionGUI($this);
116  $ret =& $this->ctrl->forwardCommand($perm_gui);
117  break;
118 
119  case "ilsurveyphrasesgui":
120  include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
121  $phrases_gui = new ilSurveyPhrasesGUI($this);
122  $ret =& $this->ctrl->forwardCommand($phrases_gui);
123  break;
124 
125  case 'ilobjectcopygui':
126  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
127  $cp = new ilObjectCopyGUI($this);
128  $cp->setType('spl');
129  $this->ctrl->forwardCommand($cp);
130  break;
131 
132  case 'ilinfoscreengui':
133  $this->infoScreenForward();
134  break;
135 
136  case "ilcommonactiondispatchergui":
137  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
139  $this->ctrl->forwardCommand($gui);
140  break;
141 
142  case "":
143  $cmd.= "Object";
144  $ret =& $this->$cmd();
145  break;
146 
147  default:
148  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
149  $q_gui = SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
150  $this->log->debug("- This is the switch/case default, going to question id =".$_GET["q_id"]);
151  // $q_gui->object->setObjId($this->object->getId());
152  $q_gui->setQuestionTabs();
153  $ret =& $this->ctrl->forwardCommand($q_gui);
154 
155  // not on create
156  if($q_gui->object->isComplete())
157  {
158  $this->tpl->setTitle($this->lng->txt("question").": ".$q_gui->object->getTitle());
159  }
160  break;
161  }
162  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
163  $this->getCreationMode() != true)
164  {
165  $this->tpl->show();
166  }
167  }
168 
169  protected function initEditForm()
170  {
171  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
172  $form = new ilPropertyFormGUI();
173  $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
174  $form->setTitle($this->lng->txt("properties"));
175  $form->setMultipart(false);
176  $form->setId("properties");
177 
178  // title
179  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
180  $title->setSubmitFormOnEnter(true);
181  $title->setValue($this->object->getTitle());
182  $title->setSize(min(40, ilObject::TITLE_LENGTH));
183  $title->setMaxLength(ilObject::TITLE_LENGTH);
184  $title->setRequired(true);
185  $form->addItem($title);
186 
187  // desc
188  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
189  $desc->setValue($this->object->getLongDescription());
190  $desc->setRows(2);
191  $desc->setCols(40);
192  $form->addItem($desc);
193 
194  // online
195  $online = new ilCheckboxInputGUI($this->lng->txt("spl_online_property"), "online");
196  $online->setInfo($this->lng->txt("spl_online_property_description"));
197  $online->setChecked($this->object->getOnline());
198  $form->addItem($online);
199 
200  $form->addCommandButton("saveProperties", $this->lng->txt("save"));
201 
202  return $form;
203  }
204 
208  public function propertiesObject(ilPropertyFormGUI $a_form = null)
209  {
210  if(!$a_form)
211  {
212  $a_form = $this->initEditForm();
213  }
214 
215  $this->tpl->setVariable("ADM_CONTENT", $a_form->getHTML());
216  }
217 
221  public function savePropertiesObject()
222  {
223  $form = $this->initEditForm();
224  if($form->checkInput())
225  {
226  $this->object->setTitle($form->getInput("title"));
227  $this->object->setDescription($form->getInput("desc"));
228  $this->object->setOnline((int)$form->getInput("online"));
229 
230  $this->object->saveToDb();
231 
232  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
233  $this->ctrl->redirect($this, "properties");
234  }
235 
236  $form->setValuesByPost();
237  $this->propertiesObject($form);
238  }
239 
240 
244  public function copyObject()
245  {
246  if (count($_POST["q_id"]) > 0)
247  {
248  foreach ($_POST["q_id"] as $key => $value)
249  {
250  $this->object->copyToClipboard($value);
251  }
252  ilUtil::sendInfo($this->lng->txt("spl_copy_insert_clipboard"), true);
253  }
254  else
255  {
256  ilUtil::sendInfo($this->lng->txt("spl_copy_select_none"), true);
257  }
258  $this->ctrl->redirect($this, "questions");
259  }
260 
264  public function moveObject()
265  {
266  if (count($_POST["q_id"]) > 0)
267  {
268  foreach ($_POST["q_id"] as $key => $value)
269  {
270  $this->object->moveToClipboard($value);
271  }
272  ilUtil::sendInfo($this->lng->txt("spl_move_insert_clipboard"), true);
273  }
274  else
275  {
276  ilUtil::sendInfo($this->lng->txt("spl_move_select_none"), true);
277  }
278  $this->ctrl->redirect($this, "questions");
279  }
280 
284  public function exportQuestionObject()
285  {
286  if (is_array($_POST['q_id']) && count($_POST['q_id']) > 0)
287  {
288  $this->createExportFileObject($_POST['q_id']);
289  }
290  else
291  {
292  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"));
293  $this->questionsObject();
294  }
295  }
296 
300  public function deleteQuestionsObject()
301  {
302  $this->checkPermission('write');
303 
304  // create an array of all checked checkboxes
305  $checked_questions = $_POST['q_id'];
306  if (count($checked_questions) == 0)
307  {
308  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
309  $this->questionsObject();
310  return;
311  }
312 
313  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
314  $cgui = new ilConfirmationGUI();
315  $cgui->setHeaderText($this->lng->txt("qpl_confirm_delete_questions"));
316 
317  $cgui->setFormAction($this->ctrl->getFormAction($this));
318  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteQuestions");
319  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteQuestions");
320 
321  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
322  $infos = $this->object->getQuestionInfos($checked_questions);
323  foreach ($infos as $data)
324  {
325  $txt = $data["title"]." (".
326  SurveyQuestion::_getQuestionTypeName($data["type_tag"]).")";
327  if($data["description"])
328  {
329  $txt .= "<div class=\"small\">".$data["description"]."</div>";
330  }
331 
332  $cgui->addItem("q_id[]", $data["id"], $txt);
333  }
334 
335  $this->tpl->setContent($cgui->getHTML());
336  }
337 
342  {
343  // delete questions after confirmation
344  ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
345  foreach ($_POST['q_id'] as $q_id)
346  {
347  $this->object->removeQuestion($q_id);
348  }
349  $this->ctrl->redirect($this, "questions");
350  }
351 
355  public function cancelDeleteQuestionsObject()
356  {
357  // delete questions after confirmation
358  $this->ctrl->redirect($this, "questions");
359  }
360 
364  public function pasteObject()
365  {
366  if (array_key_exists("spl_clipboard", $_SESSION))
367  {
368  $this->object->pasteFromClipboard();
369  }
370  else
371  {
372  ilUtil::sendInfo($this->lng->txt("spl_paste_no_objects"), true);
373  }
374  $this->ctrl->redirect($this, "questions");
375  }
376 
380  public function importQuestionsObject()
381  {
382  global $tpl;
383 
384  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
385  $form = new ilPropertyFormGUI();
386  $form->setFormAction($this->ctrl->getFormAction($this, "uploadQuestions"));
387  $form->setTitle($this->lng->txt("import_question"));
388 
389  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
390  $fi = new ilFileInputGUI($this->lng->txt("select_file"), "qtidoc");
391  $fi->setSuffixes(array("xml", "zip"));
392  $fi->setRequired(true);
393  $form->addItem($fi);
394 
395  $form->addCommandButton("uploadQuestions", $this->lng->txt("import"));
396  $form->addCommandButton("questions", $this->lng->txt("cancel"));
397 
398  $tpl->setContent($form->getHTML());
399  }
400 
404  public function uploadQuestionsObject()
405  {
406  // check if file was uploaded
407  $source = $_FILES["qtidoc"]["tmp_name"];
408  $error = 0;
409  if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
410  {
411  $error = 1;
412  }
413  // check correct file type
414  if (!$error && strpos("xml", $_FILES["qtidoc"]["type"]) !== FALSE)
415  {
416  $error = 1;
417  }
418  if (!$error)
419  {
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($_FILES["qtidoc"]["tmp_name"],
428  $_FILES["qtidoc"]["name"], $full_path);
429  $source = $full_path;
430  $this->object->importObject($source, TRUE);
431  unlink($source);
432  }
433  $this->ctrl->redirect($this, "questions");
434  }
435 
436  public function filterQuestionBrowserObject()
437  {
438  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
439  $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
440  $table_gui->writeFilterToSession();
441  $this->ctrl->redirect($this, 'questions');
442  }
443 
445  {
446  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
447  $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
448  $table_gui->resetFilter();
449  $this->ctrl->redirect($this, 'questions');
450  }
451 
455  public function questionsObject($arrFilter = null)
456  {
457  global $ilUser, $ilToolbar;
458 
459  $this->object->purgeQuestions();
460 
461  $_SESSION['q_id_table_nav'] = $_GET['q_id_table_nav'];
462 
463  if ($this->checkPermissionBool('write'))
464  {
465  include_once "Services/Form/classes/class.ilSelectInputGUI.php";
466  $qtypes = new ilSelectInputGUI("", "sel_question_types");
467  $qtypes->setValue($ilUser->getPref("svy_lastquestiontype"));
468  $ilToolbar->addInputItem($qtypes);
469 
470  $options = array();
471  foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation => $data)
472  {
473  $options[$data["type_tag"]] = $translation;
474  }
475  $qtypes->setOptions($options);
476 
477  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
478 
479  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
480  $button = ilSubmitButton::getInstance();
481  $button->setCaption("svy_create_question");
482  $button->setCommand("createQuestion");
483  $ilToolbar->addButtonInstance($button);
484 
485  $ilToolbar->addSeparator();
486 
487  $button = ilSubmitButton::getInstance();
488  $button->setCaption("import");
489  $button->setCommand("importQuestions");
490  $ilToolbar->addButtonInstance($button);
491  }
492 
493  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
494  $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions', (($this->checkPermissionBool('write') ? true : false)));
495  $table_gui->setEditable($this->checkPermissionBool('write'));
496  $arrFilter = array();
497  foreach ($table_gui->getFilterItems() as $item)
498  {
499  if ($item->getValue() !== false)
500  {
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  global $ilToolbar;
529 
530  $ilToolbar->addButton($this->lng->txt('create_export_file'),
531  $this->ctrl->getLinkTarget($this, 'createExportFile'));
532 
533  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
534  $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export');
535  $export_dir = $this->object->getExportDirectory();
536  $export_files = $this->object->getExportFiles($export_dir);
537  $data = array();
538  foreach ($export_files as $exp_file)
539  {
540  $file_arr = explode("__", $exp_file);
541  array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
542  }
543  $table_gui->setData($data);
544  $this->tpl->setContent($table_gui->getHTML());
545  }
546 
550  public function createExportFileObject($questions = null)
551  {
552  $this->checkPermission("write");
553 
554  include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
555  $survey_exp = new ilSurveyQuestionpoolExport($this->object);
556  $survey_exp->buildExportFile($questions);
557  $this->ctrl->redirect($this, "export");
558  }
559 
563  public function downloadExportFileObject()
564  {
565  if(!isset($_POST["file"]))
566  {
567  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
568  $this->ctrl->redirect($this, "export");
569  }
570 
571  if (count($_POST["file"]) > 1)
572  {
573  ilUtil::sendInfo($this->lng->txt("select_max_one_item"),true);
574  $this->ctrl->redirect($this, "export");
575  }
576 
577 
578  $export_dir = $this->object->getExportDirectory();
579 
580  $file = basename($_POST["file"][0]);
581 
582  ilUtil::deliverFile($export_dir."/".$file, $file);
583  }
584 
589  {
590  if(!isset($_POST["file"]))
591  {
592  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
593  $this->ctrl->redirect($this, "export");
594  }
595 
596  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
597  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
598  $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export', true);
599  $export_dir = $this->object->getExportDirectory();
600  $data = array();
601  foreach ($_POST['file'] as $exp_file)
602  {
603  $file_arr = explode("__", $exp_file);
604  array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
605  }
606  $table_gui->setData($data);
607  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
608  }
609 
610 
615  {
616  ilSession::clear("ilExportFiles");
617  $this->ctrl->redirect($this, "export");
618  }
619 
623  public function deleteExportFileObject()
624  {
625  $export_dir = $this->object->getExportDirectory();
626  foreach($_POST['file'] as $file)
627  {
628  $file = basename($file);
629 
630  $exp_file = $export_dir."/".$file;
631  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
632  if (@is_file($exp_file))
633  {
634  unlink($exp_file);
635  }
636  if (@is_dir($exp_dir))
637  {
638  ilUtil::delDir($exp_dir);
639  }
640  }
641  $this->ctrl->redirect($this, "export");
642  }
643 
644  protected function initImportForm($a_new_type)
645  {
646  $form = parent::initImportForm($a_new_type);
647  $form->getItemByPostVar('importfile')->setSuffixes(array("zip", "xml"));
648 
649  return $form;
650  }
651 
652  protected function initCreationForms($a_new_type)
653  {
654  $form = $this->initImportForm($a_new_type);
655 
656  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
657  self::CFORM_IMPORT => $form);
658 
659  return $forms;
660  }
661 
665  public function importFileObject($parent_id = null, $a_catch_errors = true)
666  {
667  global $tpl, $ilErr;
668 
669  if(!$parent_id)
670  {
671  $parent_id = $_GET["ref_id"];
672  }
673  $new_type = $_REQUEST["new_type"];
674 
675  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
676  if (!$this->checkPermissionBool("create", "", $new_type))
677  {
678  $ilErr->raiseError($this->lng->txt("no_create_permission"));
679  }
680 
681  $this->lng->loadLanguageModule($new_type);
682  $this->ctrl->setParameter($this, "new_type", $new_type);
683 
684  $form = $this->initImportForm($new_type);
685  if ($form->checkInput())
686  {
687  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
688  $newObj = new ilObjSurveyQuestionPool();
689  $newObj->setType($new_type);
690  $newObj->setTitle("dummy");
691  $newObj->create(true);
692  $this->putObjectInTree($newObj);
693 
694  $newObj->createImportDirectory();
695 
696  // copy uploaded file to import directory
697  $upload = $_FILES["importfile"];
698  $file = pathinfo($upload["name"]);
699  $full_path = $newObj->getImportDirectory()."/".$upload["name"];
700  ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"],
701  $full_path);
702 
703  // import qti data
704  $qtiresult = $newObj->importObject($full_path);
705 
706  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
707  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
708  "&baseClass=ilObjSurveyQuestionPoolGUI");
709  }
710 
711  // display form to correct errors
712  $form->setValuesByPost();
713  $tpl->setContent($form->getHtml());
714  }
715 
719  public function &createQuestionObject()
720  {
721  global $ilUser;
722 
723  $ilUser->writePref("svy_lastquestiontype", $_POST["sel_question_types"]);
724 
725  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
726  $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
727  $q_gui->object->setObjId($this->object->getId());
728  $q_gui->object->createNewQuestion();
729 
730  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
731  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
732  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
733  }
734 
738  public function &previewObject()
739  {
740  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
741  $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
742  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
743  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
744  $this->ctrl->redirectByClass(get_class($q_gui), "preview");
745  }
746 
752  function infoScreenObject()
753  {
754  $this->ctrl->setCmd("showSummary");
755  $this->ctrl->setCmdClass("ilinfoscreengui");
756  $this->infoScreenForward();
757  }
758 
762  function infoScreenForward()
763  {
764  if (!$this->checkPermissionBool("read"))
765  {
766  $this->checkPermission("visible");
767  }
768 
769  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
770  $info = new ilInfoScreenGUI($this);
771  $info->enablePrivateNotes();
772 
773  // standard meta data
774  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
775 
776  $this->ctrl->forwardCommand($info);
777  }
778 
779  public function addLocatorItems()
780  {
781  global $ilLocator;
782  switch ($this->ctrl->getCmd())
783  {
784  case "create":
785  case "importFile":
786  case "cancel":
787  break;
788  default:
789  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
790  break;
791  }
792  if ((int)$_GET["q_id"])
793  {
794  $q_id = (int)$_GET["q_id"];
795  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
796  $q_type = SurveyQuestion::_getQuestionType($q_id) . "GUI";
797  $q_title = SurveyQuestion::_getTitle($q_id);
798  if($q_title)
799  {
800  // not on create
801  $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
802  $ilLocator->addItem($q_title,
803  $this->ctrl->getLinkTargetByClass($q_type, "editQuestion"));
804  }
805  }
806  }
807 
813  public function getTabs()
814  {
815  global $ilHelp;
816 
817  $ilHelp->setScreenIdComponent("spl");
818 
819  $next_class = $this->ctrl->getNextClass($this);
820  switch ($next_class)
821  {
822  case "":
823  case "ilpermissiongui":
824  case "ilobjectmetadatagui":
825  case "ilsurveyphrasesgui":
826  break;
827  default:
828  return;
829  break;
830  }
831 
832  // questions
833  $force_active = (($this->ctrl->getCmdClass() == "" &&
834  $this->ctrl->getCmd() != "properties" && $this->ctrl->getCmd() != "infoScreen") ||
835  $this->ctrl->getCmd() == "")
836  ? true
837  : false;
838  if (!$force_active)
839  {
840  if (is_array($_GET["sort"]))
841  {
842  $force_active = true;
843  }
844  }
845 
846  if ($this->checkPermissionBool("read"))
847  {
848  $this->tabs_gui->addTarget("survey_questions",
849  $this->ctrl->getLinkTarget($this,'questions'),
850  array("questions", "filterQuestionBrowser", "filter", "reset", "createQuestion",
851  "importQuestions", "deleteQuestions", "copy", "paste",
852  "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
853  "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
854  "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
855  "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
856  "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
857  "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
858  "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
859  "cancelDeleteCategory", "categories", "saveCategories",
860  "savePhrase", "addPhrase"
861  ),
862  array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"), "", $force_active);
863 
864  $this->tabs_gui->addTarget("info_short",
865  $this->ctrl->getLinkTarget($this, "infoScreen"),
866  array("infoScreen", "showSummary"));
867  }
868 
869  if ($this->checkPermissionBool('write'))
870  {
871  // properties
872  $this->tabs_gui->addTarget("settings",
873  $this->ctrl->getLinkTarget($this,'properties'),
874  array("properties", "saveProperties"),
875  "", "");
876 
877  // manage phrases
878  $this->tabs_gui->addTarget("manage_phrases",
879  $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
880  array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase", "editPhrase", "newPhrase", "saveEditPhrase", "phraseEditor"),
881  "ilsurveyphrasesgui", "");
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  {
889  $this->tabs_gui->addTarget("meta_data",
890  $mdtab,
891  "", "ilmdeditorgui");
892  }
893 
894  // export
895  $this->tabs_gui->addTarget("export",
896  $this->ctrl->getLinkTarget($this,'export'),
897  array("export", "createExportFile", "confirmDeleteExportFile",
898  "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
899  "", "");
900  }
901 
902  if ($this->checkPermissionBool("edit_permission"))
903  {
904  $this->tabs_gui->addTarget("perm_settings",
905  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
906  }
907  }
908 
912  public function saveObligatoryObject()
913  {
914  $obligatory = array();
915  foreach ($_POST as $key => $value)
916  {
917  if (preg_match("/obligatory_(\d+)/", $key, $matches))
918  {
919  $obligatory[]= $matches[1];
920  }
921  }
922  $this->object->setObligatoryStates($obligatory);
923 
924  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
925  $this->ctrl->redirect($this, "questions");
926  }
927 
934  public static function _goto($a_target)
935  {
936  global $ilAccess, $lng;
937 
938  if ($ilAccess->checkAccess("visible", "", $a_target) ||
939  $ilAccess->checkAccess("read", "", $a_target))
940  {
941  $_GET["baseClass"] = "ilObjSurveyQuestionPoolGUI";
942  $_GET["cmd"] = "infoScreen";
943  $_GET["ref_id"] = $a_target;
944  include_once("ilias.php");
945  exit;
946  }
947  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
948  {
949  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
952  }
953  }
954 } // END class.ilObjSurveyQuestionPoolGUI
955 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilObjSurveyQuestionPoolGUI.
cancelDeleteQuestionsObject()
cancel delete questions
importQuestionsObject()
display the import form to import questions into the questionpool
global $ilErr
Definition: raiseError.php:16
$error
Definition: Error.php:17
Class ilObjectMetaDataGUI.
Class ilInfoScreenGUI.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
confirmDeleteExportFileObject()
confirmation screen for export file deletion
This class represents a property form user interface.
GUI class for the workflow of copying objects.
const TITLE_LENGTH
max length of object title
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
copyObject()
Copies checked questions in the questionpool to a clipboard.
This class represents a file property in a property form.
Class ilObject Basic functions for all objects.
static _getTitle($question_id)
Returns the question title of a question with a given id.
saveObligatoryObject()
Save obligatory states.
$cmd
Definition: sahs_server.php:35
setValue($a_value)
Set Value.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
Survey phrases GUI class.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
const IL_CAL_UNIX
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
cancelDeleteExportFileObject()
cancel deletion of export files
static _goto($a_target)
Redirect script to call a survey question pool reference id.
savePropertiesObject()
Save questionpool properties.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$info
Definition: example_052.php:80
prepareOutput($a_show_subobjects=true)
prepare output
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
questionsObject($arrFilter=null)
list questions of question pool
if(!is_array($argv)) $options
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
importFileObject($parent_id=null, $a_catch_errors=true)
form for new survey object import
Export class for survey questionpools.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
$ilUser
Definition: imgupload.php:18
static clear($a_var)
Unset a value.
initCreateForm($a_new_type)
Init object creation form.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$txt
Definition: error.php:12
Create styles array
The data for the language used.
propertiesObject(ilPropertyFormGUI $a_form=null)
Questionpool properties.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
& previewObject()
create preview of object
deleteQuestionsObject()
Creates a confirmation form to delete questions from the question pool.
createExportFileObject($questions=null)
create export file
Create new PHPExcel object
obj_idprivate
This class represents a text area property in a property form.
$ret
Definition: parser.php:6
getCreationMode()
get creation mode
getRefId()
get reference id public
uploadQuestionsObject()
imports question(s) into the questionpool
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static getLogger($a_component_id)
Get component logger.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
moveObject()
mark one or more question objects for moving
static redirect($a_script)
http redirect to other script
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
$_POST["username"]
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
pasteObject()
paste questios from the clipboard into the question pool
Confirmation screen class.