ILIAS  Release_3_10_x_branch Revision 61812
 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 
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"));
58 
59  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
60  }
61 
65  function &executeCommand()
66  {
67  global $ilAccess, $ilNavigationHistory;
68 
69  // add entry to navigation history
70  if (!$this->getCreationMode() &&
71  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
72  {
73  $ilNavigationHistory->addItem($_GET["ref_id"],
74  "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".$_GET["ref_id"], "spl");
75  }
76 
77  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "Modules/Survey"), "screen");
78  $this->prepareOutput();
79  $cmd = $this->ctrl->getCmd("questions");
80  $next_class = $this->ctrl->getNextClass($this);
81  $this->ctrl->setReturn($this, "questions");
82  if ($_GET["q_id"] < 1)
83  {
84  $q_type = ($_POST["sel_question_types"] != "")
85  ? $_POST["sel_question_types"]
86  : $_GET["sel_question_types"];
87  }
88  switch($next_class)
89  {
90  case 'ilmdeditorgui':
91  include_once "./Services/MetaData/classes/class.ilMDEditorGUI.php";
92  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
93  $md_gui->addObserver($this->object,'MDUpdateListener','General');
94 
95  $this->ctrl->forwardCommand($md_gui);
96  break;
97 
98  case 'ilpermissiongui':
99  include_once("./classes/class.ilPermissionGUI.php");
100  $perm_gui =& new ilPermissionGUI($this);
101  $ret =& $this->ctrl->forwardCommand($perm_gui);
102  break;
103 
104  case "ilsurveyphrasesgui":
105  include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
106  $phrases_gui =& new ilSurveyPhrasesGUI($this);
107  $ret =& $this->ctrl->forwardCommand($phrases_gui);
108  break;
109 
110  case "":
111  $cmd.= "Object";
112  $ret =& $this->$cmd();
113  break;
114 
115  default:
116  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
117  $q_gui = SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
118  $q_gui->object->setObjId($this->object->getId());
119  $q_gui->setQuestionTabs();
120  $ret =& $this->ctrl->forwardCommand($q_gui);
121  break;
122  }
123  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
124  $this->getCreationMode() != true)
125  {
126  $this->tpl->show();
127  }
128  }
129 
135  function cancelObject()
136  {
137  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
138  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
139  }
140 
141 
146  function saveObject()
147  {
148  global $rbacadmin;
149 
150  // create and insert forum in objecttree
151  $newObj = parent::saveObject();
152 
153  // always send a message
154  ilUtil::sendInfo($this->lng->txt("object_added"),true);
155 
156  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
157  "&baseClass=ilObjSurveyQuestionPoolGUI");
158  }
159 
168  function cancelAction($question_id = "")
169  {
170  $this->ctrl->redirect($this, "questions");
171  }
172 
176  function propertiesObject()
177  {
178  global $rbacsystem;
179 
180  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_properties.html", "Modules/SurveyQuestionPool");
181  $this->tpl->setCurrentBlock("adm_content");
182  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
183  $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("spl_general_properties"));
184  $this->tpl->setVariable("PROPERTY_ONLINE", $this->lng->txt("spl_online_property"));
185  $this->tpl->setVariable("PROPERTY_ONLINE_DESCRIPTION", $this->lng->txt("spl_online_property_description"));
186  if ($this->object->getOnline() == 1)
187  {
188  $this->tpl->setVariable("PROPERTY_ONLINE_CHECKED", " checked=\"checked\"");
189  }
190  if ($rbacsystem->checkAccess('write', $this->ref_id))
191  {
192  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
193  }
194  else
195  {
196  $this->tpl->setVariable("PROPERTY_ONLINE_DISABLED", " disabled=\"disabled\"");
197  }
198  $this->tpl->parseCurrentBlock();
199  }
200 
205  {
206  $qpl_online = $_POST["online"];
207  if (strlen($qpl_online) == 0) $qpl_online = "0";
208  $this->object->setOnline($qpl_online);
209  $this->object->saveToDb();
210  ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
211  $this->ctrl->redirect($this, "properties");
212  }
213 
214 
222  function copyObject()
223  {
224  // create an array of all checked checkboxes
225  $checked_questions = array();
226  foreach ($_POST as $key => $value)
227  {
228  if (preg_match("/cb_(\d+)/", $key, $matches))
229  {
230  array_push($checked_questions, $matches[1]);
231  }
232  }
233  // copy button was pressed
234  if (count($checked_questions) > 0)
235  {
236  $_SESSION["spl_copied_questions"] = $checked_questions;
237  }
238  else if (count($checked_questions) == 0)
239  {
240  ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"));
241  $_SESSION["spl_copied_questions"] = array();
242  }
243  $this->questionsObject();
244  }
245 
250  {
251  // create an array of all checked checkboxes
252  $checked_questions = array();
253  foreach ($_POST as $key => $value) {
254  if (preg_match("/cb_(\d+)/", $key, $matches)) {
255  array_push($checked_questions, $matches[1]);
256  }
257  }
258 
259  // export button was pressed
260  if (count($checked_questions) > 0)
261  {
262  $this->createExportFileObject($checked_questions);
263  }
264  else
265  {
266  ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"));
267  $this->questionsObject();
268  }
269  }
270 
279  {
280  global $rbacsystem;
281 
283  // create an array of all checked checkboxes
284  $checked_questions = array();
285  foreach ($_POST as $key => $value)
286  {
287  if (preg_match("/cb_(\d+)/", $key, $matches))
288  {
289  array_push($checked_questions, $matches[1]);
290  }
291  }
292 
293  if (count($checked_questions) > 0)
294  {
295  if ($rbacsystem->checkAccess('write', $this->ref_id))
296  {
297  ilUtil::sendInfo($this->lng->txt("qpl_confirm_delete_questions"));
298  }
299  else
300  {
301  ilUtil::sendInfo($this->lng->txt("qpl_delete_rbac_error"));
302  $this->questionsObject();
303  return;
304  }
305  }
306  elseif (count($checked_questions) == 0)
307  {
308  ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
309  $this->questionsObject();
310  return;
311  }
312  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_questions.html", "Modules/SurveyQuestionPool");
313  $whereclause = join($checked_questions, " OR survey_question.question_id = ");
314  $whereclause = " AND (survey_question.question_id = " . $whereclause . ")";
315  $query = "SELECT survey_question.*, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id$whereclause ORDER BY survey_question.title";
316  $query_result = $this->ilias->db->query($query);
317  $colors = array("tblrow1", "tblrow2");
318  $counter = 0;
319  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
320  if ($query_result->numRows() > 0)
321  {
322  while ($data = $query_result->fetchRow(MDB2_FETCHMODE_OBJECT))
323  {
324  if (in_array($data->question_id, $checked_questions))
325  {
326  $this->tpl->setCurrentBlock("row");
327  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
328  $this->tpl->setVariable("TXT_TITLE", $data->title);
329  $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
330  $this->tpl->setVariable("TXT_TYPE", SurveyQuestion::_getQuestionTypeName($data->type_tag));
331  $this->tpl->parseCurrentBlock();
332  $counter++;
333  }
334  }
335  }
336  foreach ($checked_questions as $id)
337  {
338  $this->tpl->setCurrentBlock("hidden");
339  $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
340  $this->tpl->setVariable("HIDDEN_VALUE", "1");
341  $this->tpl->parseCurrentBlock();
342  }
343 
344  $this->tpl->setCurrentBlock("adm_content");
345  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
346  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
347  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
348  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
349  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
350  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
351  $this->tpl->parseCurrentBlock();
352  }
353 
358  {
359  // delete questions after confirmation
360  ilUtil::sendInfo($this->lng->txt("qpl_questions_deleted"), true);
361  $checked_questions = array();
362  foreach ($_POST as $key => $value) {
363  if (preg_match("/id_(\d+)/", $key, $matches)) {
364  array_push($checked_questions, $matches[1]);
365  }
366  }
367 
368  foreach ($checked_questions as $key => $value) {
369  $this->object->removeQuestion($value);
370  }
371  $this->ctrl->redirect($this, "questions");
372  }
373 
378  {
379  // delete questions after confirmation
380  $this->ctrl->redirect($this, "questions");
381  }
382 
390  function pasteObject()
391  {
393 
394  // paste button was pressed
395  if (count($_SESSION["spl_copied_questions"]) == 0)
396  {
397  ilUtil::sendInfo($this->lng->txt("qpl_past_questions_confirmation"));
398  }
399  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_paste_questions.html", "Modules/SurveyQuestionPool");
400  $questions_info =& $this->object->getQuestionsInfo($_SESSION["spl_copied_questions"]);
401  $colors = array("tblrow1", "tblrow2");
402  $counter = 0;
403  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
404  foreach ($questions_info as $data)
405  {
406  $this->tpl->setCurrentBlock("row");
407  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
408  $this->tpl->setVariable("TXT_TITLE", $data["title"]);
409  $this->tpl->setVariable("TXT_DESCRIPTION", $data["description"]);
410  $this->tpl->setVariable("TXT_TYPE", SurveyQuestion::_getQuestionTypeName($data["type_tag"]));
411  $this->tpl->parseCurrentBlock();
412  $counter++;
413  }
414  foreach ($questions_info as $data)
415  {
416  $this->tpl->setCurrentBlock("hidden");
417  $this->tpl->setVariable("HIDDEN_NAME", "id_" . $data["question_id"]);
418  $this->tpl->setVariable("HIDDEN_VALUE", $data["question_id"]);
419  $this->tpl->parseCurrentBlock();
420  }
421 
422  $this->tpl->setCurrentBlock("adm_content");
423  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
424  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
425  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
426  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
427  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
428  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
429  $this->tpl->parseCurrentBlock();
430  }
431 
436  {
437  // paste questions after confirmation
438  ilUtil::sendInfo($this->lng->txt("qpl_questions_pasted"), true);
439  $checked_questions = array();
440  foreach ($_POST as $key => $value) {
441  if (preg_match("/id_(\d+)/", $key, $matches)) {
442  array_push($checked_questions, $matches[1]);
443  }
444  }
445  foreach ($checked_questions as $key => $value) {
446  $this->object->paste($value);
447  }
448 
449  $this->ctrl->redirect($this, "questions");
450  }
451 
456  {
457  // delete questions after confirmation
458  $this->ctrl->redirect($this, "questions");
459  }
460 
465  {
466  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_import_question.html", "Modules/SurveyQuestionPool");
467  $this->tpl->setCurrentBlock("adm_content");
468  $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
469  $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
470  $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
471  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
472  $this->tpl->parseCurrentBlock();
473  }
474 
479  {
480  // check if file was uploaded
481  $source = $_FILES["qtidoc"]["tmp_name"];
482  $error = 0;
483  if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
484  {
485 // $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
486  $error = 1;
487  }
488  // check correct file type
489  if (strpos("xml", $_FILES["qtidoc"]["type"]) !== FALSE)
490  {
491 // $this->ilias->raiseError("Wrong file type!",$this->ilias->error_obj->MESSAGE);
492  $error = 1;
493  }
494  if (!$error)
495  {
496  // import file into questionpool
497  // create import directory
498  $this->object->createImportDirectory();
499 
500  // copy uploaded file to import directory
501  $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
502 
503  include_once "./Services/Utilities/classes/class.ilUtil.php";
504  ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"],
505  $_FILES["qtidoc"]["name"], $full_path);
506  //move_uploaded_file($_FILES["qtidoc"]["tmp_name"], $full_path);
507  $source = $full_path;
508  $this->object->importObject($source, TRUE);
509  unlink($source);
510  }
511  $this->ctrl->redirect($this, "questions");
512  }
513 
514  function filterObject()
515  {
516  $this->questionsObject();
517  }
518 
519  function resetObject()
520  {
521  $this->questionsObject();
522  }
523 
528  function questionsObject()
529  {
530  global $rbacsystem;
531  global $ilUser;
532 
533  $lastquestiontype = $ilUser->getPref("svy_lastquestiontype");
534  $filter_text = "";
535  $filter_type = "";
536  if (count($_POST))
537  {
538  $filter_text = $_POST["filter_text"];
539  $filter_type = $_POST["sel_filter_type"];
540  }
541  else
542  {
543  $filter_text = $_GET["filter_text"];
544  $filter_type = $_GET["sel_filter_type"];
545  }
546 
547  if (strcmp($this->ctrl->getCmd(), "reset") == 0)
548  {
549  $filter_text = "";
550  $filter_type = "";
551  }
552  else
553  {
554  $this->ctrl->setParameter($this, "filter_text", $filter_text);
555  $this->ctrl->setParameter($this, "sel_filter_type", $filter_type);
556  }
557 
558  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_questions.html", "Modules/SurveyQuestionPool");
559  if ($rbacsystem->checkAccess("write", $this->ref_id))
560  {
561  $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_svy_qpl_create_new_question.html", "Modules/SurveyQuestionPool");
562  }
563  $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_qpl_action_buttons.html", "Modules/SurveyQuestionPool");
564  $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_qpl_filter_questions.html", "Modules/SurveyQuestionPool");
565 
566  // create filter form
567  $filter_fields = array(
568  "title" => $this->lng->txt("title"),
569  "description" => $this->lng->txt("description"),
570  "author" => $this->lng->txt("author"),
571  );
572  $this->tpl->setCurrentBlock("filterrow");
573  foreach ($filter_fields as $key => $value)
574  {
575  $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
576  $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
577  if (!$_POST["cmd"]["reset"])
578  {
579  if (strcmp($filter_type, $key) == 0)
580  {
581  $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
582  }
583  }
584  $this->tpl->parseCurrentBlock();
585  }
586 
587  $this->tpl->setCurrentBlock("filter_questions");
588  $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
589  $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
590  if (strcmp($this->ctrl->getCmd(), "reset") != 0)
591  {
592  $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
593  }
594  $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
595  $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
596  $this->tpl->parseCurrentBlock();
597 
598  $startrow = 0;
599  if ($_GET["prevrow"])
600  {
601  $startrow = $_GET["prevrow"];
602  }
603  if ($_GET["nextrow"])
604  {
605  $startrow = $_GET["nextrow"];
606  }
607  if ($_GET["startrow"])
608  {
609  $startrow = $_GET["startrow"];
610  }
611  if (!$_GET["sort"])
612  {
613  // default sort order
614  $_GET["sort"] = "title";
615  }
616  $sort = ($_GET["sort"]) ? $_GET["sort"] : (($_SESSION["spl_sort"]) ? $_SESSION["spl_sort"] : "title");
617  $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : (($_SESSION["spl_sortorder"]) ? $_SESSION["spl_sortorder"] : "ASC");
618  $_SESSION["spl_sort"] = $sort;
619  $_SESSION["spl_sortorder"] = $sortorder;
620  $this->ctrl->setParameter($this, "sort", $sort);
621  $this->ctrl->setParameter($this, "sortorder", $sortorder);
622  $table = $this->object->getQuestionsTable($sort, $sortorder, $filter_text, $filter_type, $startrow);
623  $colors = array("tblrow1", "tblrow2");
624  $counter = 0;
625  $last_questionblock_id = 0;
626  $editable = $rbacsystem->checkAccess('write', $this->ref_id);
627  foreach ($table["rows"] as $data)
628  {
629  $this->tpl->setCurrentBlock("checkable");
630  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
631  $this->tpl->parseCurrentBlock();
632  if ($data["complete"] == 0)
633  {
634  $this->tpl->setCurrentBlock("qpl_warning");
635  include_once "./Services/Utilities/classes/class.ilUtil.php";
636  $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
637  $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
638  $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
639  $this->tpl->parseCurrentBlock();
640  }
641  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
642  $classname = SurveyQuestion::_getQuestionType($data["question_id"]);
643  $classnamegui = $classname . "GUI";
644  $sel_question_types = $classname;
645  $this->ctrl->setParameterByClass(strtolower($classnamegui), "q_id", $data["question_id"]);
646  $this->ctrl->setParameterByClass(strtolower($classnamegui), "sel_question_types", $sel_question_types);
647  if ($editable)
648  {
649  $this->tpl->setCurrentBlock("url_edit");
650  $this->tpl->setVariable("URL_EDIT", $this->ctrl->getLinkTargetByClass(strtolower($classnamegui), "editQuestion"));
651  $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
652  $this->tpl->parseCurrentBlock();
653  }
654  $this->tpl->setCurrentBlock("QTab");
655  $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
656  $this->tpl->setVariable("URL_PREVIEW", $this->ctrl->getLinkTargetByClass(strtolower($classnamegui), "preview"));
657  $this->tpl->setVariable("TEXT_PREVIEW", $this->lng->txt("preview"));
658  $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
659  $this->tpl->setVariable("QUESTION_TYPE", SurveyQuestion::_getQuestionTypeName($data["type_tag"]));
660  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
661  include_once "./classes/class.ilFormat.php";
662  $this->tpl->setVariable('QUESTION_CREATED',ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_TIMESTAMP)));
663  $this->tpl->setVariable('QUESTION_UPDATED',ilDatePresentation::formatDate(new ilDate($data['timestamp14'],IL_CAL_TIMESTAMP)));
664  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
665  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
666  $this->tpl->parseCurrentBlock();
667  $counter++;
668  }
669 
670  if ($table["rowcount"] > count($table["rows"]))
671  {
672  $nextstep = $table["nextrow"] + $table["step"];
673  if ($nextstep > $table["rowcount"])
674  {
675  $nextstep = $table["rowcount"];
676  }
677  $counter = 1;
678  for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
679  {
680  $this->tpl->setCurrentBlock("pages");
681  if ($table["startrow"] == $i)
682  {
683  $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
684  }
685  else
686  {
687  $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&nextrow=$i" . "\">$counter</a>");
688  }
689  $this->tpl->parseCurrentBlock();
690  $counter++;
691  }
692  $this->tpl->setCurrentBlock("navigation_bottom");
693  $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
694  $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
695  $end = $table["startrow"] + $table["step"];
696  if ($end > $table["rowcount"])
697  {
698  $end = $table["rowcount"];
699  }
700  $this->tpl->setVariable("TEXT_ITEM_END", $end);
701  $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
702  $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
703  $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
704  $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
705  $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "&prevrow=" . $table["prevrow"]);
706  $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "&nextrow=" . $table["nextrow"]);
707  $this->tpl->parseCurrentBlock();
708  }
709 
710  // if there are no questions, display a message
711  if ($counter == 0)
712  {
713  $this->tpl->setCurrentBlock("Emptytable");
714  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
715  $this->tpl->parseCurrentBlock();
716  }
717  if ($counter > 0)
718  {
719  $this->tpl->setCurrentBlock("selectall");
720  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
721  $counter++;
722  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
723  $this->tpl->parseCurrentBlock();
724  }
725 
726  include_once "./Services/Utilities/classes/class.ilUtil.php";
727  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
728  $this->tpl->setCurrentBlock("copy");
729  $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
730  $this->tpl->parseCurrentBlock();
731  $this->tpl->setCurrentBlock("exportquestions");
732  $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
733  $this->tpl->parseCurrentBlock();
734 
735  // create edit buttons & table footer
736  if ($rbacsystem->checkAccess("write", $this->ref_id))
737  {
738  $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
739  $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
740  if ((!array_key_exists("spl_copied_questions", $_SESSION)) || (count($_SESSION["spl_copied_questions"]) == 0))
741  {
742  $this->tpl->setVariable("PASTE_DISABLED", " disabled=\"disabled\"");
743  }
744  }
745 
746  if ($rbacsystem->checkAccess("write", $this->ref_id))
747  {
748  // "create question" form
749  $questiontypes =& $this->object->_getQuestiontypes();
750  $this->tpl->setCurrentBlock("QTypes");
751  foreach ($questiontypes as $questiontypeTranslation => $questiontype)
752  {
753  if (strcmp($lastquestiontype, $questiontype["type_tag"]) == 0)
754  {
755  $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
756  }
757  $this->tpl->setVariable("QUESTION_TYPE_ID", $questiontype["type_tag"]);
758  $this->tpl->setVariable("QUESTION_TYPE", $questiontypeTranslation);
759  $this->tpl->parseCurrentBlock();
760  }
761  $this->tpl->setCurrentBlock("CreateQuestion");
762  $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
763  $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
764  $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
765  $this->tpl->parseCurrentBlock();
766  }
767  // define the sort column parameters
768  $sortarray = array(
769  "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
770  "description" => (strcmp($sort, "description") == 0) ? $sortorder : "",
771  "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
772  "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
773  "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
774  "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : ""
775  );
776  foreach ($sortarray as $key => $value)
777  {
778  if (strcmp($value, "ASC") == 0)
779  {
780  $sortarray[$key] = "DESC";
781  }
782  else
783  {
784  $sortarray[$key] = "ASC";
785  }
786  }
787 
788  $this->tpl->setCurrentBlock("adm_content");
789  // create table header
790  $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
791  $this->ctrl->setParameter($this, "sort", "title");
792  $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
793  $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
794  $this->ctrl->setParameter($this, "sort", "description");
795  $this->ctrl->setParameter($this, "sortorder", $sortarray["description"]);
796  $this->tpl->setVariable("QUESTION_DESCRIPTION", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
797  $this->ctrl->setParameter($this, "sort", "type");
798  $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
799  $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
800  $this->ctrl->setParameter($this, "sort", "author");
801  $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
802  $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
803  $this->ctrl->setParameter($this, "sort", "created");
804  $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
805  $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
806  $this->ctrl->setParameter($this, "sort", "updated");
807  $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
808  $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
809  $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
810  $this->ctrl->setParameter($this, "sort", $sort);
811  $this->ctrl->setParameter($this, "sortorder", $sortorder);
812  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
813  $this->tpl->parseCurrentBlock();
814  unset($_SESSION["calling_survey"]);
815  }
816 
817 
818  function updateObject()
819  {
820  $this->update = $this->object->update();
821  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
822  }
823 
824  /*
825  * list all export files
826  */
827  function exportObject()
828  {
829  global $tree;
830 
831  //$this->setTabs();
832 
833  //add template for view button
834  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
835 
836  // create export file button
837  $this->tpl->setCurrentBlock("btn_cell");
838  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
839  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
840  $this->tpl->parseCurrentBlock();
841 
842  $export_dir = $this->object->getExportDirectory();
843  $export_files = $this->object->getExportFiles($export_dir);
844 
845  // create table
846  include_once("./Services/Table/classes/class.ilTableGUI.php");
847  $tbl = new ilTableGUI();
848 
849  // load files templates
850  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
851 
852  // load template for table content data
853  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", "Modules/SurveyQuestionPool");
854 
855  $num = 0;
856 
857  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
858 
859  $tbl->setTitle($this->lng->txt("svy_export_files"));
860 
861  $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
862  $this->lng->txt("svy_size"), $this->lng->txt("date") ));
863 
864  $tbl->enabled["sort"] = false;
865  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
866 
867  // control
868  $tbl->setOrderColumn($_GET["sort_by"]);
869  $tbl->setOrderDirection($_GET["sort_order"]);
870  $tbl->setLimit($_GET["limit"]);
871  $tbl->setOffset($_GET["offset"]);
872  $tbl->setMaxCount($this->maxcount); // ???
873  $header_params = $this->ctrl->getParameterArray($this, "export");
874  $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
875 
876  // delete button
877  include_once "./Services/Utilities/classes/class.ilUtil.php";
878 
879  // footer
880  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
881  //$tbl->disable("footer");
882 
883  $tbl->setMaxCount(count($export_files));
884  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
885 
886  $tbl->render();
887  if(count($export_files) > 0)
888  {
889  $this->tpl->setVariable("COLUMN_COUNTS", 4);
890 
891  $i=0;
892  foreach($export_files as $exp_file)
893  {
894  $this->tpl->setCurrentBlock("tbl_content");
895  $this->tpl->setVariable("TXT_FILENAME", $exp_file);
896 
897  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
898  $this->tpl->setVariable("CSS_ROW", $css_row);
899 
900  $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
901  $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
902 
903  $file_arr = explode("__", $exp_file);
904  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
905 
906  $this->tpl->parseCurrentBlock();
907  }
908  $this->tpl->setCurrentBlock("selectall");
909  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
910  $this->tpl->setVariable("CSS_ROW", $css_row);
911  $this->tpl->parseCurrentBlock();
912  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
913  $this->tpl->setCurrentBlock("tbl_action_btn");
914  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
915  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
916  $this->tpl->parseCurrentBlock();
917 
918  $this->tpl->setCurrentBlock("tbl_action_btn");
919  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
920  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
921  $this->tpl->parseCurrentBlock();
922  } //if is_array
923  else
924  {
925  $this->tpl->setCurrentBlock("notfound");
926  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
927  $this->tpl->setVariable("NUM_COLS", 3);
928  $this->tpl->parseCurrentBlock();
929  }
930 
931  $this->tpl->parseCurrentBlock();
932  }
933 
937  function createExportFileObject($questions = null)
938  {
939  global $rbacsystem;
940 
941  if ($rbacsystem->checkAccess("write", $this->ref_id))
942  {
943  include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
944  $survey_exp = new ilSurveyQuestionpoolExport($this->object);
945  $survey_exp->buildExportFile($questions);
946  $this->ctrl->redirect($this, "export");
947  }
948  else
949  {
950  ilUtil::sendInfo("cannot_export_questionpool");
951  }
952  }
953 
958  {
959  if(!isset($_POST["file"]))
960  {
961  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
962  $this->ctrl->redirect($this, "export");
963  }
964 
965  if (count($_POST["file"]) > 1)
966  {
967  ilUtil::sendInfo($this->lng->txt("select_max_one_item"),true);
968  $this->ctrl->redirect($this, "export");
969  }
970 
971 
972  $export_dir = $this->object->getExportDirectory();
973  include_once "./Services/Utilities/classes/class.ilUtil.php";
974  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
975  $_POST["file"][0]);
976  }
977 
982  {
983  if(!isset($_POST["file"]))
984  {
985  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
986  $this->ctrl->redirect($this, "export");
987  }
988 
989  //$this->setTabs();
990 
991  // SAVE POST VALUES
992  $_SESSION["ilExportFiles"] = $_POST["file"];
993 
994  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/SurveyQuestionPool");
995 
996  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
997 
998  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
999 
1000  // BEGIN TABLE HEADER
1001  $this->tpl->setCurrentBlock("table_header");
1002  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
1003  $this->tpl->parseCurrentBlock();
1004 
1005  // BEGIN TABLE DATA
1006  $counter = 0;
1007  include_once "./Services/Utilities/classes/class.ilUtil.php";
1008  foreach($_POST["file"] as $file)
1009  {
1010  $this->tpl->setCurrentBlock("table_row");
1011  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_file.gif"));
1012  $this->tpl->setVariable("TEXT_IMG_OBJ", $this->lng->txt("file_icon"));
1013  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1014  $this->tpl->setVariable("TEXT_CONTENT", $file);
1015  $this->tpl->parseCurrentBlock();
1016  }
1017 
1018  // cancel/confirm button
1019  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1020  $buttons = array(
1021  "deleteExportFile" => $this->lng->txt("confirm"),
1022  "cancelDeleteExportFile" => $this->lng->txt("cancel")
1023  );
1024  foreach ($buttons as $name => $value)
1025  {
1026  $this->tpl->setCurrentBlock("operation_btn");
1027  $this->tpl->setVariable("BTN_NAME",$name);
1028  $this->tpl->setVariable("BTN_VALUE",$value);
1029  $this->tpl->parseCurrentBlock();
1030  }
1031  }
1032 
1033 
1038  {
1039  session_unregister("ilExportFiles");
1040  $this->ctrl->redirect($this, "export");
1041  }
1042 
1043 
1048  {
1049  $export_dir = $this->object->getExportDirectory();
1050  foreach($_SESSION["ilExportFiles"] as $file)
1051  {
1052  $exp_file = $export_dir."/".$file;
1053  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
1054  if (@is_file($exp_file))
1055  {
1056  unlink($exp_file);
1057  }
1058  if (@is_dir($exp_dir))
1059  {
1060  include_once "./Services/Utilities/classes/class.ilUtil.php";
1061  ilUtil::delDir($exp_dir);
1062  }
1063  }
1064  $this->ctrl->redirect($this, "export");
1065  }
1066 
1072  function importObject()
1073  {
1074  global $rbacsystem;
1075  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
1076  {
1077  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1078  }
1079  $this->getTemplateFile("import", "spl");
1080  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1081  $this->tpl->setVariable("BTN_NAME", "uploadSpl");
1082  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
1083  $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
1084  $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
1085  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
1086  }
1087 
1091  function uploadSplObject($redirect = true)
1092  {
1093  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
1094  {
1095  ilUtil::sendInfo($this->lng->txt("spl_select_file_for_import"));
1096  $this->importObject();
1097  return;
1098  }
1099  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1100  // create new questionpool object
1101  $newObj = new ilObjSurveyQuestionPool();
1102  // set type of questionpool object
1103  $newObj->setType($_GET["new_type"]);
1104  // set title of questionpool object to "dummy"
1105  $newObj->setTitle("dummy");
1106  // set description of questionpool object to "dummy"
1107  //$newObj->setDescription("dummy");
1108  // create the questionpool class in the ILIAS database (object_data table)
1109  $newObj->create(true);
1110  // create a reference for the questionpool object in the ILIAS database (object_reference table)
1111  $newObj->createReference();
1112  // put the questionpool object in the administration tree
1113  $newObj->putInTree($_GET["ref_id"]);
1114  // get default permissions and set the permissions for the questionpool object
1115  $newObj->setPermissions($_GET["ref_id"]);
1116  // notify the questionpool object and all its parent objects that a "new" object was created
1117  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1118 
1119  // create import directory
1120  $newObj->createImportDirectory();
1121 
1122  // copy uploaded file to import directory
1123  $file = pathinfo($_FILES["xmldoc"]["name"]);
1124  $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
1125  include_once "./Services/Utilities/classes/class.ilUtil.php";
1126  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
1127  $_FILES["xmldoc"]["name"], $full_path);
1128  //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
1129 
1130  // import qti data
1131  $qtiresult = $newObj->importObject($full_path);
1132 
1133  if ($redirect)
1134  {
1135  $this->ctrl->redirect($this, "cancel");
1136 // ilUtil::redirect("adm_object.php?".$this->link_params);
1137  }
1138  return $newObj->getRefId();
1139  }
1140 
1144  function createObject()
1145  {
1146  global $rbacsystem;
1147  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
1148  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
1149  {
1150  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1151  }
1152  else
1153  {
1154  $this->getTemplateFile("create", $new_type);
1155 
1156  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
1157  $this->fillCloneTemplate('DUPLICATE','spl');
1158  $this->tpl->setCurrentBlock("adm_content");
1159 
1160  // fill in saved values in case of error
1161  $data = array();
1162  $data["fields"] = array();
1163  include_once "./Services/Utilities/classes/class.ilUtil.php";
1164  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
1165  $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
1166 
1167  foreach ($data["fields"] as $key => $val)
1168  {
1169  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
1170  $this->tpl->setVariable(strtoupper($key), $val);
1171 
1172  if ($this->prepare_output)
1173  {
1174  $this->tpl->parseCurrentBlock();
1175  }
1176  }
1177 
1178  $this->ctrl->setParameter($this, "new_type", $this->type);
1179  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1180  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
1181  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
1182  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
1183  $this->tpl->setVariable("CMD_SUBMIT", "save");
1184  $this->tpl->setVariable("TARGET", ' target="'.
1185  ilFrameTargetInfo::_getFrame("MainContent").'" ');
1186  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
1187 
1188  $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
1189  $this->tpl->setVariable("TXT_SPL_FILE", $this->lng->txt("spl_upload_file"));
1190  $this->tpl->setVariable("NEW_TYPE", $this->type);
1191  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
1192 
1193  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_spl.gif'));
1194  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_spl"));
1195  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_spl.gif'));
1196  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_spl"));
1197 
1198  $this->tpl->parseCurrentBlock();
1199  }
1200  }
1201 
1205  function importFileObject()
1206  {
1207  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
1208  {
1209  ilUtil::sendInfo($this->lng->txt("spl_select_file_for_import"));
1210  $this->createObject();
1211  return;
1212  }
1213  $this->ctrl->setParameter($this, "new_type", $this->type);
1214  $ref_id = $this->uploadSplObject(false);
1215  // always send a message
1216  ilUtil::sendInfo($this->lng->txt("object_imported"),true);
1217 
1218  ilUtil::redirect("ilias.php?ref_id=".$ref_id.
1219  "&baseClass=ilObjSurveyQuestionPoolGUI");
1220  }
1221 
1226  {
1227  global $ilUser;
1228  $ilUser->writePref("svy_lastquestiontype", $_POST["sel_question_types"]);
1229  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
1230  $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
1231  $q_gui->object->setObjId($this->object->getId());
1232  $this->ctrl->setParameter($this, "sel_question_types", $_POST["sel_question_types"]);
1233  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1234  }
1235 
1240  {
1241  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
1242  $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
1243  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
1244  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["q_id"]);
1245  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1246  }
1247 
1252  {
1253  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
1254  $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
1255  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
1256  $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
1257  }
1258 
1262  function &previewObject()
1263  {
1264  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
1265  $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
1266  $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
1267  $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
1268  $this->ctrl->redirectByClass(get_class($q_gui), "preview");
1269  }
1270 
1271  function addLocatorItems()
1272  {
1273  global $ilLocator;
1274  switch ($this->ctrl->getCmd())
1275  {
1276  case "create":
1277  case "importFile":
1278  case "cancel":
1279  break;
1280  default:
1281  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1282  break;
1283  }
1284  if ($_GET["q_id"] > 0)
1285  {
1286  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1287  $q_type = SurveyQuestion::_getQuestionType($_GET["q_id"]) . "GUI";
1288  $this->ctrl->setParameterByClass($q_type, "q_id", $_GET["q_id"]);
1289  $ilLocator->addItem(SurveyQuestion::_getTitle($_GET["q_id"]), $this->ctrl->getLinkTargetByClass($q_type, "editQuestion"));
1290  }
1291  }
1292 
1298  function getTabs(&$tabs_gui)
1299  {
1300  $next_class = $this->ctrl->getNextClass($this);
1301  switch ($next_class)
1302  {
1303  case "":
1304  case "ilpermissiongui":
1305  case "ilmdeditorgui":
1306  case "ilsurveyphrasesgui":
1307  break;
1308  default:
1309  return;
1310  break;
1311  }
1312  if (($_GET["calling_survey"] > 0) || ($_GET["new_for_survey"] > 0)) return;
1313  // properties
1314  $tabs_gui->addTarget("properties",
1315  $this->ctrl->getLinkTarget($this,'properties'),
1316  "properties",
1317  "", "");
1318  // questions
1319  $force_active = ($this->ctrl->getCmdClass() == "" ||
1320  $this->ctrl->getCmd() == "")
1321  ? true
1322  : false;
1323  if (!$force_active)
1324  {
1325  if (is_array($_GET["sort"]))
1326  {
1327  $force_active = true;
1328  }
1329  }
1330  $tabs_gui->addTarget("survey_questions",
1331  $this->ctrl->getLinkTarget($this,'questions'),
1332  array("questions", "filter", "reset", "createQuestion",
1333  "importQuestions", "deleteQuestions", "copy", "paste",
1334  "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
1335  "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
1336  "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
1337  "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
1338  "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
1339  "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
1340  "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
1341  "cancelDeleteCategory", "categories", "saveCategories",
1342  "savePhrase", "addPhrase"
1343  ),
1344  array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"), "", $force_active);
1345 
1346  global $rbacsystem;
1347  global $ilAccess;
1348  if ($rbacsystem->checkAccess('write', $this->ref_id))
1349  {
1350  // meta data
1351  $tabs_gui->addTarget("meta_data",
1352  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1353  "", "ilmdeditorgui");
1354 
1355  // manage phrases
1356  $tabs_gui->addTarget("manage_phrases",
1357  $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
1358  array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase"),
1359  "ilsurveyphrasesgui", "");
1360  }
1361 
1362  // export
1363  $tabs_gui->addTarget("export",
1364  $this->ctrl->getLinkTarget($this,'export'),
1365  array("export", "createExportFile", "confirmDeleteExportFile",
1366  "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
1367  "", "");
1368 
1369  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
1370  {
1371  $tabs_gui->addTarget("perm_settings",
1372  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1373  }
1374  }
1375 
1384  function _goto($a_target)
1385  {
1386  global $ilAccess, $ilErr, $lng;
1387  if ($ilAccess->checkAccess("write", "", $a_target))
1388  {
1389  $_GET["baseClass"] = "ilObjSurveyQuestionPoolGUI";
1390  $_GET["cmd"] = "questions";
1391  $_GET["ref_id"] = $a_target;
1392  include_once("ilias.php");
1393  exit;
1394  }
1395  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1396  {
1397  $_GET["cmd"] = "frameset";
1398  $_GET["target"] = "";
1399  $_GET["ref_id"] = ROOT_FOLDER_ID;
1400  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1401  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1402  include("repository.php");
1403  exit;
1404  }
1405  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1406  }
1407 
1408 
1409 } // END class.ilObjSurveyQuestionPoolGUI
1410 ?>