ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
26 
44 {
46 
51  public function ilObjSurveyQuestionPoolGUI()
52  {
53  global $lng, $ilCtrl;
54 
55  $this->type = "spl";
56  $lng->loadLanguageModule("survey");
57  $this->ctrl =& $ilCtrl;
58  $this->ctrl->saveParameter($this, array("ref_id", "calling_survey", "new_for_survey", "pgov", "pgov_pos"));
59 
60  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
61  }
62 
66  public function executeCommand()
67  {
68  global $ilAccess, $ilNavigationHistory, $ilErr;
69 
70  if($this->ctrl->getCmd("questions") != "questions")
71  {
72  // #11186
73  $rbac_ref_id = $_REQUEST["calling_survey"];
74  if(!$rbac_ref_id)
75  {
76  $rbac_ref_id = $_REQUEST["new_for_survey"];
77  }
78  if(!$rbac_ref_id)
79  {
80  $rbac_ref_id = $_REQUEST["ref_id"];
81  }
82  }
83  else
84  {
85  $rbac_ref_id = $_REQUEST["ref_id"];
86  }
87 
88  // #11418 - goto
89  if(!$rbac_ref_id)
90  {
91  $rbac_ref_id = $_GET["ref_id"];
92  }
93 
94  if (!$ilAccess->checkAccess("read", "", $rbac_ref_id) &&
95  !$ilAccess->checkAccess("visible", "", $rbac_ref_id))
96  {
97  global $ilias;
98  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
99  }
100 
101  // add entry to navigation history
102  if (!$this->getCreationMode() &&
103  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
104  {
105  $ilNavigationHistory->addItem($_GET["ref_id"],
106  "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".$_GET["ref_id"], "spl");
107  }
108 
109  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "Modules/Survey"), "screen");
110  $this->prepareOutput();
111  $cmd = $this->ctrl->getCmd("questions");
112  $next_class = $this->ctrl->getNextClass($this);
113  $this->ctrl->setReturn($this, "questions");
114  if ($_GET["q_id"] < 1)
115  {
116  $q_type = ($_POST["sel_question_types"] != "")
117  ? $_POST["sel_question_types"]
118  : $_GET["sel_question_types"];
119  }
120  switch($next_class)
121  {
122  case 'ilmdeditorgui':
123  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
124  {
125  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
126  }
127 
128  include_once "./Services/MetaData/classes/class.ilMDEditorGUI.php";
129  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
130  $md_gui->addObserver($this->object,'MDUpdateListener','General');
131 
132  $this->ctrl->forwardCommand($md_gui);
133  break;
134 
135  case 'ilpermissiongui':
136  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
137  $perm_gui =& new ilPermissionGUI($this);
138  $ret =& $this->ctrl->forwardCommand($perm_gui);
139  break;
140 
141  case "ilsurveyphrasesgui":
142  include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
143  $phrases_gui =& new ilSurveyPhrasesGUI($this);
144  $ret =& $this->ctrl->forwardCommand($phrases_gui);
145  break;
146 
147  case 'ilobjectcopygui':
148  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
149  $cp = new ilObjectCopyGUI($this);
150  $cp->setType('spl');
151  $this->ctrl->forwardCommand($cp);
152  break;
153 
154  case 'ilinfoscreengui':
155  $this->infoScreenForward();
156  break;
157 
158  case "ilcommonactiondispatchergui":
159  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
161  $this->ctrl->forwardCommand($gui);
162  break;
163 
164  case "":
165  $cmd.= "Object";
166  $ret =& $this->$cmd();
167  break;
168 
169  default:
170  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
171  $q_gui = SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
172  $q_gui->object->setObjId($this->object->getId());
173  $q_gui->setQuestionTabs();
174  $ret =& $this->ctrl->forwardCommand($q_gui);
175  break;
176  }
177  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
178  $this->getCreationMode() != true)
179  {
180  $this->tpl->show();
181  }
182  }
183 
187  public function propertiesObject()
188  {
189  $save = ((strcmp($this->ctrl->getCmd(), "save") == 0)) ? true : false;
190 
191  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
192  $form = new ilPropertyFormGUI();
193  $form->setFormAction($this->ctrl->getFormAction($this, 'properties'));
194  $form->setTitle($this->lng->txt("properties"));
195  $form->setMultipart(false);
196  $form->setId("properties");
197 
198  // online
199  $online = new ilCheckboxInputGUI($this->lng->txt("spl_online_property"), "online");
200  $online->setInfo($this->lng->txt("spl_online_property_description"));
201  $online->setChecked($this->object->getOnline());
202  $form->addItem($online);
203 
204  $form->addCommandButton("saveProperties", $this->lng->txt("save"));
205 
206  if ($save)
207  {
208  $form->checkInput();
209  }
210  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
211  }
212 
216  public function savePropertiesObject()
217  {
218  $qpl_online = $_POST["online"];
219  if (strlen($qpl_online) == 0) $qpl_online = "0";
220  $this->object->setOnline($qpl_online);
221  $this->object->saveToDb();
222  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
223  $this->ctrl->redirect($this, "properties");
224  }
225 
226 
230  public function copyObject()
231  {
232  if (count($_POST["q_id"]) > 0)
233  {
234  foreach ($_POST["q_id"] as $key => $value)
235  {
236  $this->object->copyToClipboard($value);
237  }
238  ilUtil::sendInfo($this->lng->txt("spl_copy_insert_clipboard"), true);
239  }
240  else
241  {
242  ilUtil::sendInfo($this->lng->txt("spl_copy_select_none"), true);
243  }
244  $this->ctrl->redirect($this, "questions");
245  }
246 
250  public function moveObject()
251  {
252  if (count($_POST["q_id"]) > 0)
253  {
254  foreach ($_POST["q_id"] as $key => $value)
255  {
256  $this->object->moveToClipboard($value);
257  }
258  ilUtil::sendInfo($this->lng->txt("spl_move_insert_clipboard"), true);
259  }
260  else
261  {
262  ilUtil::sendInfo($this->lng->txt("spl_move_select_none"), true);
263  }
264  $this->ctrl->redirect($this, "questions");
265  }
266 
270  public function exportQuestionObject()
271  {
272  if (is_array($_POST['q_id']) && count($_POST['q_id']) > 0)
273  {
274  $this->createExportFileObject($_POST['q_id']);
275  }
276  else
277  {
278  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"));
279  $this->questionsObject();
280  }
281  }
282 
286  public function deleteQuestionsObject()
287  {
288  global $rbacsystem;
289 
290  // create an array of all checked checkboxes
291  $checked_questions = $_POST['q_id'];
292  if (count($checked_questions) > 0)
293  {
294  if (!$rbacsystem->checkAccess('write', $this->ref_id))
295  {
296  ilUtil::sendFailure($this->lng->txt("qpl_delete_rbac_error"));
297  $this->questionsObject();
298  return;
299  }
300  }
301  elseif (count($checked_questions) == 0)
302  {
303  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
304  $this->questionsObject();
305  return;
306  }
307 
308  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
309  $cgui = new ilConfirmationGUI();
310  $cgui->setHeaderText($this->lng->txt("qpl_confirm_delete_questions"));
311 
312  $cgui->setFormAction($this->ctrl->getFormAction($this));
313  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteQuestions");
314  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteQuestions");
315 
316  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
317  $infos = $this->object->getQuestionInfos($checked_questions);
318  foreach ($infos as $data)
319  {
320  $txt = $data["title"]." (".
321  SurveyQuestion::_getQuestionTypeName($data["type_tag"]).")";
322  if($data["description"])
323  {
324  $txt .= "<div class=\"small\">".$data["description"]."</div>";
325  }
326 
327  $cgui->addItem("q_id[]", $data["id"], $txt);
328  }
329 
330  $this->tpl->setContent($cgui->getHTML());
331  }
332 
337  {
338  // delete questions after confirmation
339  ilUtil::sendSuccess($this->lng->txt("qpl_questions_deleted"), true);
340  foreach ($_POST['q_id'] as $q_id)
341  {
342  $this->object->removeQuestion($q_id);
343  }
344  $this->ctrl->redirect($this, "questions");
345  }
346 
350  public function cancelDeleteQuestionsObject()
351  {
352  // delete questions after confirmation
353  $this->ctrl->redirect($this, "questions");
354  }
355 
359  public function pasteObject()
360  {
361  if (array_key_exists("spl_clipboard", $_SESSION))
362  {
363  $this->object->pasteFromClipboard();
364  }
365  else
366  {
367  ilUtil::sendInfo($this->lng->txt("spl_paste_no_objects"), true);
368  }
369  $this->ctrl->redirect($this, "questions");
370  }
371 
375  public function importQuestionsObject()
376  {
377  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_import_question.html", "Modules/SurveyQuestionPool");
378  $this->tpl->setCurrentBlock("adm_content");
379  $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
380  $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
381  $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
382  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
383  $this->tpl->parseCurrentBlock();
384  }
385 
389  public function uploadQuestionsObject()
390  {
391  // check if file was uploaded
392  $source = $_FILES["qtidoc"]["tmp_name"];
393  $error = 0;
394  if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
395  {
396  $error = 1;
397  }
398  // check correct file type
399  if (strpos("xml", $_FILES["qtidoc"]["type"]) !== FALSE)
400  {
401  $error = 1;
402  }
403  if (!$error)
404  {
405  // import file into questionpool
406  // create import directory
407  $this->object->createImportDirectory();
408 
409  // copy uploaded file to import directory
410  $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
411 
412  include_once "./Services/Utilities/classes/class.ilUtil.php";
413  ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"],
414  $_FILES["qtidoc"]["name"], $full_path);
415  $source = $full_path;
416  $this->object->importObject($source, TRUE);
417  unlink($source);
418  }
419  $this->ctrl->redirect($this, "questions");
420  }
421 
422  public function filterQuestionBrowserObject()
423  {
424  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
425  $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
426  $table_gui->writeFilterToSession();
427  $this->ctrl->redirect($this, 'questions');
428  }
429 
431  {
432  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
433  $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions');
434  $table_gui->resetFilter();
435  $this->ctrl->redirect($this, 'questions');
436  }
437 
441  public function questionsObject($arrFilter = null)
442  {
443  global $rbacsystem;
444  global $ilUser;
445  global $ilToolbar;
446 
447  if(get_class($this->object) == "ilObjSurvey")
448  {
449  if (($_GET["calling_survey"] > 0) || ($_GET["new_for_survey"] > 0))
450  {
451  $ref_id = $_GET["calling_survey"];
452  if (!strlen($ref_id)) $ref_id = $_GET["new_for_survey"];
453  $addurl = "";
454  if (strlen($_GET["new_for_survey"]))
455  {
456  $addurl = "&new_id=" . $_GET["q_id"];
457  }
458  if ($_REQUEST["pgov"])
459  {
460  $addurl .= "&pgov=".$_REQUEST["pgov"];
461  $addurl .= "&pgov_pos=".$_REQUEST["pgov_pos"];
462  }
463 
464  ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=".$ref_id."&cmd=questions".$addurl);
465  }
466  }
467 
468  $this->object->purgeQuestions();
469 
470  $_SESSION['q_id_table_nav'] = $_GET['q_id_table_nav'];
471 
472  if ($rbacsystem->checkAccess('write', $_GET['ref_id']))
473  {
474  include_once "Services/Form/classes/class.ilSelectInputGUI.php";
475  $qtypes = new ilSelectInputGUI("", "sel_question_types");
476  $qtypes->setValue($ilUser->getPref("svy_lastquestiontype"));
477  $ilToolbar->addInputItem($qtypes);
478 
479  $options = array();
480  foreach (ilObjSurveyQuestionPool::_getQuestionTypes() as $translation => $data)
481  {
482  $options[$data["type_tag"]] = $translation;
483  }
484  $qtypes->setOptions($options);
485 
486  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
487  $ilToolbar->addFormButton($this->lng->txt("create"), "createQuestion");
488 
489  $ilToolbar->addSeparator();
490 
491  $ilToolbar->addFormButton($this->lng->txt('import'), 'importQuestions');
492  }
493 
494  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionsTableGUI.php";
495  $table_gui = new ilSurveyQuestionsTableGUI($this, 'questions', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)));
496  $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
497  $arrFilter = array();
498  foreach ($table_gui->getFilterItems() as $item)
499  {
500  if ($item->getValue() !== false)
501  {
502  $arrFilter[$item->getPostVar()] = $item->getValue();
503  }
504  }
505  $table_gui->setData($this->object->getQuestionsData($arrFilter));
506  $this->tpl->setContent($table_gui->getHTML());
507  }
508 
509  public function updateObject()
510  {
511  $this->update = $this->object->update();
512  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
513  }
514 
515  public function afterSave(ilObject $a_new_object)
516  {
517  // always send a message
518  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
519 
520  ilUtil::redirect("ilias.php?ref_id=".$a_new_object->getRefId().
521  "&baseClass=ilObjSurveyQuestionPoolGUI");
522  }
523 
524  /*
525  * list all export files
526  */
527  public function exportObject()
528  {
529  global $ilToolbar;
530 
531  $ilToolbar->addButton($this->lng->txt('create_export_file'),
532  $this->ctrl->getLinkTarget($this, 'createExportFile'));
533 
534  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
535  $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export');
536  $export_dir = $this->object->getExportDirectory();
537  $export_files = $this->object->getExportFiles($export_dir);
538  $data = array();
539  foreach ($export_files as $exp_file)
540  {
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  global $rbacsystem;
554 
555  if ($rbacsystem->checkAccess("write", $this->ref_id))
556  {
557  include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
558  $survey_exp = new ilSurveyQuestionpoolExport($this->object);
559  $survey_exp->buildExportFile($questions);
560  $this->ctrl->redirect($this, "export");
561  }
562  else
563  {
564  ilUtil::sendInfo("cannot_export_questionpool");
565  }
566  }
567 
571  public function downloadExportFileObject()
572  {
573  if(!isset($_POST["file"]))
574  {
575  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
576  $this->ctrl->redirect($this, "export");
577  }
578 
579  if (count($_POST["file"]) > 1)
580  {
581  ilUtil::sendInfo($this->lng->txt("select_max_one_item"),true);
582  $this->ctrl->redirect($this, "export");
583  }
584 
585 
586  $export_dir = $this->object->getExportDirectory();
587  include_once "./Services/Utilities/classes/class.ilUtil.php";
588 
589  $file = basename($_POST["file"][0]);
590 
591  ilUtil::deliverFile($export_dir."/".$file, $file);
592  }
593 
598  {
599  if(!isset($_POST["file"]))
600  {
601  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
602  $this->ctrl->redirect($this, "export");
603  }
604 
605  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
606  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyQuestionPoolExportTableGUI.php";
607  $table_gui = new ilSurveyQuestionPoolExportTableGUI($this, 'export', true);
608  $export_dir = $this->object->getExportDirectory();
609  $data = array();
610  foreach ($_POST['file'] as $exp_file)
611  {
612  $file_arr = explode("__", $exp_file);
613  array_push($data, array('file' => $exp_file, 'date' => ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)), 'size' => filesize($export_dir."/".$exp_file)));
614  }
615  $table_gui->setData($data);
616  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
617  }
618 
619 
624  {
625  ilSession::clear("ilExportFiles");
626  $this->ctrl->redirect($this, "export");
627  }
628 
632  public function deleteExportFileObject()
633  {
634  $export_dir = $this->object->getExportDirectory();
635  foreach($_POST['file'] as $file)
636  {
637  $file = basename($file);
638 
639  $exp_file = $export_dir."/".$file;
640  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
641  if (@is_file($exp_file))
642  {
643  unlink($exp_file);
644  }
645  if (@is_dir($exp_dir))
646  {
647  include_once "./Services/Utilities/classes/class.ilUtil.php";
648  ilUtil::delDir($exp_dir);
649  }
650  }
651  $this->ctrl->redirect($this, "export");
652  }
653 
654  protected function initImportForm($a_new_type)
655  {
656  $form = parent::initImportForm($a_new_type);
657  $form->getItemByPostVar('importfile')->setSuffixes(array("zip", "xml"));
658 
659  return $form;
660  }
661 
662  protected function initCreationForms($a_new_type)
663  {
664  $form = $this->initImportForm($a_new_type);
665 
666  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
667  self::CFORM_IMPORT => $form);
668 
669  return $forms;
670  }
671 
675  public function importFileObject()
676  {
677  global $tpl, $ilErr;
678 
679  $parent_id = $_GET["ref_id"];
680  $new_type = $_REQUEST["new_type"];
681 
682  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
683  if (!$this->checkPermissionBool("create", "", $new_type))
684  {
685  $ilErr->raiseError($this->lng->txt("no_create_permission"));
686  }
687 
688  $this->lng->loadLanguageModule($new_type);
689  $this->ctrl->setParameter($this, "new_type", $new_type);
690 
691  $form = $this->initImportForm($new_type);
692  if ($form->checkInput())
693  {
694  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
695  $newObj = new ilObjSurveyQuestionPool();
696  $newObj->setType($new_type);
697  $newObj->setTitle("dummy");
698  $newObj->create(true);
699  $this->putObjectInTree($newObj);
700 
701  $newObj->createImportDirectory();
702 
703  // copy uploaded file to import directory
704  $upload = $_FILES["importfile"];
705  $file = pathinfo($upload["name"]);
706  $full_path = $newObj->getImportDirectory()."/".$upload["name"];
707  include_once "./Services/Utilities/classes/class.ilUtil.php";
708  ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"],
709  $full_path);
710 
711  // import qti data
712  $qtiresult = $newObj->importObject($full_path);
713 
714  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
715  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
716  "&baseClass=ilObjSurveyQuestionPoolGUI");
717  }
718 
719  // display form to correct errors
720  $form->setValuesByPost();
721  $tpl->setContent($form->getHtml());
722  }
723 
727  public function &createQuestionObject()
728  {
729  global $ilUser;
730  $ilUser->writePref("svy_lastquestiontype", $_POST["sel_question_types"]);
731  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
732  $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
733  $q_gui->object->setObjId($this->object->getId());
734  $q_gui->object->createNewQuestion();
735  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
736  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $_POST["sel_question_types"]);
737  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
738  }
739 
743  public function &editQuestionForSurveyObject()
744  {
745  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
746  $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
747  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
748  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["q_id"]);
749  $this->ctrl->setParameterByClass(get_class($q_gui), "pgov", $_GET["pgov"]);
750  $this->ctrl->setParameterByClass(get_class($q_gui), "pgov_pos", $_GET["pgov_pos"]);
751  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
752  }
753 
757  public function &createQuestionForSurveyObject()
758  {
759  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
760  $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
761  $q_gui->object->createNewQuestion();
762  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $q_gui->object->getId());
763  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
764  $this->ctrl->setParameterByClass(get_class($q_gui), "pgov", $_GET["pgov"]);
765  $this->ctrl->setParameterByClass(get_class($q_gui), "pgov_pos", $_GET["pgov_pos"]);
766  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
767  }
768 
772  public function &previewObject()
773  {
774  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
775  $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
776  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
777  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
778  $this->ctrl->redirectByClass(get_class($q_gui), "preview");
779  }
780 
786  function infoScreenObject()
787  {
788  $this->ctrl->setCmd("showSummary");
789  $this->ctrl->setCmdClass("ilinfoscreengui");
790  $this->infoScreenForward();
791  }
792 
796  function infoScreenForward()
797  {
798  global $ilErr, $ilAccess;
799 
800  if(!$ilAccess->checkAccess("visible", "", $this->ref_id))
801  {
802  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
803  }
804 
805  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
806  $info = new ilInfoScreenGUI($this);
807  $info->enablePrivateNotes();
808 
809  // standard meta data
810  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
811 
812  $this->ctrl->forwardCommand($info);
813  }
814 
815  public function addLocatorItems()
816  {
817  global $ilLocator;
818  switch ($this->ctrl->getCmd())
819  {
820  case "create":
821  case "importFile":
822  case "cancel":
823  break;
824  default:
825  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
826  break;
827  }
828  if ($_GET["q_id"] > 0)
829  {
830  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
831  $q_type = SurveyQuestion::_getQuestionType($_GET["q_id"]) . "GUI";
832  $this->ctrl->setParameterByClass($q_type, "q_id", $_GET["q_id"]);
833  $ilLocator->addItem(SurveyQuestion::_getTitle($_GET["q_id"]), $this->ctrl->getLinkTargetByClass($q_type, "editQuestion"));
834  }
835  }
836 
842  public function getTabs(&$tabs_gui)
843  {
844  global $ilAccess, $ilHelp;
845 
846  $ilHelp->setScreenIdComponent("spl");
847 
848  $next_class = $this->ctrl->getNextClass($this);
849  switch ($next_class)
850  {
851  case "":
852  case "ilpermissiongui":
853  case "ilmdeditorgui":
854  case "ilsurveyphrasesgui":
855  break;
856  default:
857  return;
858  break;
859  }
860  if (($_GET["calling_survey"] > 0) || ($_GET["new_for_survey"] > 0)) return;
861  // questions
862  $force_active = (($this->ctrl->getCmdClass() == "" &&
863  $this->ctrl->getCmd() != "properties") ||
864  $this->ctrl->getCmd() == "")
865  ? true
866  : false;
867  if (!$force_active)
868  {
869  if (is_array($_GET["sort"]))
870  {
871  $force_active = true;
872  }
873  }
874  $tabs_gui->addTarget("survey_questions",
875  $this->ctrl->getLinkTarget($this,'questions'),
876  array("questions", "filterQuestionBrowser", "filter", "reset", "createQuestion",
877  "importQuestions", "deleteQuestions", "copy", "paste",
878  "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
879  "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
880  "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
881  "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
882  "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
883  "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
884  "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
885  "cancelDeleteCategory", "categories", "saveCategories",
886  "savePhrase", "addPhrase"
887  ),
888  array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"), "", $force_active);
889 
890  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
891  {
892  $tabs_gui->addTarget("info_short",
893  $this->ctrl->getLinkTarget($this, "infoScreen"),
894  array("infoScreen", "showSummary"));
895  }
896 
897  if ($ilAccess->checkAccess('write', '', $this->ref_id))
898  {
899  // properties
900  $tabs_gui->addTarget("settings",
901  $this->ctrl->getLinkTarget($this,'properties'),
902  "properties",
903  "", "");
904 
905  // manage phrases
906  $tabs_gui->addTarget("manage_phrases",
907  $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
908  array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase", "editPhrase", "newPhrase", "saveEditPhrase", "phraseEditor"),
909  "ilsurveyphrasesgui", "");
910 
911  // meta data
912  $tabs_gui->addTarget("meta_data",
913  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
914  "", "ilmdeditorgui");
915 
916  // export
917  $tabs_gui->addTarget("export",
918  $this->ctrl->getLinkTarget($this,'export'),
919  array("export", "createExportFile", "confirmDeleteExportFile",
920  "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
921  "", "");
922  }
923 
924  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
925  {
926  $tabs_gui->addTarget("perm_settings",
927  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
928  }
929  }
930 
934  public function saveObligatoryObject()
935  {
936  $obligatory = array();
937  foreach ($_POST as $key => $value)
938  {
939  if (preg_match("/obligatory_(\d+)/", $key, $matches))
940  {
941  $obligatory[]= $matches[1];
942  }
943  }
944  $this->object->setObligatoryStates($obligatory);
945 
946  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
947  $this->ctrl->redirect($this, "questions");
948  }
949 
956  public static function _goto($a_target)
957  {
958  global $ilAccess, $ilErr, $lng;
959 
960  if ($ilAccess->checkAccess("write", "", $a_target))
961  {
962  $_GET["baseClass"] = "ilObjSurveyQuestionPoolGUI";
963  $_GET["cmd"] = "questions";
964  $_GET["ref_id"] = $a_target;
965  include_once("ilias.php");
966  exit;
967  }
968  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
969  {
970  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
973  }
974  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
975  }
976 } // END class.ilObjSurveyQuestionPoolGUI
977 ?>