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