ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSurveyGUI.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 
40 include_once "./classes/class.ilObjectGUI.php";
41 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
42 
44 {
49  function ilObjSurveyGUI()
50  {
51  global $lng, $ilCtrl;
52 
53  $this->type = "svy";
54  $lng->loadLanguageModule("survey");
55  $this->ctrl =& $ilCtrl;
56  $this->ctrl->saveParameter($this, "ref_id");
57 
58  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
59  }
60 
62  {
63  include_once "./Services/Utilities/classes/class.ilUtil.php";
64  $path = $this->tree->getPathFull($this->object->getRefID());
65  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
66  }
67 
71  function &executeCommand()
72  {
73  global $ilAccess, $ilNavigationHistory;
74 
75  // add entry to navigation history
76  if (!$this->getCreationMode() &&
77  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
78  {
79  $ilNavigationHistory->addItem($_GET["ref_id"],
80  "ilias.php?baseClass=ilObjSurveyGUI&cmd=infoScreen&ref_id=".$_GET["ref_id"], "svy");
81  }
82 
83  $cmd = $this->ctrl->getCmd("properties");
84  $next_class = $this->ctrl->getNextClass($this);
85  $this->ctrl->setReturn($this, "properties");
86  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "Modules/Survey"), "screen");
87  $this->prepareOutput();
88 
89  //echo "<br>nextclass:$next_class:cmd:$cmd:qtype=$q_type";
90  switch($next_class)
91  {
92  case "ilinfoscreengui":
93  $this->infoScreen(); // forwards command
94  break;
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 "ilsurveyevaluationgui":
104  include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
105  $eval_gui = new ilSurveyEvaluationGUI($this->object);
106  $ret =& $this->ctrl->forwardCommand($eval_gui);
107  break;
108 
109  case "ilsurveyexecutiongui":
110  include_once("./Modules/Survey/classes/class.ilSurveyExecutionGUI.php");
111  $exec_gui = new ilSurveyExecutionGUI($this->object);
112  $ret =& $this->ctrl->forwardCommand($exec_gui);
113  break;
114 
115  case 'ilpermissiongui':
116  include_once("./classes/class.ilPermissionGUI.php");
117  $perm_gui =& new ilPermissionGUI($this);
118  $ret =& $this->ctrl->forwardCommand($perm_gui);
119  break;
120 
121  default:
122  $cmd.= "Object";
123  $ret =& $this->$cmd();
124  break;
125  }
126  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
127  $this->getCreationMode() != true)
128  {
129  $this->tpl->show();
130  }
131  }
132 
137  function saveObject()
138  {
139  global $rbacadmin;
140 
141  // create and insert forum in objecttree
142  $newObj = parent::saveObject();
143  // always send a message
144  ilUtil::sendInfo($this->lng->txt("object_added"),true);
145  ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=".$newObj->getRefId()."&cmd=properties");
146  }
147 
153  function cancelObject($in_rep = false)
154  {
155  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
156  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
157  }
158 
167  {
168  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
169  $this->ctrl->redirect($this, "properties");
170  }
171 
180  {
181  include_once "./Services/Utilities/classes/class.ilUtil.php";
182  $status = STATUS_OFFLINE;
183  if ($_POST["status"] == 1)
184  {
185  $status = STATUS_ONLINE;
186  }
187  $result = $this->object->setStatus($status);
188  if ($result)
189  {
190  ilUtil::sendInfo($result, true);
191  }
192  $this->object->setEvaluationAccess($_POST["evaluation_access"]);
193  $this->object->setStartDate(sprintf("%04d-%02d-%02d", $_POST["start_date"]["y"], $_POST["start_date"]["m"], $_POST["start_date"]["d"]));
194  $this->object->setStartDateEnabled($_POST["checked_start_date"]);
195  $this->object->setEndDate(sprintf("%04d-%02d-%02d", $_POST["end_date"]["y"], $_POST["end_date"]["m"], $_POST["end_date"]["d"]));
196  $this->object->setEndDateEnabled($_POST["checked_end_date"]);
197 
198  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
199  $introduction = ilUtil::stripSlashes($_POST["introduction"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
200  $this->object->setIntroduction($introduction);
201  $outro = ilUtil::stripSlashes($_POST["outro"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
202  $this->object->setOutro($outro);
203 
204  $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
205  if (!$hasDatasets)
206  {
207  $anonymize = $_POST["anonymize"];
208  if ($anonymize)
209  {
210  $codes = $_POST["codes"];
211  $anonymize += $codes;
212  }
213  $this->object->setAnonymize($anonymize);
214  }
215  if ($_POST["showQuestionTitles"])
216  {
217  $this->object->showQuestionTitles();
218  }
219  else
220  {
221  $this->object->hideQuestionTitles();
222  }
223  $this->update = $this->object->update();
224  $this->object->saveToDb();
225  if (strcmp($_SESSION["info"], "") != 0)
226  {
227  ilUtil::sendInfo($_SESSION["info"] . "<br />" . $this->lng->txt("settings_saved"), true);
228  }
229  else
230  {
231  ilUtil::sendInfo($this->lng->txt("settings_saved"), true);
232  }
233  $this->ctrl->redirect($this, "properties");
234  }
235 
243  function handleWriteAccess()
244  {
245  global $ilAccess;
246  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
247  {
248  // allow only write access
249  ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), TRUE);
250  $this->ctrl->redirect($this, "infoScreen");
251  }
252  }
253 
261  function propertiesObject()
262  {
263  $this->handleWriteAccess();
264  // to set the command class for the default command after object creation to make the RTE editor switch work
265  if (strlen($this->ctrl->getCmdClass()) == 0) $this->ctrl->setCmdClass("ilobjsurveygui");
266  include_once "./Services/Utilities/classes/class.ilUtil.php";
267  $this->lng->loadLanguageModule("jscalendar");
268  $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
269  $this->tpl->setCurrentBlock("calendar_javascript");
270  $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
271  $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
272  $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
273  $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
274  $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
275  $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
276  $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
277  $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
278  $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
279  $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
280  $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
281  $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
282  $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
283  $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
284  $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
285  $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
286  $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
287  $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
288  $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
289  $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
290  $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
291  $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
292  $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
293  $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
294  $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
295  $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
296  $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
297  $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
298  $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
299  $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
300  $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
301  $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
302  $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
303  $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
304  $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
305  $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
306  $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
307  $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
308  $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
309  $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
310  $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
311  $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
312  $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
313  $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
314  $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
315  $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
316  $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
317  $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
318  $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
319  $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
320  $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
321  $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
322  $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
323  $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
324  $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
325  $this->tpl->setVariable("WK", $this->lng->txt("wk"));
326  $this->tpl->setVariable("TIME", $this->lng->txt("time"));
327  $this->tpl->parseCurrentBlock();
328  $this->tpl->setCurrentBlock("CalendarJS");
329  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./Modules/Survey/js/calendar/calendar.js");
330  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./Modules/Survey/js/calendar/calendar-setup.js");
331  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./Modules/Survey/js/calendar/calendar.css");
332  $this->tpl->parseCurrentBlock();
333 
334  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_properties.html", "Modules/Survey");
335  $this->tpl->setCurrentBlock("adm_content");
336  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "properties"));
337  $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("introduction"));
338  $this->tpl->setVariable("VALUE_INTRODUCTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getIntroduction())));
339  $this->tpl->setVariable("TEXT_OUTRO", $this->lng->txt("outro"));
340  $this->tpl->setVariable("VALUE_OUTRO", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getOutro())));
341  $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("online"));
342  $this->tpl->setVariable("TEXT_START_DATE", $this->lng->txt("start_date"));
343  $this->tpl->setVariable("VALUE_START_DATE", ilUtil::makeDateSelect("start_date", $this->object->getStartYear(), $this->object->getStartMonth(), $this->object->getStartDay()));
344  $this->tpl->setVariable("IMG_START_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
345  $this->tpl->setVariable("TXT_START_DATE_CALENDAR", $this->lng->txt("open_calendar"));
346  $this->tpl->setVariable("TEXT_END_DATE", $this->lng->txt("end_date"));
347  $this->tpl->setVariable("VALUE_END_DATE", ilUtil::makeDateSelect("end_date", $this->object->getEndYear(), $this->object->getEndMonth(), $this->object->getEndDay()));
348  $this->tpl->setVariable("IMG_END_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
349  $this->tpl->setVariable("TXT_END_DATE_CALENDAR", $this->lng->txt("open_calendar"));
350  $this->tpl->setVariable("TEXT_EVALUATION_ACCESS", $this->lng->txt("evaluation_access"));
351  $this->tpl->setVariable("DESCRIPTION_EVALUATION_ACCESS", $this->lng->txt("evaluation_access_description"));
352  $this->tpl->setVariable("TEXT_ENABLED", $this->lng->txt("enabled"));
353  $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("evaluation_access_off"));
354  $this->tpl->setVariable("VALUE_ALL", $this->lng->txt("evaluation_access_all"));
355  $this->tpl->setVariable("VALUE_PARTICIPANTS", $this->lng->txt("evaluation_access_participants"));
356 
357  $this->tpl->setVariable("TEXT_ANONYMIZATION", $this->lng->txt("anonymization"));
358 
359  $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
360  if ($hasDatasets)
361  {
362  $this->tpl->setVariable("DISABLED_ANONYMIZATION", " disabled=\"disabled\"");
363  }
364 
365  $this->tpl->setVariable("DESCRIPTION_ANONYMIZATION", $this->lng->txt("anonymize_survey_description"));
366  $this->tpl->setVariable("ANON_VALUE_OFF", $this->lng->txt("off"));
367  $this->tpl->setVariable("ANON_VALUE_ON", $this->lng->txt("on_additional"));
368  $this->tpl->setVariable("VALUE_NOCODES", $this->lng->txt("anonymize_without_code"));
369  $this->tpl->setVariable("VALUE_CODES", $this->lng->txt("anonymize_with_code"));
370  switch ($this->object->getAnonymize())
371  {
372  case ANONYMIZE_OFF:
373  $this->tpl->setVariable("ANON_CHECKED_OFF", " checked=\"checked\"");
374  $this->tpl->setVariable("CHECKED_CODES", " checked=\"checked\"");
375  break;
376  case ANONYMIZE_ON:
377  $this->tpl->setVariable("ANON_CHECKED_ON", " checked=\"checked\"");
378  $this->tpl->setVariable("CHECKED_CODES", " checked=\"checked\"");
379  break;
381  $this->tpl->setVariable("ANON_CHECKED_ON", " checked=\"checked\"");
382  $this->tpl->setVariable("CHECKED_NOCODES", " checked=\"checked\"");
383  break;
384  }
385 
386  if ($this->object->getEndDateEnabled())
387  {
388  $this->tpl->setVariable("CHECKED_END_DATE", " checked=\"checked\"");
389  }
390  if ($this->object->getStartDateEnabled())
391  {
392  $this->tpl->setVariable("CHECKED_START_DATE", " checked=\"checked\"");
393  }
394  switch ($this->object->getEvaluationAccess())
395  {
397  $this->tpl->setVariable("CHECKED_OFF", " checked=\"checked\"");
398  break;
400  $this->tpl->setVariable("CHECKED_ALL", " checked=\"checked\"");
401  break;
403  $this->tpl->setVariable("CHECKED_PARTICIPANTS", " checked=\"checked\"");
404  break;
405  }
406  if ($this->object->getStatus() == STATUS_ONLINE)
407  {
408  $this->tpl->setVariable("CHECKED_STATUS", " checked=\"checked\"");
409  }
410  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
411  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
412  $this->tpl->setVariable("TEXT_SHOW_QUESTIONTITLES", $this->lng->txt("svy_show_questiontitles"));
413  if ($this->object->getShowQuestionTitles())
414  {
415  $this->tpl->setVariable("QUESTIONTITLES_CHECKED", " checked=\"checked\"");
416  }
417  $this->tpl->parseCurrentBlock();
418 
419  include_once "./Services/RTE/classes/class.ilRTE.php";
420  $rtestring = ilRTE::_getRTEClassname();
421  include_once "./Services/RTE/classes/class.$rtestring.php";
422  $rte = new $rtestring();
423  include_once "./classes/class.ilObject.php";
425  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
426  $rte->addRTESupport($obj_id, $obj_type, "survey");
427  }
428 
437  {
438  $this->browseForQuestionsObject($_POST["sel_questionpool"]);
439  }
440 
449  {
450  $this->browseForQuestionsObject("", true);
451  }
452 
461  {
462  $this->ctrl->setParameter($this, "browsetype", $_POST["datatype"]);
463  $this->ctrl->redirect($this, "browseForQuestions");
464  }
465 
474  {
475  // insert selected questions into test
476  $inserted_objects = 0;
477  foreach ($_POST as $key => $value)
478  {
479  if (preg_match("/cb_(\d+)/", $key, $matches))
480  {
481  if ($_GET["browsetype"] == 1)
482  {
483  $this->object->insertQuestion($matches[1]);
484  }
485  else
486  {
487  $this->object->insertQuestionBlock($matches[1]);
488  }
489  $inserted_objects++;
490  }
491  }
492  if ($inserted_objects)
493  {
494  $this->object->saveCompletionStatus();
495  ilUtil::sendInfo($this->lng->txt("questions_inserted"), true);
496  $this->ctrl->redirect($this, "questions");
497  }
498  else
499  {
500  if ($_GET["browsetype"] == 1)
501  {
502  ilUtil::sendInfo($this->lng->txt("insert_missing_question"));
503  }
504  else
505  {
506  ilUtil::sendInfo($this->lng->txt("insert_missing_questionblock"));
507  }
508  $this->browseForQuestionsObject("", false, $_GET["browsetype"]);
509  }
510  }
511 
520  {
521  $checked_questions = array();
522  $checked_questionblocks = array();
523  foreach ($_POST as $key => $value)
524  {
525  if (preg_match("/cb_(\d+)/", $key, $matches))
526  {
527  array_push($checked_questions, $matches[1]);
528  }
529  if (preg_match("/cb_qb_(\d+)/", $key, $matches))
530  {
531  array_push($checked_questionblocks, $matches[1]);
532  }
533  }
534  if (count($checked_questions) + count($checked_questionblocks) > 0)
535  {
536  ilUtil::sendInfo($this->lng->txt("remove_questions"));
537  $this->removeQuestionsForm($checked_questions, $checked_questionblocks);
538  return;
539  }
540  else
541  {
542  ilUtil::sendInfo($this->lng->txt("no_question_selected_for_removal"), true);
543  $this->ctrl->redirect($this, "questions");
544  }
545  }
546 
554  function browseForQuestionsObject($filter_questionpool = "", $reset_filter = false, $browsequestions = 1)
555  {
556  global $rbacsystem;
557 
559  if (strcmp($this->ctrl->getCmd(), "filterQuestions") != 0)
560  {
561  if (array_key_exists("sel_questionpool", $_GET)) $filter_questionpool = $_GET["sel_questionpool"];
562  }
563  $browsequestions = (array_key_exists("browsetype", $_GET)) ? $_GET["browsetype"] : 1;
564  $this->ctrl->setParameter($this, "browsetype", $browsequestions);
565  if ($_POST["cmd"]["back"])
566  {
567  $show_questionbrowser = false;
568  }
569 
570  $add_parameter = "&insert_question=1";
571 
572  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questionbrowser.html", "Modules/Survey");
573  $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_svy_action_buttons.html", "Modules/Survey");
574  $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_svy_filter_questions.html", "Modules/Survey");
575 
576  $questionpools =& $this->object->getQuestionpoolTitles();
577  if (count($questionpools) == 0)
578  {
579  ilUtil::sendInfo($this->lng->txt("no_questions_available"));
580  return;
581  }
582  $filter_type = $_GET["sel_filter_type"];
583  if (!$filter_type)
584  {
585  $filter_type = $_POST["sel_filter_type"];
586  }
587  if ($reset_filter)
588  {
589  $filter_type = "";
590  }
591  $add_parameter .= "&sel_filter_type=$filter_type";
592 
593  $filter_text = $_GET["filter_text"];
594  if (!$filter_text)
595  {
596  $filter_text = $_POST["filter_text"];
597  }
598  if ($reset_filter)
599  {
600  $filter_text = "";
601  }
602  $add_parameter .= "&filter_text=$filter_text";
603 
604  $filter_fields = array(
605  "title" => $this->lng->txt("title"),
606  "comment" => $this->lng->txt("description"),
607  "author" => $this->lng->txt("author"),
608  );
609  $this->tpl->setCurrentBlock("filterrow");
610  foreach ($filter_fields as $key => $value)
611  {
612  $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
613  $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
614  if (!$reset_filter)
615  {
616  if (strcmp($filter_type, $key) == 0)
617  {
618  $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
619  }
620  }
621  $this->tpl->parseCurrentBlock();
622  }
623 
624  $filter_question_type = $_POST["sel_question_type"];
625  if (!$filter_question_type)
626  {
627  $filter_question_type = $_GET["sel_question_type"];
628  }
629  if ($reset_filter)
630  {
631  $filter_question_type = "";
632  }
633  $add_parameter .= "&sel_question_type=$filter_question_type";
634 
635  if ($browsequestions)
636  {
637  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
638  $questiontypes =& ilObjSurveyQuestionPool::_getQuestiontypes();
639  foreach ($questiontypes as $questiontypeTranslation => $questiontype)
640  {
641  $this->tpl->setCurrentBlock("questiontype_row");
642  $this->tpl->setVariable("VALUE_QUESTION_TYPE", $questiontype["type_tag"]);
643  $this->tpl->setVariable("TEXT_QUESTION_TYPE", $questiontypeTranslation);
644  if (strcmp($filter_question_type, $questiontype["type_tag"]) == 0)
645  {
646  $this->tpl->setVariable("SELECTED_QUESTION_TYPE", " selected=\"selected\"");
647  }
648  $this->tpl->parseCurrentBlock();
649  }
650  }
651 
652  if ($reset_filter)
653  {
654  $filter_questionpool = "";
655  }
656  $add_parameter .= "&sel_questionpool=$filter_questionpool";
657 
658  if ($browsequestions)
659  {
660  foreach ($questionpools as $key => $value)
661  {
662  $this->tpl->setCurrentBlock("questionpool_row");
663  $this->tpl->setVariable("VALUE_QUESTIONPOOL", $key);
664  $this->tpl->setVariable("TEXT_QUESTIONPOOL", $value);
665  if (strcmp($filter_questionpool, $key) == 0)
666  {
667  $this->tpl->setVariable("SELECTED_QUESTIONPOOL", " selected=\"selected\"");
668  }
669  $this->tpl->parseCurrentBlock();
670  }
671  }
672 
673  if ($browsequestions)
674  {
675  $this->tpl->setCurrentBlock("question_filters");
676  $this->tpl->setVariable("SHOW_QUESTION_TYPES", $this->lng->txt("filter_show_question_types"));
677  $this->tpl->setVariable("TEXT_ALL_QUESTION_TYPES", $this->lng->txt("filter_all_question_types"));
678  $this->tpl->setVariable("SHOW_QUESTIONPOOLS", $this->lng->txt("filter_show_questionpools"));
679  $this->tpl->setVariable("TEXT_ALL_QUESTIONPOOLS", $this->lng->txt("filter_all_questionpools"));
680  $this->tpl->parseCurrentBlock();
681  }
682 
683  $this->tpl->setCurrentBlock("filter_questions");
684  $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
685  $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
686  if (!$_POST["cmd"]["reset"])
687  {
688  $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
689  }
690  $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
691  $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
692  $this->tpl->setVariable("OPTION_QUESTIONS", $this->lng->txt("questions"));
693  $this->tpl->setVariable("OPTION_QUESTIONBLOCKS", $this->lng->txt("questionblocks"));
694  if ($browsequestions)
695  {
696  $this->tpl->setVariable("SELECTED_QUESTIONS", " selected=\"selected\"");
697  }
698  else
699  {
700  $this->tpl->setVariable("SELECTED_QUESTIONBLOCKS", " selected=\"selected\"");
701  }
702  $this->tpl->setVariable("TEXT_DATATYPE", $this->lng->txt("display_all_available"));
703  $this->tpl->setVariable("BTN_CHANGE", $this->lng->txt("change"));
704  $this->tpl->parseCurrentBlock();
705 
706  if ($_POST["cmd"]["reset"])
707  {
708  $_POST["filter_text"] = "";
709  }
710  $startrow = 0;
711  if ($_GET["prevrow"])
712  {
713  $startrow = $_GET["prevrow"];
714  }
715  if ($_GET["nextrow"])
716  {
717  $startrow = $_GET["nextrow"];
718  }
719  if ($_GET["startrow"])
720  {
721  $startrow = $_GET["startrow"];
722  }
723  $sort = ($_GET["sort"]) ? $_GET["sort"] : "title";
724  $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : "ASC";
725  $this->ctrl->setParameter($this, "sort", $sort);
726  $this->ctrl->setParameter($this, "sortorder", $sortorder);
727  if ($browsequestions)
728  {
729  $table = $this->object->getQuestionsTable($sort, $sortorder, $filter_text, $filter_type, $startrow, 1, $filter_question_type, $filter_questionpool);
730  }
731  else
732  {
733  $table = $this->object->getQuestionblocksTable($sort, $sortorder, $filter_text, $filter_type, $startrow);
734  }
735  $colors = array("tblrow1", "tblrow2");
736  $counter = 0;
737  $questionblock_id = 0;
738  if ($browsequestions)
739  {
740  include_once "./classes/class.ilFormat.php";
741  foreach ($table["rows"] as $data)
742  {
743  if ($rbacsystem->checkAccess("write", $data["ref_id"]))
744  {
745  if ($data["complete"])
746  {
747  // make only complete questions selectable
748  $this->tpl->setCurrentBlock("checkable");
749  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
750  $this->tpl->setVariable("COUNTER", $data["question_id"]);
751  $this->tpl->parseCurrentBlock();
752  }
753  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
754  $this->tpl->setCurrentBlock("QTab");
755  $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
756  $this->tpl->setVariable("TEXT_PREVIEW", $this->lng->txt("preview"));
757  $this->tpl->setVariable("URL_PREVIEW", "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $data["ref_id"] . "&cmd=preview&preview=" . $data["question_id"]);
758  $this->tpl->setVariable("COUNTER", $data["question_id"]);
759  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
760  $this->tpl->setVariable("QUESTION_TYPE", SurveyQuestion::_getQuestionTypeName($data["type_tag"]));
761  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
762  $this->tpl->setVariable('QUESTION_CREATED',ilDatePresentation::formatDate(new ilDate($data["created"],IL_CAL_TIMESTAMP)));
763  $this->tpl->setVariable('QUESTION_UPDATED',ilDatePresentation::formatDate(new ilDate($data["timestamp14"],IL_CAL_TIMESTAMP)));
764  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
765  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
766  $this->tpl->parseCurrentBlock();
767  $counter++;
768  }
769  }
770  if ($table["rowcount"] > count($table["rows"]))
771  {
772  $nextstep = $table["nextrow"] + $table["step"];
773  if ($nextstep > $table["rowcount"])
774  {
775  $nextstep = $table["rowcount"];
776  }
777  $counter = 1;
778  for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
779  {
780  $this->tpl->setCurrentBlock("pages_questions");
781  if ($table["startrow"] == $i)
782  {
783  $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
784  }
785  else
786  {
787  $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=$i" . "\">$counter</a>");
788  }
789  $this->tpl->parseCurrentBlock();
790  $counter++;
791  }
792  $this->tpl->setCurrentBlock("questions_navigation_bottom");
793  $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
794  $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
795  $end = $table["startrow"] + $table["step"];
796  if ($end > $table["rowcount"])
797  {
798  $end = $table["rowcount"];
799  }
800  $this->tpl->setVariable("TEXT_ITEM_END", $end);
801  $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
802  $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
803  $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
804  $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
805  $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&prevrow=" . $table["prevrow"]);
806  $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=" . $table["nextrow"]);
807  $this->tpl->parseCurrentBlock();
808  }
809  }
810  else
811  {
812  foreach ($table["rows"] as $data)
813  {
814  $this->tpl->setCurrentBlock("questionblock_row");
815  $this->tpl->setVariable("QUESTIONBLOCK_ID", $data["questionblock_id"]);
816  $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<strong>" . $data["title"] . "</strong>");
817  $this->tpl->setVariable("SURVEY_TITLE", $data["surveytitle"]);
818  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
819  $this->tpl->setVariable("QUESTIONS_TITLE", $data["questions"]);
820  $this->tpl->parseCurrentBlock();
821  $counter++;
822  }
823  if ($table["rowcount"] > count($table["rows"]))
824  {
825  $nextstep = $table["nextrow"] + $table["step"];
826  if ($nextstep > $table["rowcount"])
827  {
828  $nextstep = $table["rowcount"];
829  }
830  $counter = 1;
831  for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
832  {
833  $this->tpl->setCurrentBlock("pages_questionblocks");
834  if ($table["startrow"] == $i)
835  {
836  $this->tpl->setVariable("PAGE_NUMBER", "<strong>$counter</strong>");
837  }
838  else
839  {
840  $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=$i" . "\">$counter</a>");
841  }
842  $this->tpl->parseCurrentBlock();
843  $counter++;
844  }
845  $this->tpl->setCurrentBlock("questionblocks_navigation_bottom");
846  $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
847  $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
848  $end = $table["startrow"] + $table["step"];
849  if ($end > $table["rowcount"])
850  {
851  $end = $table["rowcount"];
852  }
853  $this->tpl->setVariable("TEXT_ITEM_END", $end);
854  $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
855  $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
856  $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
857  $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
858  $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&prevrow=" . $table["prevrow"]);
859  $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . $add_parameter . "&nextrow=" . $table["nextrow"]);
860  $this->tpl->parseCurrentBlock();
861  }
862  }
863 
864  // if there are no questions, display a message
865  if ($counter == 0)
866  {
867  $this->tpl->setCurrentBlock("Emptytable");
868  if ($browsequestions)
869  {
870  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
871  }
872  else
873  {
874  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questionblocks_available"));
875  }
876  $this->tpl->parseCurrentBlock();
877  }
878  else
879  {
880  $this->tpl->setCurrentBlock("selectall");
881  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
882  $counter++;
883  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
884  $this->tpl->parseCurrentBlock();
885  // create edit buttons & table footer
886  $this->tpl->setCurrentBlock("selection");
887  $this->tpl->setVariable("INSERT", $this->lng->txt("insert"));
888  $this->tpl->parseCurrentBlock();
889 
890  $this->tpl->setCurrentBlock("Footer");
891  include_once "./Services/Utilities/classes/class.ilUtil.php";
892  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
893  $this->tpl->parseCurrentBlock();
894  }
895  // define the sort column parameters
896  $sortarray = array(
897  "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
898  "description" => (strcmp($sort, "description") == 0) ? $sortorder : "",
899  "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
900  "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
901  "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
902  "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : "",
903  "qpl" => (strcmp($sort, "qpl") == 0) ? $sortorder : "",
904  "svy" => (strcmp($sort, "svy") == 0) ? $sortorder : ""
905  );
906  foreach ($sortarray as $key => $value)
907  {
908  if (strcmp($value, "ASC") == 0)
909  {
910  $sortarray[$key] = "DESC";
911  }
912  else
913  {
914  $sortarray[$key] = "ASC";
915  }
916  }
917 
918  if ($browsequestions)
919  {
920  $this->tpl->setCurrentBlock("questions_header");
921  $this->ctrl->setParameter($this, "sort", "title");
922  $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
923  $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
924  $this->ctrl->setParameter($this, "sort", "description");
925  $this->ctrl->setParameter($this, "sortorder", $sortarray["description"]);
926  $this->tpl->setVariable("QUESTION_COMMENT", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
927  $this->ctrl->setParameter($this, "sort", "type");
928  $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
929  $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
930  $this->ctrl->setParameter($this, "sort", "author");
931  $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
932  $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
933  $this->ctrl->setParameter($this, "sort", "created");
934  $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
935  $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
936  $this->ctrl->setParameter($this, "sort", "updated");
937  $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
938  $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
939  $this->ctrl->setParameter($this, "sort", "qpl");
940  $this->ctrl->setParameter($this, "sortorder", $sortarray["qpl"]);
941  $this->tpl->setVariable("QUESTION_POOL", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("obj_spl") . "</a>" . $table["images"]["qpl"]);
942  $this->tpl->parseCurrentBlock();
943  }
944  else
945  {
946  $this->tpl->setCurrentBlock("questionblocks_header");
947  $this->ctrl->setParameter($this, "sort", "title");
948  $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
949  $this->tpl->setVariable("QUESTIONBLOCK_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
950  $this->ctrl->setParameter($this, "sort", "svy");
951  $this->ctrl->setParameter($this, "sortorder", $sortarray["svy"]);
952  $this->tpl->setVariable("SURVEY_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "browseForQuestions") . "$add_parameter&startrow=" . $table["startrow"] . "\">" . $this->lng->txt("obj_svy") . "</a>" . $table["images"]["svy"]);
953  $this->tpl->setVariable("QUESTIONS_TITLE", $this->lng->txt("contains"));
954  $this->tpl->parseCurrentBlock();
955  }
956  $this->tpl->setCurrentBlock("adm_content");
957  // create table header
958  $this->ctrl->setParameter($this, "sort", $sort);
959  $this->ctrl->setParameter($this, "sortorder", $sortorder);
960  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "browseForQuestions") . $add_parameter);
961  $this->tpl->parseCurrentBlock();
962  }
963 
973  function removeQuestionsForm($checked_questions, $checked_questionblocks)
974  {
976  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_remove_questions.html", "Modules/Survey");
977  $colors = array("tblrow1", "tblrow2");
978  $counter = 0;
979  $surveyquestions =& $this->object->getSurveyQuestions();
980  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
981  foreach ($surveyquestions as $question_id => $data)
982  {
983  if (in_array($data["question_id"], $checked_questions) or (in_array($data["questionblock_id"], $checked_questionblocks)))
984  {
985  $this->tpl->setCurrentBlock("row");
986  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
987  $this->tpl->setVariable("TEXT_TITLE", $data["title"]);
988  $this->tpl->setVariable("TEXT_DESCRIPTION", $data["description"]);
989  $this->tpl->setVariable("TEXT_TYPE", SurveyQuestion::_getQuestionTypeName($data["type_tag"]));
990  $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $data["questionblock_title"]);
991  $this->tpl->parseCurrentBlock();
992  $counter++;
993  }
994  }
995  foreach ($checked_questions as $id)
996  {
997  $this->tpl->setCurrentBlock("hidden");
998  $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
999  $this->tpl->setVariable("HIDDEN_VALUE", "$id");
1000  $this->tpl->parseCurrentBlock();
1001  }
1002  foreach ($checked_questionblocks as $id)
1003  {
1004  $this->tpl->setCurrentBlock("hidden");
1005  $this->tpl->setVariable("HIDDEN_NAME", "id_qb_$id");
1006  $this->tpl->setVariable("HIDDEN_VALUE", "$id");
1007  $this->tpl->parseCurrentBlock();
1008  }
1009  $this->tpl->setCurrentBlock("adm_content");
1010  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
1011  $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
1012  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
1013  $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock"));
1014  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
1015  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1016  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "confirmRemoveQuestions"));
1017  $this->tpl->parseCurrentBlock();
1018  }
1019 
1020 
1029  function defineQuestionblock($questionblock_id = "")
1030  {
1031  $this->questionsSubtabs("questions");
1032  ilUtil::sendInfo();
1033  if ($questionblock_id)
1034  {
1035  $questionblock = $this->object->getQuestionblock($questionblock_id);
1036  }
1037  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_define_questionblock.html", "Modules/Survey");
1038  foreach ($_POST as $key => $value)
1039  {
1040  if (preg_match("/cb_(\d+)/", $key, $matches))
1041  {
1042  $this->tpl->setCurrentBlock("hidden");
1043  $this->tpl->setVariable("HIDDEN_NAME", "cb_$matches[1]");
1044  $this->tpl->setVariable("HIDDEN_VALUE", $matches[1]);
1045  $this->tpl->parseCurrentBlock();
1046  }
1047  }
1048  if ($questionblock_id)
1049  {
1050  $this->tpl->setCurrentBlock("hidden");
1051  $this->tpl->setVariable("HIDDEN_NAME", "questionblock_id");
1052  $this->tpl->setVariable("HIDDEN_VALUE", $questionblock_id);
1053  $this->tpl->parseCurrentBlock();
1054  }
1055  $this->tpl->setCurrentBlock("adm_content");
1056  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
1057  if ($questionblock_id)
1058  {
1059  $this->tpl->setVariable("VALUE_TITLE", $questionblock["title"]);
1060  }
1061  $this->tpl->setVariable("TXT_QUESTIONTEXT_DESCRIPTION", $this->lng->txt("show_questiontext_description"));
1062  $this->tpl->setVariable("TXT_QUESTIONTEXT", $this->lng->txt("show_questiontext"));
1063  if (($questionblock["show_questiontext"]) || (strlen($questionblock_id) == 0))
1064  {
1065  $this->tpl->setVariable("CHECKED_QUESTIONTEXT", " checked=\"checked\"");
1066  }
1067  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
1068  $this->tpl->setVariable("HEADING_QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
1069  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
1070  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
1071  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "saveDefineQuestionblock"));
1072  $this->tpl->parseCurrentBlock();
1073  }
1074 
1083  {
1084  global $ilUser;
1085  $this->questionsSubtabs("questions");
1086  $tpl = new ilTemplate("tpl.il_svy_svy_qpl_select.html", TRUE, TRUE, "Modules/Survey");
1087  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, TRUE, TRUE, "write");
1088  if (count($questionpools))
1089  {
1090  foreach ($questionpools as $key => $value)
1091  {
1092  $tpl->setCurrentBlock("option");
1093  $tpl->setVariable("VALUE_OPTION", $key);
1094  $tpl->setVariable("TEXT_OPTION", $value);
1095  $tpl->parseCurrentBlock();
1096  }
1097  $tpl->setCurrentBlock("selection");
1098  $tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("select_questionpool"));
1099  $tpl->parseCurrentBlock();
1100  }
1101  else
1102  {
1103  $tpl->setCurrentBlock("selection");
1104  $tpl->setVariable("TXT_QPL_ENTER", $this->lng->txt("cat_create_spl"));
1105  $tpl->parseCurrentBlock();
1106  }
1107  $tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1108  $sel_question_types = (strlen($_POST["sel_question_types"])) ? $_POST["sel_question_types"] : $_GET["sel_question_types"];
1109  $this->ctrl->setParameter($this, "sel_question_types", $sel_question_types);
1110  $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "executeCreateQuestion"));
1111  $tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1112  $this->tpl->setVariable("ADM_CONTENT", $tpl->get());
1113  }
1114 
1123  {
1124  $this->ctrl->redirect($this, "questions");
1125  }
1126 
1135  {
1136  if (strlen($_POST["sel_spl"]))
1137  {
1138  include_once "./Services/Utilities/classes/class.ilUtil.php";
1139  ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $_POST["sel_spl"] . "&cmd=createQuestionForSurvey&new_for_survey=".$_GET["ref_id"]."&sel_question_types=".$_GET["sel_question_types"]);
1140  }
1141  elseif (strlen($_POST["name_spl"]))
1142  {
1143  $ref_id = $this->createQuestionPool($_POST["name_spl"]);
1144  ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $ref_id . "&cmd=createQuestionForSurvey&new_for_survey=".$_GET["ref_id"]."&sel_question_types=".$_GET["sel_question_types"]);
1145  }
1146  else
1147  {
1148  ilUtil::sendInfo($this->lng->txt("err_no_pool_name"), true);
1149  $this->ctrl->setParameter($this, "sel_question_types", $_GET["sel_question_types"]);
1150  $this->ctrl->redirect($this, "createQuestion");
1151  }
1152  }
1153 
1160  private function createQuestionPool($name = "dummy")
1161  {
1162  global $tree;
1163  $parent_ref = $tree->getParentId($this->object->getRefId());
1164  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1165  $qpl = new ilObjSurveyQuestionPool();
1166  $qpl->setType("spl");
1167  $qpl->setTitle($name);
1168  $qpl->setDescription("");
1169  $qpl->create();
1170  $qpl->createReference();
1171  $qpl->putInTree($parent_ref);
1172  $qpl->setPermissions($parent_ref);
1173  $qpl->setOnline(1); // must be online to be available
1174  $qpl->saveToDb();
1175  return $qpl->getRefId();
1176  }
1177 
1186  function addHeadingObject($question_id = "")
1187  {
1188  $this->questionsSubtabs("questions");
1189  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_heading.html", "Modules/Survey");
1190  $survey_questions =& $this->object->getSurveyQuestions();
1191  if ($question_id)
1192  {
1193  $_POST["insertbefore"] = $question_id;
1194  $_POST["heading"] = $survey_questions[$question_id]["heading"];
1195  }
1196  foreach ($survey_questions as $key => $value)
1197  {
1198  $this->tpl->setCurrentBlock("insertbefore_row");
1199  $this->tpl->setVariable("VALUE_OPTION", $key);
1200  $option = $this->lng->txt("before") . ": \"" . $value["title"] . "\"";
1201  if (strlen($option) > 80)
1202  {
1203  $option = preg_replace("/^(.{40}).*(.{40})$/", "\\1 [...] \\2", $option);
1204  }
1205  include_once "./Services/Utilities/classes/class.ilUtil.php";
1206  $this->tpl->setVariable("TEXT_OPTION", ilUtil::prepareFormOutput($option));
1207  if ($key == $_POST["insertbefore"])
1208  {
1209  $this->tpl->setVariable("SELECTED_OPTION", " selected=\"selected\"");
1210  }
1211  $this->tpl->parseCurrentBlock();
1212  }
1213  if ($question_id)
1214  {
1215  $this->tpl->setCurrentBlock("hidden");
1216  $this->tpl->setVariable("INSERTBEFORE_ORIGINAL", $question_id);
1217  $this->tpl->parseCurrentBlock();
1218  }
1219  $this->tpl->setCurrentBlock("adm_content");
1220  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "saveHeading"));
1221  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
1222  if ($question_id)
1223  {
1224  $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("edit_heading"));
1225  $this->tpl->setVariable("SELECT_DISABLED", " disabled=\"disabled\"");
1226  }
1227  else
1228  {
1229  $this->tpl->setVariable("TEXT_ADD_HEADING", $this->lng->txt("add_heading"));
1230  }
1231  $this->tpl->setVariable("TEXT_HEADING", $this->lng->txt("heading"));
1232  $this->tpl->setVariable("VALUE_HEADING", $_POST["heading"]);
1233  $this->tpl->setVariable("TEXT_INSERT", $this->lng->txt("insert"));
1234  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
1235  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
1236  $this->tpl->parseCurrentBlock();
1237  include_once "./Services/RTE/classes/class.ilRTE.php";
1238  $rtestring = ilRTE::_getRTEClassname();
1239  include_once "./Services/RTE/classes/class.$rtestring.php";
1240  $rte = new $rtestring();
1241  $rte->removePlugin("ibrowser");
1242  include_once "./classes/class.ilObject.php";
1244  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
1245  $rte->addRTESupport($obj_id, $obj_type, "survey");
1246  }
1247 
1256  {
1257  // insert questions from test after confirmation
1258  foreach ($_POST as $key => $value) {
1259  if (preg_match("/id_(\d+)/", $key, $matches)) {
1260  if ($_GET["browsetype"] == 1)
1261  {
1262  $this->object->insertQuestion($matches[1]);
1263  }
1264  else
1265  {
1266  $this->object->insertQuestionBlock($matches[1]);
1267  }
1268  }
1269  }
1270  $this->object->saveCompletionStatus();
1271  ilUtil::sendInfo($this->lng->txt("questions_inserted"), true);
1272  $this->ctrl->redirect($this, "questions");
1273  }
1274 
1283  {
1284  $this->ctrl->redirect($this, "questions");
1285  }
1286 
1295  {
1296  if ($_POST["heading"])
1297  {
1298  $insertbefore = $_POST["insertbefore"];
1299  if (!$insertbefore)
1300  {
1301  $insertbefore = $_POST["insertbefore_original"];
1302  }
1303  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1304  $this->object->saveHeading(ilUtil::stripSlashes($_POST["heading"], TRUE, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey")), $insertbefore);
1305  $this->ctrl->redirect($this, "questions");
1306  }
1307  else
1308  {
1309  ilUtil::sendInfo($this->lng->txt("error_add_heading"));
1310  $this->addHeadingObject();
1311  return;
1312  }
1313  }
1314 
1323  {
1324  $this->ctrl->redirect($this, "questions");
1325  }
1326 
1335  {
1336  $this->object->saveHeading("", $_POST["removeheading"]);
1337  $this->ctrl->redirect($this, "questions");
1338  }
1339 
1348  {
1349  $this->ctrl->redirect($this, "questions");
1350  }
1351 
1360  {
1361  ilUtil::sendInfo($this->lng->txt("confirm_remove_heading"));
1362  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_confirm_removeheading.html", "Modules/Survey");
1363  $this->tpl->setCurrentBlock("adm_content");
1364  $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
1365  $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
1366  $this->tpl->setVariable("REMOVE_HEADING", $_GET["removeheading"]);
1367  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "confirmRemoveHeading"));
1368  $this->tpl->parseCurrentBlock();
1369  }
1370 
1379  {
1380  $checked_questions = array();
1381  $checked_questionblocks = array();
1382  foreach ($_POST as $key => $value)
1383  {
1384  if (preg_match("/id_(\d+)/", $key, $matches))
1385  {
1386  array_push($checked_questions, $matches[1]);
1387  }
1388  if (preg_match("/id_qb_(\d+)/", $key, $matches))
1389  {
1390  array_push($checked_questionblocks, $matches[1]);
1391  }
1392  }
1393  $this->object->removeQuestions($checked_questions, $checked_questionblocks);
1394  $this->object->saveCompletionStatus();
1395  ilUtil::sendInfo($this->lng->txt("questions_removed"), true);
1396  $this->ctrl->redirect($this, "questions");
1397  }
1398 
1407  {
1408  $this->ctrl->redirect($this, "questions");
1409  }
1410 
1419  {
1420  $questionblock = array();
1421  foreach ($_POST as $key => $value)
1422  {
1423  if (preg_match("/cb_(\d+)/", $key, $matches))
1424  {
1425  array_push($questionblock, $value);
1426  }
1427  }
1428  if (count($questionblock) < 2)
1429  {
1430  ilUtil::sendInfo($this->lng->txt("qpl_define_questionblock_select_missing"), true);
1431  $this->ctrl->redirect($this, "questions");
1432  }
1433  else
1434  {
1435  $this->defineQuestionblock();
1436  return;
1437  }
1438  }
1439 
1448  {
1449  if ($_POST["title"])
1450  {
1451  $show_questiontext = ($_POST["show_questiontext"]) ? 1 : 0;
1452  if ($_POST["questionblock_id"])
1453  {
1454  include_once "./Services/Utilities/classes/class.ilUtil.php";
1455  $this->object->modifyQuestionblock($_POST["questionblock_id"], ilUtil::stripSlashes($_POST["title"]), $show_questiontext);
1456  }
1457  else
1458  {
1459  $questionblock = array();
1460  foreach ($_POST as $key => $value)
1461  {
1462  if (preg_match("/cb_(\d+)/", $key, $matches))
1463  {
1464  array_push($questionblock, $value);
1465  }
1466  }
1467  include_once "./Services/Utilities/classes/class.ilUtil.php";
1468  $this->object->createQuestionblock(ilUtil::stripSlashes($_POST["title"]), $show_questiontext, $questionblock);
1469  }
1470  $this->ctrl->redirect($this, "questions");
1471  }
1472  else
1473  {
1474  ilUtil::sendInfo($this->lng->txt("enter_questionblock_title"));
1475  $this->defineQuestionblockObject();
1476  return;
1477  }
1478  }
1479 
1488  {
1489  $unfoldblocks = array();
1490  foreach ($_POST as $key => $value)
1491  {
1492  if (preg_match("/cb_qb_(\d+)/", $key, $matches))
1493  {
1494  array_push($unfoldblocks, $matches[1]);
1495  }
1496  }
1497  if (count($unfoldblocks))
1498  {
1499  $this->object->unfoldQuestionblocks($unfoldblocks);
1500  }
1501  else
1502  {
1503  ilUtil::sendInfo($this->lng->txt("qpl_unfold_select_none"), true);
1504  }
1505  $this->ctrl->redirect($this, "questions");
1506  }
1507 
1516  {
1517  $this->ctrl->redirect($this, "questions");
1518  }
1519 
1528  {
1529  $move_questions = array();
1530  foreach ($_POST as $key => $value)
1531  {
1532  if (preg_match("/cb_(\d+)/", $key, $matches))
1533  {
1534  array_push($move_questions, $matches[1]);
1535  }
1536  if (preg_match("/cb_qb_(\d+)/", $key, $matches))
1537  {
1538  $ids = $this->object->getQuestionblockQuestionIds($matches[1]);
1539  foreach ($ids as $qkey => $qid)
1540  {
1541  array_push($move_questions, $qid);
1542  }
1543  }
1544  }
1545  if (count($move_questions) == 0)
1546  {
1547  ilUtil::sendInfo($this->lng->txt("no_question_selected_for_move"), true);
1548  $this->ctrl->redirect($this, "questions");
1549  }
1550  else
1551  {
1552  $_SESSION["move_questions"] = $move_questions;
1553  ilUtil::sendInfo($this->lng->txt("select_target_position_for_move_question"));
1554  $this->questionsObject();
1555  }
1556  }
1557 
1565  function insertQuestions($insert_mode)
1566  {
1567  // get all questions to move
1568  $move_questions = $_SESSION["move_questions"];
1569  // get insert point
1570  $insert_id = -1;
1571  foreach ($_POST as $key => $value)
1572  {
1573  if (preg_match("/^cb_(\d+)$/", $key, $matches))
1574  {
1575  if ($insert_id < 0)
1576  {
1577  $insert_id = $matches[1];
1578  }
1579  }
1580  if (preg_match("/^cb_qb_(\d+)$/", $key, $matches))
1581  {
1582  if ($insert_id < 0)
1583  {
1584  $ids =& $this->object->getQuestionblockQuestionIds($matches[1]);
1585  if (count($ids))
1586  {
1587  if ($insert_mode == 0)
1588  {
1589  $insert_id = $ids[0];
1590  }
1591  else if ($insert_mode == 1)
1592  {
1593  $insert_id = $ids[count($ids)-1];
1594  }
1595  }
1596  }
1597  }
1598  }
1599  if ($insert_id <= 0)
1600  {
1601  ilUtil::sendInfo($this->lng->txt("no_target_selected_for_move"), true);
1602  }
1603  else
1604  {
1605  $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
1606  }
1607  unset($_SESSION["move_questions"]);
1608  $this->ctrl->redirect($this, "questions");
1609  }
1610 
1619  {
1620  $this->insertQuestions(0);
1621  }
1622 
1631  {
1632  $this->insertQuestions(1);
1633  }
1634 
1643  {
1644  $obligatory = array();
1645  foreach ($_POST as $key => $value)
1646  {
1647  if (preg_match("/obligatory_(\d+)/", $key, $matches))
1648  {
1649  $obligatory[$matches[1]] = 1;
1650  }
1651  }
1652  $this->object->setObligatoryStates($obligatory);
1653  $this->ctrl->redirect($this, "questions");
1654  }
1655 
1663  function questionsObject()
1664  {
1665  $this->handleWriteAccess();
1666  global $rbacsystem;
1667 
1668  $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
1669  include_once "./Services/Utilities/classes/class.ilUtil.php";
1670  if ((!$rbacsystem->checkAccess("read", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
1671  {
1672  // allow only read and write access
1673  ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), true);
1674  $path = $this->tree->getPathFull($this->object->getRefID());
1675  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
1676  return;
1677  }
1678 
1679  if ($_GET["new_id"] > 0)
1680  {
1681  // add a question to the survey previous created in a questionpool
1682  $inserted = $this->object->insertQuestion($_GET["new_id"]);
1683  if (!$inserted)
1684  {
1685  ilUtil::sendInfo($this->lng->txt("survey_error_insert_incomplete_question"));
1686  }
1687  }
1688 
1689  if ($_GET["eqid"] and $_GET["eqpl"])
1690  {
1691  ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForSurvey&calling_survey=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
1692  }
1693 
1694 
1695  $_SESSION["calling_survey"] = $this->object->getRefId();
1696  unset($_SESSION["survey_id"]);
1697 
1698  if ($_GET["editheading"])
1699  {
1700  $this->addHeadingObject($_GET["editheading"]);
1701  return;
1702  }
1703 
1704  if ($_GET["up"] > 0)
1705  {
1706  $this->object->moveUpQuestion($_GET["up"]);
1707  }
1708  if ($_GET["down"] > 0)
1709  {
1710  $this->object->moveDownQuestion($_GET["down"]);
1711  }
1712  if ($_GET["qbup"] > 0)
1713  {
1714  $this->object->moveUpQuestionblock($_GET["qbup"]);
1715  }
1716  if ($_GET["qbdown"] > 0)
1717  {
1718  $this->object->moveDownQuestionblock($_GET["qbdown"]);
1719  }
1720 
1721  if ($_GET["removeheading"])
1722  {
1723  $this->confirmRemoveHeadingForm();
1724  return;
1725  }
1726 
1727  if ($_GET["editblock"])
1728  {
1729  $this->defineQuestionblock($_GET["editblock"]);
1730  return;
1731  }
1732 
1733  if ($_GET["add"])
1734  {
1735  // called after a new question was created from a questionpool
1736  $selected_array = array();
1737  array_push($selected_array, $_GET["add"]);
1738  ilUtil::sendInfo($this->lng->txt("ask_insert_questions"));
1739  $this->insertQuestionsForm($selected_array);
1740  return;
1741  }
1742 
1743  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_questions.html", "Modules/Survey");
1744 
1745  $survey_questions =& $this->object->getSurveyQuestions();
1746  $questionblock_titles =& $this->object->getQuestionblockTitles();
1747  $questionpools =& $this->object->getQuestionpoolTitles();
1748  $colors = array("tblrow1", "tblrow2");
1749  $counter = 0;
1750  $title_counter = 0;
1751  $last_color_class = "";
1752  $obligatory = "<img src=\"" . ilUtil::getImagePath("obligatory.gif", "Modules/Survey") . "\" alt=\"" . $this->lng->txt("question_obligatory") . "\" title=\"" . $this->lng->txt("question_obligatory") . "\" />";
1753  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1754  $questiontypes =& ilObjSurveyQuestionPool::_getQuestiontypes();
1755  if (count($survey_questions) > 0)
1756  {
1757  foreach ($survey_questions as $question_id => $data)
1758  {
1759  $title_counter++;
1760  if (($last_questionblock_id > 0) && ($data["questionblock_id"] == 0))
1761  {
1762  $counter++;
1763  }
1764  if (($last_questionblock_id > 0) && ($data["questionblock_id"] > 0) && ($data["questionblock_id"] != $last_questionblock_id))
1765  {
1766  $counter++;
1767  }
1768  if (($data["questionblock_id"] > 0) and ($data["questionblock_id"] != $last_questionblock_id))
1769  {
1770  // add a separator line for the beginning of a question block
1771  $this->tpl->setCurrentBlock("separator");
1772  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1773  $this->tpl->parseCurrentBlock();
1774  $this->tpl->setCurrentBlock("QTab");
1775  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1776  $this->tpl->parseCurrentBlock();
1777 
1778  $this->tpl->setCurrentBlock("block");
1779  $this->tpl->setVariable("TYPE_ICON", "<img src=\"" . ilUtil::getImagePath("questionblock.gif", "Modules/Survey") . "\" alt=\"".$this->lng->txt("questionblock_icon")."\" />");
1780  $this->tpl->setVariable("TEXT_QUESTIONBLOCK", $this->lng->txt("questionblock") . ": " . $data["questionblock_title"]);
1781  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1782  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1783  {
1784  if ($data["question_id"] != $this->object->questions[0])
1785  {
1786  $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "$&qbup=" . $data["questionblock_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"" . $this->lng->txt("up") . "\" title=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
1787  }
1788  $akeys = array_keys($survey_questions);
1789  if ($data["questionblock_id"] != $survey_questions[$akeys[count($akeys)-1]]["questionblock_id"])
1790  {
1791  $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&qbdown=" . $data["questionblock_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"" . $this->lng->txt("down") . "\" title=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
1792  }
1793  $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
1794  $this->tpl->setVariable("HREF_EDIT", $this->ctrl->getLinkTarget($this, "questions") . "&editblock=" . $data["questionblock_id"]);
1795  }
1796  $this->tpl->parseCurrentBlock();
1797  $this->tpl->setCurrentBlock("QTab");
1798  $this->tpl->setVariable("QUESTION_ID", "qb_" . $data["questionblock_id"]);
1799  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1800  $this->tpl->parseCurrentBlock();
1801  }
1802  if (($last_questionblock_id > 0) && ($data["questionblock_id"] == 0))
1803  {
1804  // add a separator line for the end of a question block
1805  $this->tpl->setCurrentBlock("separator");
1806  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1807  $this->tpl->parseCurrentBlock();
1808  $this->tpl->setCurrentBlock("QTab");
1809  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1810  $this->tpl->parseCurrentBlock();
1811  }
1812  if ($data["heading"])
1813  {
1814  $this->tpl->setCurrentBlock("heading");
1815  $this->tpl->setVariable("TEXT_HEADING", $data["heading"]);
1816  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1817  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1818  {
1819  $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
1820  $this->tpl->setVariable("HREF_EDIT", $this->ctrl->getLinkTarget($this, "questions") . "&editheading=" . $data["question_id"]);
1821  $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("remove"));
1822  $this->tpl->setVariable("HREF_DELETE", $this->ctrl->getLinkTarget($this, "questions") . "&removeheading=" . $data["question_id"]);
1823  }
1824  $this->tpl->parseCurrentBlock();
1825  $this->tpl->setCurrentBlock("QTab");
1826  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1827  $this->tpl->parseCurrentBlock();
1828  }
1829  if (!$data["questionblock_id"])
1830  {
1831  $this->tpl->setCurrentBlock("checkable");
1832  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
1833  $this->tpl->parseCurrentBlock();
1834  }
1835  $this->tpl->setCurrentBlock("QTab");
1836  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1838  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1839  {
1840  $q_id = $data["question_id"];
1841  $qpl_ref_id = $this->object->_getRefIdFromObjId($data["obj_fi"]);
1842  $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. <a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
1843  }
1844  else
1845  {
1846  $this->tpl->setVariable("QUESTION_TITLE", "$title_counter. ". $data["title"]);
1847  }
1848  $this->tpl->setVariable("TYPE_ICON", "<img src=\"" . ilUtil::getImagePath("question.gif", "Modules/Survey") . "\" alt=\"".$this->lng->txt("question_icon")."\" />");
1849  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1850  {
1851  $obligatory_checked = "";
1852  if ($data["obligatory"] == 1)
1853  {
1854  $obligatory_checked = " checked=\"checked\"";
1855  }
1856  $this->tpl->setVariable("QUESTION_OBLIGATORY", "<input type=\"checkbox\" name=\"obligatory_" . $data["question_id"] . "\" value=\"1\"$obligatory_checked />");
1857  }
1858  else
1859  {
1860  if ($data["obligatory"] == 1)
1861  {
1862  $this->tpl->setVariable("QUESTION_OBLIGATORY", $obligatory);
1863  }
1864  }
1865  $this->tpl->setVariable("QUESTION_COMMENT", $data["description"]);
1866  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1867  {
1868  if (!$data["questionblock_id"])
1869  {
1870  // up/down buttons for non-questionblock questions
1871  if ($data["question_id"] != $this->object->questions[0])
1872  {
1873  $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&up=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"".$this->lng->txt("up")."\" border=\"0\" /></a>");
1874  }
1875  if ($data["question_id"] != $this->object->questions[count($this->object->questions)-1])
1876  {
1877  $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&down=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"".$this->lng->txt("down")."\" border=\"0\" /></a>");
1878  }
1879  }
1880  else
1881  {
1882  // up/down buttons for questionblock questions
1883  if ($data["questionblock_id"] == $last_questionblock_id)
1884  {
1885  $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&up=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"".$this->lng->txt("up")."\" border=\"0\" /></a>");
1886  }
1887  $tmp_questions = array_keys($survey_questions);
1888  $blockkey = array_search($question_id, $tmp_questions);
1889  if (($blockkey !== FALSE) && ($blockkey < count($tmp_questions)-1))
1890  {
1891  if ($data["questionblock_id"] == $survey_questions[$tmp_questions[$blockkey+1]]["questionblock_id"])
1892  {
1893  $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&down=" . $data["question_id"] . "\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"".$this->lng->txt("down")."\" border=\"0\" /></a>");
1894  }
1895  }
1896  }
1897  }
1898  foreach ($questiontypes as $trans => $typedata)
1899  {
1900  if (strcmp($typedata["type_tag"], $data["type_tag"]) == 0)
1901  {
1902  $this->tpl->setVariable("QUESTION_TYPE", $trans);
1903  }
1904  }
1905  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
1906  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1907  $last_color_class = $colors[$counter % 2];
1908  if (!$data["questionblock_id"])
1909  {
1910  $counter++;
1911  }
1912  $this->tpl->parseCurrentBlock();
1913  $last_questionblock_id = $data["questionblock_id"];
1914  }
1915 
1916  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1917  {
1918  $this->tpl->setCurrentBlock("selectall");
1919  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
1920  $this->tpl->setVariable("COLOR_CLASS", $last_color_class);
1921  $this->tpl->parseCurrentBlock();
1922  if (array_key_exists("move_questions", $_SESSION))
1923  {
1924  $this->tpl->setCurrentBlock("move_buttons");
1925  $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
1926  $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
1927  $this->tpl->parseCurrentBlock();
1928  }
1929  $this->tpl->setCurrentBlock("QFooter");
1930  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
1931  $this->tpl->setVariable("REMOVE", $this->lng->txt("remove_question"));
1932  $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
1933  $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
1934  $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
1935  $this->tpl->setVariable("SAVE", $this->lng->txt("save_obligatory_state"));
1936  $this->tpl->parseCurrentBlock();
1937  }
1938  }
1939  else
1940  {
1941  $this->tpl->setCurrentBlock("Emptytable");
1942  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
1943  $this->tpl->parseCurrentBlock();
1944  }
1945  if (($last_questionblock_id > 0))
1946  {
1947  // add a separator line for the end of a question block (if the last question is a questionblock question)
1948  $this->tpl->setCurrentBlock("separator");
1949  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1950  $this->tpl->parseCurrentBlock();
1951  $this->tpl->setCurrentBlock("QTab");
1952  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
1953  $this->tpl->parseCurrentBlock();
1954  }
1955 
1956  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1957  {
1958  $this->tpl->setCurrentBlock("QTypes");
1959  $query = "SELECT * FROM survey_questiontype";
1960  $query_result = $this->ilias->db->query($query);
1961  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1962  while ($data = $query_result->fetchRow(MDB2_FETCHMODE_OBJECT))
1963  {
1964  $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
1965  $this->tpl->setVariable("QUESTION_TYPE", SurveyQuestion::_getQuestionTypeName($data->type_tag));
1966  $this->tpl->parseCurrentBlock();
1967  }
1968  $this->tpl->parseCurrentBlock();
1969  }
1970  $this->tpl->setCurrentBlock("adm_content");
1971  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "questions"));
1972  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("title"));
1973  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1974  $this->tpl->setVariable("QUESTION_OBLIGATORY", $this->lng->txt("obligatory"));
1975  $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("sequence"));
1976  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("question_type"));
1977  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1978 
1979  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
1980  {
1981  $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("browse_for_questions"));
1982  $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
1983  $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
1984  $this->tpl->setVariable("HEADING", $this->lng->txt("add_heading"));
1985  }
1986  if ($hasDatasets)
1987  {
1988  ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning"));
1989  }
1990 
1991  $this->tpl->parseCurrentBlock();
1992  $this->questionsSubtabs("questions");
1993  }
1994 
2002  function evaluationObject()
2003  {
2004  include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
2005  $eval_gui = new ilSurveyEvaluationGUI($this->object);
2006  $this->ctrl->setCmdClass(get_class($eval_gui));
2007  $this->ctrl->redirect($eval_gui, "evaluation");
2008  }
2009 
2017  function outUserGroupTable($a_type, $id_array, $block_result, $block_row, $title_text, $buttons)
2018  {
2019  global $rbacsystem;
2020 
2021  $rowclass = array("tblrow1", "tblrow2");
2022  switch($a_type)
2023  {
2024  case "usr":
2025  include_once './Services/User/classes/class.ilObjUser.php';
2026  $counter = 0;
2027  foreach ($id_array as $user_id)
2028  {
2029  $this->tpl->setCurrentBlock($block_row);
2030  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
2031  if (ilObjUser::_lookupLogin($user_id))
2032  {
2033  $user = new ilObjUser($user_id);
2034  $this->tpl->setVariable("COUNTER", $user->getId());
2035  $this->tpl->setVariable("VALUE_LOGIN", $user->getLogin());
2036  $this->tpl->setVariable("VALUE_FIRSTNAME", $user->getFirstname());
2037  $this->tpl->setVariable("VALUE_LASTNAME", $user->getLastname());
2038  }
2039  else
2040  {
2041  $this->tpl->setVariable("COUNTER", $user_id);
2042  $this->tpl->setVariable("VALUE_LOGIN", $this->lng->txt("deleted_user"));
2043  $this->tpl->setVariable("VALUE_FIRSTNAME", $this->lng->txt("unknown"));
2044  $this->tpl->setVariable("VALUE_LASTNAME", $this->lng->txt("unknown"));
2045  }
2046  $counter++;
2047  $this->tpl->parseCurrentBlock();
2048  }
2049  if (count($id_array))
2050  {
2051  $this->tpl->setCurrentBlock("selectall_$block_result");
2052  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2053  $counter++;
2054  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
2055  $this->tpl->parseCurrentBlock();
2056  }
2057  $this->tpl->setCurrentBlock($block_result);
2058  include_once "./Services/Utilities/classes/class.ilUtil.php";
2059  $this->tpl->setVariable("TEXT_USER_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_usr.gif") . "\" alt=\"".$this->lng->txt("obj_usr")."\" /> " . $title_text);
2060  $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
2061  $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
2062  $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
2063  if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
2064  {
2065  foreach ($buttons as $cat)
2066  {
2067  $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
2068  }
2069  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
2070  }
2071  $this->tpl->parseCurrentBlock();
2072  break;
2073  case "grp":
2074  include_once "./Modules/Group/classes/class.ilObjGroup.php";
2075  $counter = 0;
2076  foreach ($id_array as $group_id)
2077  {
2078  $group = new ilObjGroup($group_id);
2079  $this->tpl->setCurrentBlock($block_row);
2080  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
2081  $this->tpl->setVariable("COUNTER", $group->getRefId());
2082  $this->tpl->setVariable("VALUE_TITLE", $group->getTitle());
2083  $this->tpl->setVariable("VALUE_DESCRIPTION", $group->getDescription());
2084  $counter++;
2085  $this->tpl->parseCurrentBlock();
2086  }
2087  if (count($id_array))
2088  {
2089  $this->tpl->setCurrentBlock("selectall_$block_result");
2090  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2091  $counter++;
2092  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
2093  $this->tpl->parseCurrentBlock();
2094  }
2095  $this->tpl->setCurrentBlock($block_result);
2096  include_once "./Services/Utilities/classes/class.ilUtil.php";
2097  $this->tpl->setVariable("TEXT_GROUP_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_grp.gif") . "\" alt=\"".$this->lng->txt("obj_grp")."\" /> " . $title_text);
2098  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
2099  $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
2100  if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
2101  {
2102  foreach ($buttons as $cat)
2103  {
2104  $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
2105  }
2106  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
2107  }
2108  $this->tpl->parseCurrentBlock();
2109  break;
2110  case "role":
2111  include_once "./Services/AccessControl/classes/class.ilObjRole.php";
2112  $counter = 0;
2113  foreach ($id_array as $role_id)
2114  {
2115  $role = new ilObjRole($role_id);
2116  $this->tpl->setCurrentBlock($block_row);
2117  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
2118  $this->tpl->setVariable("COUNTER", $role->getId());
2119  $this->tpl->setVariable("VALUE_TITLE", $role->getTitle());
2120  $this->tpl->setVariable("VALUE_DESCRIPTION", $role->getDescription());
2121  $counter++;
2122  $this->tpl->parseCurrentBlock();
2123  }
2124  if (count($id_array))
2125  {
2126  $this->tpl->setCurrentBlock("selectall_$block_result");
2127  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2128  $counter++;
2129  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
2130  $this->tpl->parseCurrentBlock();
2131  }
2132  $this->tpl->setCurrentBlock($block_result);
2133  include_once "./Services/Utilities/classes/class.ilUtil.php";
2134  $this->tpl->setVariable("TEXT_ROLE_TITLE", "<img src=\"" . ilUtil::getImagePath("icon_role.gif") . "\" alt=\"".$this->lng->txt("obj_role")."\" /> " . $title_text);
2135  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
2136  $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
2137  if ($rbacsystem->checkAccess('invite', $this->object->getRefId()))
2138  {
2139  foreach ($buttons as $cat)
2140  {
2141  $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
2142  }
2143  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
2144  }
2145  $this->tpl->parseCurrentBlock();
2146  break;
2147  }
2148  }
2149 
2158  {
2159  include_once "./Services/Administration/classes/class.ilSetting.php";
2160  $surveySetting = new ilSetting("survey");
2161  $unlimited_invitation = $surveySetting->get("unlimited_invitation");
2162  $mode = $_POST["mode"];
2163  if (!$unlimited_invitation)
2164  {
2165  $mode = MODE_PREDEFINED_USERS;
2166  }
2167  $this->object->setInvitationAndMode($_POST["invitation"], $_POST["mode"]);
2168  $this->object->saveToDb();
2169  $this->ctrl->redirect($this, "invite");
2170  }
2171 
2180  {
2181  $this->inviteObject();
2182  }
2183 
2192  {
2193  // disinvite users
2194  if (is_array($_POST["invited_users"]))
2195  {
2196  foreach ($_POST["invited_users"] as $user_id)
2197  {
2198  $this->object->disinviteUser($user_id);
2199  }
2200  }
2201  $this->ctrl->redirect($this, "invite");
2202  }
2203 
2212  {
2213  // add users to invitation
2214  if (is_array($_POST["user_select"]))
2215  {
2216  foreach ($_POST["user_select"] as $user_id)
2217  {
2218  $this->object->inviteUser($user_id);
2219  }
2220  }
2221  // add groups to invitation
2222  $error = "";
2223  if (is_array($_POST["group_select"]))
2224  {
2225  $invited = 0;
2226  foreach ($_POST["group_select"] as $group_id)
2227  {
2228  $invited += $this->object->inviteGroup($group_id);
2229  }
2230  if ($invited == 0)
2231  {
2232  $error .= $this->lng->txt("no_user_of_group_invited");
2233  }
2234  }
2235  // add roles to invitation
2236  if (is_array($_POST["role_select"]))
2237  {
2238  $invited = 0;
2239  foreach ($_POST["role_select"] as $role_id)
2240  {
2241  $invited += $this->object->inviteRole($role_id);
2242  }
2243  if ($invited == 0)
2244  {
2245  $error .= $this->lng->txt("no_user_of_group_invited");
2246  }
2247  }
2248  if (strlen($error)) ilUtil::sendInfo($error, TRUE);
2249  $this->ctrl->redirect($this, "invite");
2250  }
2251 
2252 
2260  function inviteObject()
2261  {
2262  global $ilAccess;
2263  global $rbacsystem;
2264 
2265  if ((!$rbacsystem->checkAccess("visible,invite", $this->ref_id)) && (!$rbacsystem->checkAccess("write", $this->ref_id)))
2266  {
2267  // allow only read and write access
2268  ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), true);
2269  $path = $this->tree->getPathFull($this->object->getRefID());
2270  include_once "./Services/Utilities/classes/class.ilUtil.php";
2271  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
2272  return;
2273  }
2274 
2275  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_invite.html", "Modules/Survey");
2276 
2277  if ($this->object->getStatus() == STATUS_OFFLINE)
2278  {
2279  $this->tpl->setCurrentBlock("survey_offline");
2280  $this->tpl->setVariable("SURVEY_OFFLINE_MESSAGE", $this->lng->txt("survey_offline_message"));
2281  $this->tpl->parseCurrentBlock();
2282  return;
2283  }
2284 
2285  $concat = ($_POST["concatenation"]) ? $_POST["concatenation"] : "or";
2286  $searchfor = ($_POST["search_for"]) ? $_POST["search_for"] : array("usr");
2287 
2288  if (strcmp($this->ctrl->getCmd(), "searchInvitation") == 0)
2289  {
2290  if (is_array($_POST["search_for"]))
2291  {
2292  if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]) or in_array("role", $_POST["search_for"]))
2293  {
2294  include_once "./classes/class.ilSearch.php";
2295  $search =& new ilSearch($ilUser->id);
2296  $search->setSearchString($_POST["search_term"]);
2297  $search->setCombination($concat);
2298  $search->setSearchFor($searchfor);
2299  $search->setSearchType("new");
2300  if($search->validate($message))
2301  {
2302  $search->performSearch();
2303  }
2304  if ($message)
2305  {
2306  ilUtil::sendInfo($message);
2307  }
2308  if(!$search->getNumberOfResults() && $search->getSearchFor())
2309  {
2310  ilUtil::sendInfo($this->lng->txt("search_no_match"));
2311  }
2312  $buttons = array("add");
2313  $invited_users = $this->object->getInvitedUsers();
2314  if ($searchresult = $search->getResultByType("usr"))
2315  {
2316  $users = array();
2317  foreach ($searchresult as $result_array)
2318  {
2319  if (!in_array($result_array["id"], $invited_users))
2320  {
2321  if ($ilAccess->checkAccessOfUser($result_array["id"], "read", "", $this->object->getRefId(), "svy", $this->object->getId()))
2322  {
2323  array_push($users, $result_array["id"]);
2324  }
2325  }
2326  }
2327  if (count($users))
2328  {
2329  $this->outUserGroupTable("usr", $users, "user_result", "user_row", $this->lng->txt("found_users"), $buttons);
2330  }
2331  else
2332  {
2333  ilUtil::sendInfo($this->lng->txt("search_no_match"));
2334  }
2335  }
2336  $searchresult = array();
2337  if ($searchresult = $search->getResultByType("grp"))
2338  {
2339  $groups = array();
2340  foreach ($searchresult as $result_array)
2341  {
2342  array_push($groups, $result_array["id"]);
2343  }
2344  $this->outUserGroupTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_groups"), $buttons);
2345  }
2346  $searchresult = array();
2347  if ($searchresult = $search->getResultByType("role"))
2348  {
2349  $roles = array();
2350  foreach ($searchresult as $result_array)
2351  {
2352  array_push($roles, $result_array["id"]);
2353  }
2354  $this->outUserGroupTable("role", $roles, "role_result", "role_row", $this->lng->txt("search_roles"), $buttons);
2355  }
2356  }
2357  }
2358  else
2359  {
2360  ilUtil::sendInfo($this->lng->txt("no_user_or_group_selected"));
2361  }
2362  }
2363 
2364  if (($this->object->getInvitationMode() == MODE_PREDEFINED_USERS) and ($this->object->getInvitation() == INVITATION_ON))
2365  {
2366  if ($rbacsystem->checkAccess('invite', $this->ref_id))
2367  {
2368  $this->tpl->setCurrentBlock("invitation");
2369  $this->tpl->setVariable("SEARCH_INVITATION", $this->lng->txt("search_invitation"));
2370  $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("search_term"));
2371  $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
2372  $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("objs_usr"));
2373  $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("objs_grp"));
2374  $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("objs_role"));
2375  $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
2376  $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
2377  $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
2378  $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
2379  if (is_array($searchfor))
2380  {
2381  if (in_array("usr", $searchfor))
2382  {
2383  $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
2384  }
2385  if (in_array("grp", $searchfor))
2386  {
2387  $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
2388  }
2389  if (in_array("role", $searchfor))
2390  {
2391  $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
2392  }
2393  }
2394  if (strcmp($concat, "and") == 0)
2395  {
2396  $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
2397  }
2398  else if (strcmp($concat, "or") == 0)
2399  {
2400  $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
2401  }
2402  $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
2403  $this->tpl->parseCurrentBlock();
2404  }
2405  }
2406 
2407  if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
2408  {
2409  $invited_users = $this->object->getInvitedUsers();
2410  $buttons = array("disinvite");
2411  if (count($invited_users))
2412  {
2413  $this->outUserGroupTable("usr", $invited_users, "invited_user_result", "invited_user_row", $this->lng->txt("invited_users"), $buttons);
2414  }
2415  }
2416  if ($this->object->getInvitation() == INVITATION_ON)
2417  {
2418  include_once "./Services/Administration/classes/class.ilSetting.php";
2419  $surveySetting = new ilSetting("survey");
2420  $unlimited_invitation = $surveySetting->get("unlimited_invitation");
2421  if (!$unlimited_invitation)
2422  {
2423  $this->tpl->touchBlock("disabled_mode");
2424  }
2425  $this->tpl->setCurrentBlock("invitation_mode");
2426  $this->tpl->setVariable("TEXT_MODE", $this->lng->txt("invitation_mode"));
2427  $this->tpl->setVariable("VALUE_UNLIMITED", $this->lng->txt("unlimited_users"));
2428  $this->tpl->setVariable("VALUE_PREDEFINED", $this->lng->txt("predefined_users"));
2429  if (!$unlimited_invitation)
2430  {
2431  $this->tpl->setVariable("SELECTED_PREDEFINED", " selected=\"selected\"");
2432  }
2433  else
2434  {
2435  if ($this->object->getInvitationMode() == MODE_PREDEFINED_USERS)
2436  {
2437  $this->tpl->setVariable("SELECTED_PREDEFINED", " selected=\"selected\"");
2438  }
2439  else
2440  {
2441  $this->tpl->setVariable("SELECTED_UNLIMITED", " selected=\"selected\"");
2442  }
2443  }
2444  $this->tpl->parseCurrentBlock();
2445  }
2446 
2447  if ($rbacsystem->checkAccess("write", $this->ref_id) or $rbacsystem->checkAccess('invite', $this->ref_id))
2448  {
2449  $this->tpl->setCurrentBlock("command_buttons");
2450  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
2451  $this->tpl->parseCurrentBlock();
2452  }
2453 
2454  $this->tpl->setCurrentBlock("survey_online");
2455  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "invite"));
2456  $this->tpl->setVariable("TEXT_INVITATION", $this->lng->txt("invitation"));
2457  $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
2458  $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
2459  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
2460  if ($this->object->getInvitation() == INVITATION_ON)
2461  {
2462  $this->tpl->setVariable("SELECTED_ON", " selected=\"selected\"");
2463  }
2464  else
2465  {
2466  $this->tpl->setVariable("SELECTED_OFF", " selected=\"selected\"");
2467  }
2468  $this->tpl->parseCurrentBlock();
2469  }
2470 
2479  {
2480  ilUtil::sendInfo($this->lng->txt("confirm_delete_all_user_data"));
2481  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", "Modules/Survey");
2482  $this->tpl->setCurrentBlock("confirm_delete");
2483  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
2484  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
2485  $this->tpl->parseCurrentBlock();
2486  $this->tpl->setCurrentBlock("adm_content");
2487  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "deleteAllUserData"));
2488  $this->tpl->parseCurrentBlock();
2489  }
2490 
2499  {
2500  $this->object->deleteAllUserData();
2501  ilUtil::sendInfo($this->lng->txt("svy_all_user_data_deleted"), true);
2502  $this->ctrl->redirect($this, "maintenance");
2503  }
2504 
2513  {
2514  $this->ctrl->redirect($this, "maintenance");
2515  }
2516 
2525  {
2526  $this->object->removeSelectedSurveyResults($_POST["chbUser"]);
2527  ilUtil::sendInfo($this->lng->txt("svy_selected_user_data_deleted"), true);
2528  $this->ctrl->redirect($this, "maintenance");
2529  }
2530 
2539  {
2540  $this->ctrl->redirect($this, "maintenance");
2541  }
2542 
2551  {
2552  if (count($_POST["chbUser"]) == 0)
2553  {
2554  $this->ctrl->redirect($this, "maintenance");
2555  }
2556  ilUtil::sendInfo($this->lng->txt("confirm_delete_single_user_data"));
2557  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", "Modules/Survey");
2558 
2559  $this->tpl->setCurrentBlock("confirm_delete_selected");
2560  $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
2561  $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
2562  $this->tpl->parseCurrentBlock();
2563 
2564  foreach ($_POST["chbUser"] as $key => $value)
2565  {
2566  $this->tpl->setCurrentBlock("hidden");
2567  $this->tpl->setVariable("USER_ID", $value);
2568  $this->tpl->parseCurrentBlock();
2569  }
2570 
2571  $this->tpl->setCurrentBlock("adm_content");
2572  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "deleteSingleUserResults"));
2573  $this->tpl->parseCurrentBlock();
2574  }
2575 
2577  {
2578  $this->handleWriteAccess();
2579 
2580  global $rbacsystem;
2581 
2582  if ($rbacsystem->checkAccess("write", $this->ref_id))
2583  {
2584  if ($_GET["fill"] > 0)
2585  {
2586  for ($i = 0; $i < $_GET["fill"]; $i++) $this->object->fillSurveyForUser();
2587  }
2588  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_maintenance.html", "Modules/Survey");
2589  $total =& $this->object->getSurveyParticipants();
2590  if (count($total))
2591  {
2592  $color_class = array("tblrow1", "tblrow2");
2593  $counter = 0;
2594  foreach ($total as $user_data)
2595  {
2596  $user_name = $user_data["sortname"];
2597  $user_login = $user_data["login"];
2598  $this->tpl->setCurrentBlock("userrow");
2599  $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
2600  $this->tpl->setVariable("USER_ID", $user_data["active_id"]);
2601  $this->tpl->setVariable("VALUE_USER_NAME", $user_name);
2602  $this->tpl->setVariable("VALUE_USER_LOGIN", $user_login);
2603  $last_access = $this->object->_getLastAccess($user_data["active_id"]);
2604  $this->tpl->setVariable('LAST_ACCESS',ilDatePresentation::formatDate(new ilDateTime($last_access,IL_CAL_TIMESTAMP)));
2605  $this->tpl->parseCurrentBlock();
2606  $counter++;
2607  }
2608  $this->tpl->setCurrentBlock("selectall");
2609  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2610  $counter++;
2611  $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
2612  $this->tpl->parseCurrentBlock();
2613  $this->tpl->setCurrentBlock("participanttable");
2614  $this->tpl->setVariable("USER_NAME", $this->lng->txt("name"));
2615  $this->tpl->setVariable("USER_LOGIN", $this->lng->txt("login"));
2616  $this->tpl->setVariable("LAST_ACCESS", $this->lng->txt("last_access"));
2617  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
2618  $this->tpl->setVariable("ARROW", $this->lng->txt("arrow_downright"));
2619  $this->tpl->setVariable("DELETE", $this->lng->txt("delete_user_data"));
2620  $this->tpl->parseCurrentBlock();
2621 
2622  $this->tpl->setCurrentBlock("adm_content");
2623  $this->tpl->setVariable("BTN_DELETE_ALL", $this->lng->txt("svy_delete_all_user_data"));
2624  // $this->tpl->setVariable("BTN_CREATE_SOLUTIONS", $this->lng->txt("tst_create_solutions"));
2625  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "deleteSingleUserResults"));
2626  $this->tpl->parseCurrentBlock();
2627  }
2628  else
2629  {
2630  $this->tpl->setCurrentBlock("maintenance_information");
2631  $this->tpl->setVariable("MAINTENANCE_INFORMATION", $this->lng->txt("svy_maintenance_information_no_results"));
2632  $this->tpl->parseCurrentBlock();
2633  }
2634  }
2635  else
2636  {
2637  ilUtil::sendInfo($this->lng->txt("cannot_maintain_survey"));
2638  }
2639  }
2640 
2641  /*
2642  * list all export files
2643  */
2644  function exportObject()
2645  {
2646  $this->handleWriteAccess();
2647 
2648  global $tree;
2649  global $rbacsystem;
2650 
2651  //add template for view button
2652  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
2653 
2654  // create export file button
2655  $this->tpl->setCurrentBlock("btn_cell");
2656  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
2657  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
2658  $this->tpl->parseCurrentBlock();
2659 
2660  $export_dir = $this->object->getExportDirectory();
2661  $export_files = $this->object->getExportFiles($export_dir);
2662 
2663  // create table
2664  include_once("./Services/Table/classes/class.ilTableGUI.php");
2665  $tbl = new ilTableGUI();
2666 
2667  // load files templates
2668  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
2669 
2670  // load template for table content data
2671  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", "Modules/Survey");
2672 
2673  $num = 0;
2674 
2675  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "export"));
2676 
2677  $tbl->setTitle($this->lng->txt("svy_export_files"));
2678 
2679  $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
2680  $this->lng->txt("svy_size"), $this->lng->txt("date") ));
2681 
2682  $tbl->enabled["sort"] = false;
2683  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
2684 
2685  // control
2686  $tbl->setOrderColumn($_GET["sort_by"]);
2687  $tbl->setOrderDirection($_GET["sort_order"]);
2688  $tbl->setLimit($_GET["limit"]);
2689  $tbl->setOffset($_GET["offset"]);
2690  $tbl->setMaxCount($this->maxcount); // ???
2691 
2692  $header_params = $this->ctrl->getParameterArray($this, "export");
2693  $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
2694 
2695  // footer
2696  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
2697  //$tbl->disable("footer");
2698 
2699  $tbl->setMaxCount(count($export_files));
2700  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
2701 
2702  $tbl->render();
2703  if(count($export_files) > 0)
2704  {
2705  $this->tpl->setVariable("COLUMN_COUNTS", 4);
2706 
2707  $i=0;
2708  foreach($export_files as $exp_file)
2709  {
2710  $this->tpl->setCurrentBlock("tbl_content");
2711  $this->tpl->setVariable("TXT_FILENAME", $exp_file);
2712 
2713  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
2714  $this->tpl->setVariable("CSS_ROW", $css_row);
2715 
2716  $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
2717  $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
2718 
2719  $file_arr = explode("__", $exp_file);
2720  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
2721 
2722  $this->tpl->parseCurrentBlock();
2723  }
2724  $this->tpl->setCurrentBlock("selectall");
2725  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2726  $this->tpl->setVariable("CSS_ROW", $css_row);
2727  $this->tpl->parseCurrentBlock();
2728  // delete button
2729  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
2730  $this->tpl->setCurrentBlock("tbl_action_btn");
2731  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
2732  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
2733  $this->tpl->parseCurrentBlock();
2734 
2735  $this->tpl->setCurrentBlock("tbl_action_btn");
2736  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
2737  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
2738  $this->tpl->parseCurrentBlock();
2739  } //if is_array
2740  else
2741  {
2742  $this->tpl->setCurrentBlock("notfound");
2743  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
2744  $this->tpl->setVariable("NUM_COLS", 3);
2745  $this->tpl->parseCurrentBlock();
2746  }
2747 
2748  $this->tpl->parseCurrentBlock();
2749  }
2750 
2755  {
2756  global $rbacsystem;
2757 
2758  if ($rbacsystem->checkAccess("write", $this->ref_id))
2759  {
2760  include_once("./Modules/Survey/classes/class.ilSurveyExport.php");
2761  $survey_exp = new ilSurveyExport($this->object);
2762  $survey_exp->buildExportFile();
2763  $this->ctrl->redirect($this, "export");
2764  }
2765  else
2766  {
2767  ilUtil::sendInfo("cannot_export_survey");
2768  }
2769  }
2770 
2776  function importObject()
2777  {
2778  $this->getTemplateFile("import", "svy");
2779  $this->tpl->setCurrentBlock("option_qpl");
2780  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
2781  $svy = new ilObjSurvey();
2782  $questionpools =& $svy->getAvailableQuestionpools(TRUE, FALSE, TRUE);
2783  if (count($questionpools) == 0)
2784  {
2785  }
2786  else
2787  {
2788  foreach ($questionpools as $key => $value)
2789  {
2790  $this->tpl->setCurrentBlock("option_spl");
2791  $this->tpl->setVariable("OPTION_VALUE", $key);
2792  $this->tpl->setVariable("TXT_OPTION", $value);
2793  $this->tpl->parseCurrentBlock();
2794  }
2795  }
2796  $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
2797  $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
2798  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "import"));
2799  $this->tpl->setVariable("BTN_NAME", "upload");
2800  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
2801  $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
2802  $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
2803  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
2804 
2805  }
2806 
2813  function uploadObject($redirect = true)
2814  {
2815  if ($_POST["spl"] < 1)
2816  {
2817  ilUtil::sendInfo($this->lng->txt("svy_select_questionpools"));
2818  $this->importObject();
2819  return;
2820  }
2821  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
2822  {
2823  ilUtil::sendInfo($this->lng->txt("svy_select_file_for_import"));
2824  $this->importObject();
2825  return;
2826  }
2827 
2828  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
2829  $newObj = new ilObjSurvey();
2830  $newObj->setType($_GET["new_type"]);
2831  $newObj->setTitle("dummy");
2832  $newObj->setDescription("dummy");
2833  $newObj->create(true);
2834  $newObj->createReference();
2835  $newObj->putInTree($_GET["ref_id"]);
2836  $newObj->setPermissions($_GET["ref_id"]);
2837  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
2838  // copy uploaded file to import directory
2839  $error = $newObj->importObject($_FILES["xmldoc"], $_POST["spl"]);
2840  if (strlen($error))
2841  {
2842  $newObj->delete();
2843  $this->ilias->raiseError($error, $this->ilias->error_obj->MESSAGE);
2844  return;
2845  }
2846  else
2847  {
2848  $ref_id = $newObj->getRefId();
2849  }
2850  if ($redirect)
2851  {
2852  include_once "./Services/Utilities/classes/class.ilUtil.php";
2853  ilUtil::redirect($this->getReturnLocation("upload",$this->ctrl->getTargetScript()."?".$this->link_params));
2854  }
2855  return $ref_id;
2856  }
2857 
2861  function createObject()
2862  {
2863  global $rbacsystem;
2864  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2865  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
2866  {
2867  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
2868  }
2869  else
2870  {
2871  $this->getTemplateFile("create", $new_type);
2872 
2873  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
2874  $svy = new ilObjSurvey();
2875 
2876  $this->fillCloneTemplate('DUPLICATE','svy');
2877  $questionpools =& $svy->getAvailableQuestionpools($use_obj_id = TRUE, $could_be_offline = TRUE, $showPath = TRUE);
2878  if (count($questionpools) > 0)
2879  {
2880  foreach ($questionpools as $key => $value)
2881  {
2882  $this->tpl->setCurrentBlock("option_spl");
2883  $this->tpl->setVariable("OPTION_VALUE", $key);
2884  $this->tpl->setVariable("TXT_OPTION", $value);
2885  if ($_POST["spl"] == $key)
2886  {
2887  $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
2888  }
2889  $this->tpl->parseCurrentBlock();
2890  }
2891  }
2892  // fill in saved values in case of error
2893  $data = array();
2894  $data["fields"] = array();
2895  include_once "./Services/Utilities/classes/class.ilUtil.php";
2896  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
2897  $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
2898 
2899  foreach ($data["fields"] as $key => $val)
2900  {
2901  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
2902  $this->tpl->setVariable(strtoupper($key), $val);
2903 
2904  if ($this->prepare_output)
2905  {
2906  $this->tpl->parseCurrentBlock();
2907  }
2908  }
2909 
2910  $this->ctrl->setParameter($this, "new_type", $this->type);
2911  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "create"));
2912  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
2913  $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_short"));
2914  $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
2915  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2916  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
2917  $this->tpl->setVariable("CMD_SUBMIT", "save");
2918  $this->tpl->setVariable("TARGET", ' target="'.
2919  ilFrameTargetInfo::_getFrame("MainContent").'" ');
2920  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
2921 
2922  $this->tpl->setVariable("TXT_IMPORT_SVY", $this->lng->txt("import_svy"));
2923  $this->tpl->setVariable("TXT_SVY_FILE", $this->lng->txt("svy_upload_file"));
2924  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
2925 
2926  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_svy.gif'));
2927  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_svy"));
2928  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_svy.gif'));
2929  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_svy"));
2930  }
2931  }
2932 
2936  function importFileObject()
2937  {
2938  if ($_POST["spl"] < 1)
2939  {
2940  ilUtil::sendInfo($this->lng->txt("svy_select_questionpools"));
2941  $this->createObject();
2942  return;
2943  }
2944  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
2945  {
2946  ilUtil::sendInfo($this->lng->txt("svy_select_file_for_import"));
2947  $this->createObject();
2948  return;
2949  }
2950  $this->ctrl->setParameter($this, "new_type", $this->type);
2951  $ref_id = $this->uploadObject(false);
2952  // always send a message
2953  ilUtil::sendInfo($this->lng->txt("object_imported"),true);
2954 
2955  ilUtil::redirect("ilias.php?ref_id=".$ref_id.
2956  "&baseClass=ilObjSurveyGUI");
2957 // $this->ctrl->redirect($this, "importFile");
2958  }
2959 
2964  {
2965  if(!isset($_POST["file"]))
2966  {
2967  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
2968  $this->ctrl->redirect($this, "export");
2969  }
2970 
2971  if (count($_POST["file"]) > 1)
2972  {
2973  ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
2974  $this->ctrl->redirect($this, "export");
2975  }
2976 
2977 
2978  $export_dir = $this->object->getExportDirectory();
2979  include_once "./Services/Utilities/classes/class.ilUtil.php";
2980  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
2981  $_POST["file"][0]);
2982  }
2983 
2988  {
2989  if(!isset($_POST["file"]))
2990  {
2991  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
2992  $this->ctrl->redirect($this, "export");
2993  }
2994 
2995  //$this->setTabs();
2996 
2997  // SAVE POST VALUES
2998  $_SESSION["ilExportFiles"] = $_POST["file"];
2999 
3000  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Survey");
3001 
3002  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
3003 
3004  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "deleteExportFile"));
3005 
3006  // BEGIN TABLE HEADER
3007  $this->tpl->setCurrentBlock("table_header");
3008  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
3009  $this->tpl->parseCurrentBlock();
3010 
3011  // BEGIN TABLE DATA
3012  $counter = 0;
3013  include_once "./Services/Utilities/classes/class.ilUtil.php";
3014  foreach($_POST["file"] as $file)
3015  {
3016  $this->tpl->setCurrentBlock("table_row");
3017  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_file.gif"));
3018  $this->tpl->setVariable("TEXT_IMG_OBJ", $this->lng->txt("file_icon"));
3019  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
3020  $this->tpl->setVariable("TEXT_CONTENT", $file);
3021  $this->tpl->parseCurrentBlock();
3022  }
3023 
3024  // cancel/confirm button
3025  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3026  $buttons = array("deleteExportFile" => $this->lng->txt("confirm"),
3027  "cancelDeleteExportFile" => $this->lng->txt("cancel"));
3028  foreach ($buttons as $name => $value)
3029  {
3030  $this->tpl->setCurrentBlock("operation_btn");
3031  $this->tpl->setVariable("BTN_NAME",$name);
3032  $this->tpl->setVariable("BTN_VALUE",$value);
3033  $this->tpl->parseCurrentBlock();
3034  }
3035  }
3036 
3037 
3042  {
3043  session_unregister("ilExportFiles");
3044  $this->ctrl->redirect($this, "export");
3045  }
3046 
3047 
3052  {
3053  $export_dir = $this->object->getExportDirectory();
3054  foreach($_SESSION["ilExportFiles"] as $file)
3055  {
3056  $exp_file = $export_dir."/".$file;
3057  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
3058  if (@is_file($exp_file))
3059  {
3060  unlink($exp_file);
3061  }
3062  if (@is_dir($exp_dir))
3063  {
3064  include_once "./Services/Utilities/classes/class.ilUtil.php";
3065  ilUtil::delDir($exp_dir);
3066  }
3067  }
3068  $this->ctrl->redirect($this, "export");
3069  }
3070 
3072  {
3073  if (strcmp($_POST["lang"], "-1") != 0)
3074  {
3075  global $ilUser;
3076  $ilUser->writePref("survey_code_language", $_POST["lang"]);
3077  }
3078  $this->ctrl->redirect($this, "codes");
3079  }
3080 
3088  function codesObject()
3089  {
3090  $this->handleWriteAccess();
3091 
3092  if ($this->object->getAnonymize() != 1)
3093  {
3094  return ilUtil::sendInfo($this->lng->txt("survey_codes_no_anonymization"));
3095  }
3096  global $rbacsystem;
3097  global $ilUser;
3098 
3099  $default_lang = $ilUser->getPref("survey_code_language");
3100  $tableoutput = "";
3101 
3102  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_codes.html", true);
3103  if ($rbacsystem->checkAccess("write", $this->ref_id))
3104  {
3105  $codecount = $this->object->getSurveyCodesCount();
3106  if ($codecount)
3107  {
3108  $maxentries = $ilUser->getPref("hits_per_page");
3109  if ($maxentries < 1)
3110  {
3111  $maxentries = 9999;
3112  }
3113 
3114  $survey_codes =& $this->object->getSurveyCodesTableData($default_lang, $_GET["offset"], $maxentries, $_GET["sort_by"], $_GET["sort_order"]);
3115  $headervars = array("", "counter", "date", "used", "url");
3116 
3117  include_once "./Services/Table/classes/class.ilTableGUI.php";
3118  $tbl = new ilTableGUI(0, FALSE);
3119  $tbl->setTitle($this->lng->txt("survey_code"));
3120  $header_names = array(
3121  "",
3122  $this->lng->txt("survey_code"),
3123  $this->lng->txt("create_date"),
3124  $this->lng->txt("survey_code_used"),
3125  $this->lng->txt("survey_code_url")
3126  );
3127  $tbl->setHeaderNames($header_names);
3128 
3129  $tbl->disable("sort");
3130  $tbl->disable("auto_sort");
3131  $tbl->disable("title");
3132  $tbl->disable("form");
3133  $tbl->enable("action");
3134  $tbl->enable("select_all");
3135  $tbl->setLimit($maxentries);
3136  $tbl->setOffset($_GET["offset"]);
3137  $tbl->setData($survey_codes);
3138  $tbl->setMaxCount($codecount);
3139  $tbl->setOrderDirection($_GET["sort_order"]);
3140  $tbl->setSelectAllCheckbox("chb_code");
3141  $tbl->setFormName("form_codes");
3142  $tbl->addActionButton("deleteCodes", $this->lng->txt("delete"));
3143  $tbl->addActionButton("exportCodes", $this->lng->txt("export"));
3144 
3145  $header_params = $this->ctrl->getParameterArray($this, "codes");
3146  $tbl->setHeaderVars($headervars, $header_params);
3147 
3148  // footer
3149  $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
3150  // render table
3151  $tableoutput = $tbl->render();
3152  $this->tpl->setCurrentBlock("exportall");
3153  $this->tpl->setVariable("VALUE_EXPORT_ALL_CODES", $this->lng->txt("export_all_survey_codes"));
3154  $this->tpl->parseCurrentBlock();
3155  }
3156  else
3157  {
3158  $this->tpl->setCurrentBlock("emptyrow");
3159  $this->tpl->setVariable("NO_CODES", $this->lng->txt("survey_code_no_codes"));
3160  $this->tpl->parseCurrentBlock();
3161  }
3162 
3163  $languages = $this->lng->getInstalledLanguages();
3164  foreach ($languages as $lang)
3165  {
3166  $this->tpl->setCurrentBlock("option_lang");
3167  $this->tpl->setVariable("VALUE_LANG", $lang);
3168  $this->tpl->setVariable("TEXT_LANG", $this->lng->txt("lang_$lang"));
3169  if (strcmp($lang, $default_lang) == 0)
3170  {
3171  $this->tpl->setVariable("SELECTED_LANG", " selected=\"selected\"");
3172  }
3173  $this->tpl->parseCurrentBlock();
3174  }
3175 
3176  $this->tpl->setCurrentBlock("adm_content");
3177  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "codes"));
3178  $this->tpl->setVariable("CODES_TABLE", $tableoutput);
3179  $this->tpl->setVariable("TEXT_CREATE", $this->lng->txt("create"));
3180  $this->tpl->setVariable("TEXT_SURVEY_CODES", $this->lng->txt("new_survey_codes"));
3181  $this->tpl->setVariable("TEXT_SURVEY_CODES_LANG", $this->lng->txt("survey_codes_lang"));
3182  $this->tpl->setVariable("TEXT_NO_LANGUAGE_SELECTED", $this->lng->txt("please_select"));
3183  $this->tpl->setVariable("VALUE_ACTIVATE", $this->lng->txt("select"));
3184  $this->tpl->parseCurrentBlock();
3185  }
3186  else
3187  {
3188  ilUtil::sendInfo($this->lng->txt("cannot_create_survey_codes"));
3189  }
3190  }
3191 
3200  {
3201  if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
3202  {
3203  foreach ($_POST["chb_code"] as $survey_code)
3204  {
3205  $this->object->deleteSurveyCode($survey_code);
3206  }
3207  }
3208  $this->codesObject();
3209  }
3210 
3219  {
3220  if (is_array($_POST["chb_code"]) && (count($_POST["chb_code"]) > 0))
3221  {
3222  $export = $this->object->getSurveyCodesForExport($_POST["chb_code"]);
3223  ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".txt"));
3224  }
3225  else
3226  {
3227  $this->codesObject();
3228  }
3229  }
3230 
3239  {
3240  $export = $this->object->getSurveyCodesForExport(array());
3241  ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".txt"));
3242  }
3243 
3252  {
3253  if (preg_match("/\d+/", $_POST["nrOfCodes"]))
3254  {
3255  $this->object->createSurveyCodes($_POST["nrOfCodes"]);
3256  }
3257  else
3258  {
3259  ilUtil::sendInfo($this->lng->txt("enter_valid_number_of_codes"), true);
3260  }
3261  $this->ctrl->redirect($this, "codes");
3262  }
3263 
3271  function addConstraintForm($step, $postvalues, &$survey_questions, $questions = FALSE)
3272  {
3273  $this->ctrl->saveParameter($this, "preid");
3274  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_add_constraint.html", "Modules/Survey");
3275  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3276  if (is_array($questions))
3277  {
3278  foreach ($questions as $question)
3279  {
3280  $this->tpl->setCurrentBlock("option_q");
3281  $this->tpl->setVariable("OPTION_VALUE", $question["question_id"]);
3282  $this->tpl->setVariable("OPTION_TEXT", $question["title"] . " (" . SurveyQuestion::_getQuestionTypeName($question["type_tag"]) . ")");
3283  if ($question["question_id"] == $postvalues["q"])
3284  {
3285  $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
3286  }
3287  $this->tpl->parseCurrentBlock();
3288  }
3289  }
3290  if ($step > 1)
3291  {
3292  $relations = $this->object->getAllRelations();
3293  foreach ($relations as $rel_id => $relation)
3294  {
3295  if (in_array($relation["short"], $survey_questions[$postvalues["q"]]["availableRelations"]))
3296  {
3297  $this->tpl->setCurrentBlock("option_r");
3298  $this->tpl->setVariable("OPTION_VALUE", $rel_id);
3299  $this->tpl->setVariable("OPTION_TEXT", $relation["short"]);
3300  if ($rel_id == $postvalues["r"])
3301  {
3302  $this->tpl->setVariable("OPTION_CHECKED", " selected=\"selected\"");
3303  }
3304  $this->tpl->parseCurrentBlock();
3305  }
3306  }
3307  $this->tpl->setCurrentBlock("select_relation");
3308  $this->tpl->setVariable("SELECT_RELATION", $this->lng->txt("step") . " 2: " . $this->lng->txt("select_relation"));
3309  $this->tpl->parseCurrentBlock();
3310  }
3311 
3312  if ($step > 2)
3313  {
3314  $variables =& $this->object->getVariables($postvalues["q"]);
3315  $question_type = $survey_questions[$postvalues["q"]]["type_tag"];
3316  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3317  SurveyQuestion::_includeClass($question_type);
3318  $question = new $question_type();
3319  $question->loadFromDb($postvalues["q"]);
3320  $select_value = $question->getPreconditionSelectValue($postvalues["v"]);
3321  $this->tpl->setCurrentBlock("select_value");
3322  $this->tpl->setVariable("SELECT_VALUE", $select_value);
3323  $this->tpl->parseCurrentBlock();
3324  }
3325 
3326  $this->tpl->setCurrentBlock("buttons");
3327  $this->tpl->setVariable("BTN_CONTINUE", $this->lng->txt("continue"));
3328  switch ($step)
3329  {
3330  case 1:
3331  $this->tpl->setVariable("COMMAND", "constraintStep2");
3332  $this->tpl->setVariable("COMMAND_BACK", "constraints");
3333  break;
3334  case 2:
3335  $this->tpl->setVariable("COMMAND", "constraintStep3");
3336  $this->tpl->setVariable("COMMAND_BACK", "constraintStep1");
3337  break;
3338  case 3:
3339  $this->tpl->setVariable("COMMAND", "constraintsAdd");
3340  $this->tpl->setVariable("COMMAND_BACK", "constraintStep2");
3341  break;
3342  }
3343  $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
3344  $this->tpl->parseCurrentBlock();
3345  $this->tpl->setCurrentBlock("adm_content");
3346  $title = "";
3347  if ($survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["questionblock_id"] > 0)
3348  {
3349  $title = $this->lng->txt("questionblock") . ": " . $survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["questionblock_title"];
3350  }
3351  else
3352  {
3353  $title = $this->lng->txt($survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["type_tag"]) . ": " . $survey_questions[$_SESSION["constraintstructure"][$_GET["start"]][0]]["title"];
3354  }
3355  $this->tpl->setVariable("CONSTRAINT_QUESTION_TEXT", $title);
3356  $this->tpl->setVariable("SELECT_PRIOR_QUESTION", $this->lng->txt("step") . " 1: " . $this->lng->txt("select_prior_question"));
3357  if (strlen($_GET["start"])) $this->ctrl->setParameter($this, "start", $_GET["start"]);
3358  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "constraintsAdd"));
3359  $this->tpl->parseCurrentBlock();
3360  }
3361 
3370  {
3371  if (strlen($_POST["v"]) == 0)
3372  {
3373  ilUtil::sendInfo($this->lng->txt("msg_enter_value_for_valid_constraint"));
3374  return $this->constraintStep3Object();
3375  }
3376  $survey_questions =& $this->object->getSurveyQuestions();
3377  $structure =& $_SESSION["constraintstructure"];
3378  $include_elements = $_SESSION["includeElements"];
3379  foreach ($include_elements as $elementCounter)
3380  {
3381  if (is_array($structure[$elementCounter]))
3382  {
3383  foreach ($structure[$elementCounter] as $key => $question_id)
3384  {
3385  if (strlen($_GET["preid"]))
3386  {
3387  $this->object->updateConstraint($question_id, $_POST["q"], $_POST["r"], $_POST["v"]);
3388  }
3389  else
3390  {
3391  $this->object->addConstraint($question_id, $_POST["q"], $_POST["r"], $_POST["v"]);
3392  }
3393  }
3394  }
3395  }
3396  unset($_SESSION["includeElements"]);
3397  unset($_SESSION["constraintstructure"]);
3398  $this->ctrl->redirect($this, "constraints");
3399  }
3400 
3409  {
3410  $survey_questions =& $this->object->getSurveyQuestions();
3411  $option_questions = array();
3412  if (strlen($_GET["precondition"]))
3413  {
3414  $pc = $this->object->getPrecondition($_GET["precondition"]);
3415  $postvalues = array(
3416  "q" => $pc["question_fi"],
3417  "r" => $pc["relation_id"],
3418  "v" => $pc["value"]
3419  );
3420  $this->ctrl->setParameter($this, "preid", $_GET["precondition"]);
3421  array_push($option_questions, array("question_id" => $pc["question_fi"], "title" => $survey_questions[$pc["question_fi"]]["title"], "type_tag" => $survey_questions[$pc["question_fi"]]["type_tag"]));
3422  $this->addConstraintForm(3, $postvalues, $survey_questions, $option_questions);
3423  }
3424  else
3425  {
3426  array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
3427  $this->addConstraintForm(3, $_POST, $survey_questions, $option_questions);
3428  }
3429  }
3430 
3439  {
3440  $survey_questions =& $this->object->getSurveyQuestions();
3441  $option_questions = array();
3442  array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
3443  $this->addConstraintForm(2, $_POST, $survey_questions, $option_questions);
3444  }
3445 
3454  {
3455  $survey_questions =& $this->object->getSurveyQuestions();
3456  $structure =& $_SESSION["constraintstructure"];
3457  $start = $_GET["start"];
3458  $option_questions = array();
3459  for ($i = 1; $i < $start; $i++)
3460  {
3461  if (is_array($structure[$i]))
3462  {
3463  foreach ($structure[$i] as $key => $question_id)
3464  {
3465  if ($survey_questions[$question_id]["usableForPrecondition"])
3466  {
3467  array_push($option_questions, array("question_id" => $survey_questions[$question_id]["question_id"], "title" => $survey_questions[$question_id]["title"], "type_tag" => $survey_questions[$question_id]["type_tag"]));
3468  }
3469  }
3470  }
3471  }
3472  if (count($option_questions) == 0)
3473  {
3474  unset($_SESSION["includeElements"]);
3475  unset($_SESSION["constraintstructure"]);
3476  ilUtil::sendInfo($this->lng->txt("constraints_no_nonessay_available"), true);
3477  $this->ctrl->redirect($this, "constraints");
3478  }
3479  $this->addConstraintForm(1, $_POST, $survey_questions, $option_questions);
3480  }
3481 
3490  {
3491  $survey_questions =& $this->object->getSurveyQuestions();
3492  $structure =& $_SESSION["constraintstructure"];
3493  foreach ($_POST as $key => $value)
3494  {
3495  if (preg_match("/^constraint_(\d+)_(\d+)/", $key, $matches))
3496  {
3497  foreach ($structure[$matches[1]] as $key => $question_id)
3498  {
3499  $this->object->deleteConstraint($matches[2], $question_id);
3500  }
3501  }
3502  }
3503 
3504  $this->ctrl->redirect($this, "constraints");
3505  }
3506 
3508  {
3509  $include_elements = $_POST["includeElements"];
3510  if ((!is_array($include_elements)) || (count($include_elements) == 0))
3511  {
3512  ilUtil::sendInfo($this->lng->txt("constraints_no_questions_or_questionblocks_selected"), true);
3513  $this->ctrl->redirect($this, "constraints");
3514  }
3515  else if (count($include_elements) >= 1)
3516  {
3517  $_SESSION["includeElements"] = $include_elements;
3518  sort($include_elements, SORT_NUMERIC);
3519  $_GET["start"] = $include_elements[0];
3520  $this->constraintStep1Object();
3521  }
3522  }
3523 
3525  {
3526  $_SESSION["includeElements"] = array($_GET["start"]);
3527  $this->ctrl->setParameter($this, "precondition", $_GET["precondition"]);
3528  $this->ctrl->setParameter($this, "start", $_GET["start"]);
3529  $this->ctrl->redirect($this, "constraintStep3");
3530  }
3531 
3540  {
3541  $this->handleWriteAccess();
3542 
3543  global $rbacsystem;
3544 
3545  $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
3546  $step = 0;
3547  if (array_key_exists("step", $_GET)) $step = $_GET["step"];
3548  switch ($step)
3549  {
3550  case 1:
3551  $this->constraintStep1Object();
3552  return;
3553  break;
3554  case 2:
3555  return;
3556  break;
3557  case 3:
3558  return;
3559  break;
3560  }
3561 
3562  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_constraints_list.html", "Modules/Survey");
3563  $survey_questions =& $this->object->getSurveyQuestions();
3564  $last_questionblock_title = "";
3565  $counter = 1;
3566  $hasPreconditions = FALSE;
3567  $structure = array();
3568  $colors = array("tblrow1", "tblrow2");
3569  foreach ($survey_questions as $question_id => $data)
3570  {
3571  $title = $data["title"];
3572  $show = true;
3573  if ($data["questionblock_id"] > 0)
3574  {
3575  $title = $data["questionblock_title"];
3576  $type = $this->lng->txt("questionblock");
3577  if (strcmp($title, $last_questionblock_title) != 0)
3578  {
3579  $last_questionblock_title = $title;
3580  $structure[$counter] = array();
3581  array_push($structure[$counter], $data["question_id"]);
3582  }
3583  else
3584  {
3585  array_push($structure[$counter-1], $data["question_id"]);
3586  $show = false;
3587  }
3588  }
3589  else
3590  {
3591  $structure[$counter] = array($data["question_id"]);
3592  $type = $this->lng->txt("question");
3593  }
3594  if ($show)
3595  {
3596  if ($counter == 1)
3597  {
3598  $this->tpl->setCurrentBlock("description");
3599  $this->tpl->setVariable("DESCRIPTION", $this->lng->txt("constraints_first_question_description"));
3600  $this->tpl->parseCurrentBlock();
3601  }
3602  else
3603  {
3604  $constraints =& $this->object->getConstraints($data["question_id"]);
3605  $rowcount = 0;
3606  if (count($constraints))
3607  {
3608  $hasPreconditions = TRUE;
3609  foreach ($constraints as $constraint)
3610  {
3611  $this->tpl->setCurrentBlock("constraint");
3612  $this->tpl->setVariable("SEQUENCE_ID", $counter);
3613  $this->tpl->setVariable("CONSTRAINT_ID", $constraint["id"]);
3614  $this->tpl->setVariable("CONSTRAINT_TEXT", $survey_questions[$constraint["question"]]["title"] . " " . $constraint["short"] . " " . $constraint["valueoutput"]);
3615  $this->tpl->setVariable("TEXT_EDIT_PRECONDITION", $this->lng->txt("edit"));
3616  $this->ctrl->setParameter($this, "precondition", $constraint["id"]);
3617  $this->ctrl->setParameter($this, "start", $counter);
3618  $this->tpl->setVariable("EDIT_PRECONDITION", $this->ctrl->getLinkTarget($this, "editPrecondition"));
3619  $this->ctrl->setParameter($this, "precondition", "");
3620  $this->ctrl->setParameter($this, "start", "");
3621  $this->tpl->parseCurrentBlock();
3622  }
3623  }
3624  }
3625  if ($counter != 1)
3626  {
3627  $this->tpl->setCurrentBlock("include_elements");
3628  $this->tpl->setVariable("QUESTION_NR", "$counter");
3629  $this->tpl->parseCurrentBlock();
3630  }
3631  $this->tpl->setCurrentBlock("constraint_section");
3632  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
3633  $this->tpl->setVariable("QUESTION_NR", "$counter");
3634  $this->tpl->setVariable("TITLE", "$title");
3635  $icontype = "question.gif";
3636  if ($data["questionblock_id"] > 0)
3637  {
3638  $icontype = "questionblock.gif";
3639  }
3640  $this->tpl->setVariable("TYPE", "$type: ");
3641  include_once "./Services/Utilities/classes/class.ilUtil.php";
3642  $this->tpl->setVariable("ICON_HREF", ilUtil::getImagePath($icontype, "Modules/Survey"));
3643  $this->tpl->setVariable("ICON_ALT", $type);
3644  $this->tpl->parseCurrentBlock();
3645  $counter++;
3646  }
3647  }
3648  if ($rbacsystem->checkAccess("write", $this->ref_id) and !$hasDatasets)
3649  {
3650  if ($hasPreconditions)
3651  {
3652  $this->tpl->setCurrentBlock("selectall_preconditions");
3653  $this->tpl->setVariable("SELECT_ALL_PRECONDITIONS", $this->lng->txt("select_all"));
3654  $this->tpl->parseCurrentBlock();
3655  }
3656  $this->tpl->setCurrentBlock("selectall");
3657  $counter++;
3658  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
3659  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
3660  $this->tpl->parseCurrentBlock();
3661 
3662  if ($hasPreconditions)
3663  {
3664  $this->tpl->setCurrentBlock("delete_button");
3665  $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
3666  include_once "./Services/Utilities/classes/class.ilUtil.php";
3667  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
3668  $this->tpl->parseCurrentBlock();
3669  }
3670 
3671  $this->tpl->setCurrentBlock("buttons");
3672  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
3673  $this->tpl->setVariable("BTN_CREATE_CONSTRAINTS", $this->lng->txt("constraint_add"));
3674  $this->tpl->parseCurrentBlock();
3675  }
3676  $this->tpl->setCurrentBlock("adm_content");
3677  $this->tpl->setVariable("CONSTRAINTS_INTRODUCTION", $this->lng->txt("constraints_introduction"));
3678  $this->tpl->setVariable("DEFINED_PRECONDITIONS", $this->lng->txt("existing_constraints"));
3679  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "constraints"));
3680  $this->tpl->setVariable("CONSTRAINTS_HEADER", $this->lng->txt("constraints_list_of_entities"));
3681  $this->tpl->parseCurrentBlock();
3682  $_SESSION["constraintstructure"] = $structure;
3683  if ($hasDatasets)
3684  {
3685  ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning"));
3686  }
3687  }
3688 
3694  function infoScreenObject()
3695  {
3696  $this->ctrl->setCmd("showSummary");
3697  $this->ctrl->setCmdClass("ilinfoscreengui");
3698  $this->infoScreen();
3699  }
3700 
3701  function setNewTemplate()
3702  {
3703  global $tpl;
3704  $tpl = new ilTemplate("tpl.il_svy_svy_main.html", TRUE, TRUE, "Modules/Survey");
3705  // load style sheet depending on user's settings
3706  $location_stylesheet = ilUtil::getStyleSheetLocation();
3707  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
3708  $tpl->setVariable("LOCATION_JAVASCRIPT",dirname($location_stylesheet));
3709  }
3710 
3714  function infoScreen()
3715  {
3716  global $ilAccess;
3717  global $ilUser;
3718 
3719  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
3720  {
3721  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
3722  }
3723 
3724  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
3725  $info = new ilInfoScreenGUI($this);
3726  include_once "./Modules/Survey/classes/class.ilSurveyExecutionGUI.php";
3727  $output_gui =& new ilSurveyExecutionGUI($this->object);
3728  $info->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
3729  $info->enablePrivateNotes();
3730  $anonymize_key = NULL;
3731  if ($this->object->getAnonymize() == 1)
3732  {
3733  if ($_SESSION["anonymous_id"])
3734  {
3735  $anonymize_key = $_SESSION["anonymous_id"];
3736  }
3737  else if ($_POST["anonymous_id"])
3738  {
3739  $anonymize_key = $_POST["anonymous_id"];
3740  }
3741  }
3742  $canStart = $this->object->canStartSurvey($anonymize_key);
3743  $showButtons = $canStart["result"];
3744  if (!$showButtons) ilUtil::sendInfo(implode("<br />", $canStart["messages"]));
3745 
3746  if ($showButtons)
3747  {
3748  // output of start/resume buttons for personalized surveys
3749  if (!$this->object->getAnonymize())
3750  {
3751  $survey_started = $this->object->isSurveyStarted($ilUser->getId(), "");
3752  // Anonymous User tries to start a personalized survey
3753  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
3754  {
3755  ilUtil::sendInfo($this->lng->txt("anonymous_with_personalized_survey"));
3756  }
3757  else
3758  {
3759  if ($survey_started === 1)
3760  {
3761  ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
3762  }
3763  elseif ($survey_started === 0)
3764  {
3765  $info->addFormButton("resume", $this->lng->txt("resume_survey"));
3766  }
3767  elseif ($survey_started === FALSE)
3768  {
3769  $info->addFormButton("start", $this->lng->txt("start_survey"));
3770  }
3771  }
3772  }
3773  // output of start/resume buttons for anonymized surveys
3774  else if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
3775  {
3776  if (($_SESSION["AccountId"] == ANONYMOUS_USER_ID) && (strlen($_POST["anonymous_id"]) == 0) && (strlen($_SESSION["anonymous_id"]) == 0))
3777  {
3778  $info->setFormAction($this->ctrl->getFormAction($this, "infoScreen"));
3779  $info->addSection($this->lng->txt("anonymization"));
3780  $info->addProperty("", $this->lng->txt("anonymize_anonymous_introduction"));
3781  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_id"), "anonymous_id", "", 8, "infoScreen", $this->lng->txt("submit"));
3782  }
3783  else
3784  {
3785  if (strlen($_POST["anonymous_id"]) > 0)
3786  {
3787  if (!$this->object->checkSurveyCode($_POST["anonymous_id"]))
3788  {
3789  ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used"));
3790  }
3791  else
3792  {
3793  $anonymize_key = $_POST["anonymous_id"];
3794  }
3795  }
3796  else if (strlen($_SESSION["anonymous_id"]) > 0)
3797  {
3798  if (!$this->object->checkSurveyCode($_SESSION["anonymous_id"]))
3799  {
3800  ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used"));
3801  }
3802  else
3803  {
3804  $anonymize_key = $_SESSION["anonymous_id"];
3805  }
3806  }
3807  else
3808  {
3809  // registered users do not need to know that there is an anonymous key. The data is anonymized automatically
3810  $anonymize_key = $this->object->getUserAccessCode($ilUser->getId());
3811  if (!strlen($anonymize_key))
3812  {
3813  $anonymize_key = $this->object->createNewAccessCode();
3814  $this->object->saveUserAccessCode($ilUser->getId(), $anonymize_key);
3815  }
3816  }
3817  $info->addHiddenElement("anonymous_id", $anonymize_key);
3818  $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymize_key);
3819  if ($survey_started === 1)
3820  {
3821  ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
3822  }
3823  elseif ($survey_started === 0)
3824  {
3825  $info->addFormButton("resume", $this->lng->txt("resume_survey"));
3826  }
3827  elseif ($survey_started === FALSE)
3828  {
3829  $info->addFormButton("start", $this->lng->txt("start_survey"));
3830  }
3831  }
3832  }
3833  else
3834  {
3835  // free access
3836  $survey_started = $this->object->isSurveyStarted($ilUser->getId(), "");
3837  if ($survey_started === 1)
3838  {
3839  ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
3840  }
3841  elseif ($survey_started === 0)
3842  {
3843  $info->addFormButton("resume", $this->lng->txt("resume_survey"));
3844  }
3845  elseif ($survey_started === FALSE)
3846  {
3847  $info->addFormButton("start", $this->lng->txt("start_survey"));
3848  }
3849  }
3850  }
3851 
3852  if (strlen($this->object->getIntroduction()))
3853  {
3854  $introduction = $this->object->getIntroduction();
3855  $info->addSection($this->lng->txt("introduction"));
3856  $info->addProperty("", $this->object->prepareTextareaOutput($introduction));
3857  }
3858 
3859  $info->addSection($this->lng->txt("svy_general_properties"));
3860  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
3861  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
3862  switch ($this->object->getAnonymize())
3863  {
3864  case ANONYMIZE_OFF:
3865  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("anonymize_personalized"));
3866  break;
3867  case ANONYMIZE_ON:
3868  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
3869  {
3870  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_with_code"));
3871  }
3872  else
3873  {
3874  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_registered_user"));
3875  }
3876  break;
3877  case ANONYMIZE_FREEACCESS:
3878  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_without_code"));
3879  break;
3880  }
3881  include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
3882  if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
3883  {
3884  $info->addProperty($this->lng->txt("evaluation_access"), $this->lng->txt("evaluation_access_info"));
3885  }
3886  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
3887  $this->ctrl->forwardCommand($info);
3888  }
3889 
3895  function printViewObject()
3896  {
3897  global $ilias;
3898 
3899  $this->questionsSubtabs("printview");
3900  $template = new ilTemplate("tpl.il_svy_svy_printview.html", TRUE, TRUE, "Modules/Survey");
3901 
3902  if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
3903  {
3904  $this->ctrl->setParameter($this, "pdf", "1");
3905  $template->setCurrentBlock("pdf_export");
3906  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "printView"));
3907  $this->ctrl->setParameter($this, "pdf", "");
3908  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3909  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
3910  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
3911  $template->parseCurrentBlock();
3912  }
3913  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
3914  $template->setVariable("PRINT_URL", "javascript:window.print();");
3915 
3916  $pages =& $this->object->getSurveyPages();
3917  foreach ($pages as $page)
3918  {
3919  if (count($page) > 0)
3920  {
3921  foreach ($page as $question)
3922  {
3923  $questionGUI = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]);
3924  if (is_object($questionGUI))
3925  {
3926  if (strlen($question["heading"]))
3927  {
3928  $template->setCurrentBlock("textblock");
3929  $template->setVariable("TEXTBLOCK", $question["heading"]);
3930  $template->parseCurrentBlock();
3931  }
3932  $template->setCurrentBlock("question");
3933  $template->setVariable("QUESTION_DATA", $questionGUI->getPrintView($this->object->getShowQuestionTitles(), $question["questionblock_show_questiontext"], $this->object->getSurveyId()));
3934  $template->parseCurrentBlock();
3935  }
3936  }
3937  if (count($page) > 1)
3938  {
3939  $template->setCurrentBlock("page");
3940  $template->setVariable("BLOCKTITLE", $page[0]["questionblock_title"]);
3941  $template->parseCurrentBlock();
3942  }
3943  else
3944  {
3945  $template->setCurrentBlock("page");
3946  $template->parseCurrentBlock();
3947  }
3948  }
3949  }
3950  $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print");
3951  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3952  {
3953  $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
3954  $printbody->setVariable("TITLE", sprintf($this->lng->txt("tst_result_user_name"), $uname));
3955  $printbody->setVariable("ADM_CONTENT", $template->get());
3956  $printoutput = $printbody->get();
3957  $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput);
3958  $fo = $this->object->processPrintoutput2FO($printoutput);
3959  $this->object->deliverPDFfromFO($fo);
3960  }
3961  else
3962  {
3963  $this->tpl->setVariable("ADM_CONTENT", $template->get());
3964  }
3965  }
3966 
3967  function addLocatorItems()
3968  {
3969  global $ilLocator;
3970  switch ($this->ctrl->getCmd())
3971  {
3972  case "next":
3973  case "previous":
3974  case "start":
3975  case "resume":
3976  case "redirectQuestion":
3977  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3978  break;
3979  case "evaluation":
3980  case "checkEvaluationAccess":
3981  case "evaluationdetails":
3982  case "evaluationuser":
3983  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"), "", $_GET["ref_id"]);
3984  break;
3985  case "create":
3986  case "save":
3987  case "cancel":
3988  case "importFile":
3989  case "cloneAll":
3990  break;
3991  case "infoScreen":
3992  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3993  break;
3994  default:
3995  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
3996  break;
3997  }
3998  }
3999 
4007  function questionsSubtabs($a_cmd)
4008  {
4009  $questions = ($a_cmd == 'questions') ? true : false;
4010  $printview = ($a_cmd == 'printview') ? true : false;
4011 
4012  $this->tabs_gui->addSubTabTarget("survey_question_editor", $this->ctrl->getLinkTarget($this, "questions"),
4013  "", "", "", $questions);
4014  $this->tabs_gui->addSubTabTarget("print_view", $this->ctrl->getLinkTarget($this, "printView"),
4015  "", "", "", $printview);
4016  }
4024  function setEvalSubtabs()
4025  {
4026  global $ilTabs;
4027  global $ilAccess;
4028 
4029  $ilTabs->addSubTabTarget(
4030  "svy_eval_cumulated",
4031  $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"),
4032  array("evaluation", "checkEvaluationAccess"),
4033  ""
4034  );
4035 
4036  $ilTabs->addSubTabTarget(
4037  "svy_eval_detail",
4038  $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluationdetails"),
4039  array("evaluationdetails"),
4040  ""
4041  );
4042 
4043  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
4044  {
4045  $ilTabs->addSubTabTarget(
4046  "svy_eval_user",
4047  $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluationuser"),
4048  array("evaluationuser"),
4049  ""
4050  );
4051  }
4052  }
4053 
4055  {
4056  global $ilAccess;
4057  global $ilTabs;
4058 
4059  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4060  {
4061  $ilTabs->setBackTarget($this->lng->txt("menubacktosurvey"), $this->ctrl->getLinkTarget($this, "questions"));
4062  $ilTabs->addTarget("browse_for_questions",
4063  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
4064  array("browseForQuestions",
4065  "filterQuestions", "resetFilterQuestions", "changeDatatype", "insertQuestions",),
4066  "", ""
4067  );
4068  }
4069  }
4070 
4076  function getTabs(&$tabs_gui)
4077  {
4078  global $ilAccess, $ilUser;
4079 
4080  switch ($this->ctrl->getCmd())
4081  {
4082  case "browseForQuestions":
4083  case "insertQuestions":
4084  case "filterQuestions":
4085  case "resetFilterQuestions":
4086  case "changeDatatype":
4087 
4088  case "start":
4089  case "resume":
4090  case "next":
4091  case "previous":
4092  case "redirectQuestion":
4093  return;
4094  break;
4095  case "evaluation":
4096  case "checkEvaluationAccess":
4097  case "evaluationdetails":
4098  case "evaluationuser":
4099  $this->setEvalSubtabs();
4100  break;
4101  }
4102 
4103  // questions
4104  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4105  {
4106  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
4107  ? true
4108  : false;
4109 
4110  $tabs_gui->addTarget("survey_questions",
4111  $this->ctrl->getLinkTarget($this,'questions'),
4112  array("questions", "browseForQuestions", "createQuestion",
4113  "filterQuestions", "resetFilterQuestions", "changeDatatype", "insertQuestions",
4114  "removeQuestions", "cancelRemoveQuestions", "confirmRemoveQuestions",
4115  "defineQuestionblock", "saveDefineQuestionblock", "cancelDefineQuestionblock",
4116  "unfoldQuestionblock", "moveQuestions",
4117  "insertQuestionsBefore", "insertQuestionsAfter", "saveObligatory",
4118  "addHeading", "saveHeading", "cancelHeading", "editHeading",
4119  "confirmRemoveHeading", "cancelRemoveHeading", "printView"),
4120  "", "", $force_active);
4121  }
4122 
4123  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
4124  {
4125  $tabs_gui->addTarget("info_short",
4126  $this->ctrl->getLinkTarget($this,'infoScreen'),
4127  array("infoScreen", "showSummary"));
4128  }
4129 
4130  // properties
4131  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4132  {
4133  $force_active = ($this->ctrl->getCmd() == "")
4134  ? true
4135  : false;
4136  $tabs_gui->addTarget("properties",
4137  $this->ctrl->getLinkTarget($this,'properties'),
4138  array("properties", "save", "cancel"), "",
4139  "", $force_active);
4140  }
4141 
4142  // questions
4143  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4144  {
4145  // meta data
4146  $tabs_gui->addTarget("meta_data",
4147  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
4148  "", "ilmdeditorgui");
4149 
4150  // constraints
4151  $tabs_gui->addTarget("constraints",
4152  $this->ctrl->getLinkTarget($this, "constraints"),
4153  array("constraints", "constraintStep1", "constraintStep2",
4154  "constraintStep3", "constraintsAdd", "createConstraints",
4155  "editPrecondition"),
4156  "");
4157  }
4158  if (($ilAccess->checkAccess("write", "", $this->ref_id)) || ($ilAccess->checkAccess("invite", "", $this->ref_id)))
4159  {
4160  // invite
4161  $tabs_gui->addTarget("invitation",
4162  $this->ctrl->getLinkTarget($this, "invite"),
4163  array("invite", "saveInvitationStatus",
4164  "searchInvitation", "inviteUserGroup",
4165  "disinviteUserGroup"),
4166  "");
4167  }
4168  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4169  {
4170  // export
4171  $tabs_gui->addTarget("export",
4172  $this->ctrl->getLinkTarget($this,'export'),
4173  array("export", "createExportFile", "confirmDeleteExportFile",
4174  "downloadExportFile"),
4175  ""
4176  );
4177 
4178  // maintenance
4179  $tabs_gui->addTarget("maintenance",
4180  $this->ctrl->getLinkTarget($this,'maintenance'),
4181  array("maintenance", "deleteAllUserData"),
4182  "");
4183 
4184  if ($this->object->getAnonymize() == 1)
4185  {
4186  // code
4187  $tabs_gui->addTarget("codes",
4188  $this->ctrl->getLinkTarget($this,'codes'),
4189  array("codes", "createSurveyCodes", "setCodeLanguage", "deleteCodes", "exportCodes"),
4190  "");
4191  }
4192  }
4193 
4194  include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
4195  if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
4196  {
4197  // evaluation
4198  $tabs_gui->addTarget("svy_evaluation",
4199  $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"),
4200  array("evaluation", "checkEvaluationAccess", "evaluationdetails",
4201  "evaluationuser"),
4202  "");
4203  }
4204 
4205  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
4206  {
4207  // permissions
4208  $tabs_gui->addTarget("perm_settings",
4209  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
4210  }
4211  }
4212 
4218  function _goto($a_target, $a_access_code = "")
4219  {
4220  global $ilAccess, $ilErr, $lng;
4221  if ($ilAccess->checkAccess("read", "", $a_target))
4222  {
4223  include_once "./Services/Utilities/classes/class.ilUtil.php";
4224  if (strlen($a_access_code))
4225  {
4226  $_SESSION["anonymous_id"] = $a_access_code;
4227  $_GET["baseClass"] = "ilObjSurveyGUI";
4228  $_GET["cmd"] = "infoScreen";
4229  $_GET["ref_id"] = $a_target;
4230  include("ilias.php");
4231  exit;
4232  }
4233  else
4234  {
4235  $_GET["baseClass"] = "ilObjSurveyGUI";
4236  $_GET["cmd"] = "infoScreen";
4237  $_GET["ref_id"] = $a_target;
4238  include("ilias.php");
4239  exit;
4240  }
4241  }
4242  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4243  {
4244  $_GET["cmd"] = "frameset";
4245  $_GET["target"] = "";
4246  $_GET["ref_id"] = ROOT_FOLDER_ID;
4247  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
4248  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4249  include("repository.php");
4250  exit;
4251  }
4252 
4253  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4254  }
4255 
4256 } // END class.ilObjSurveyGUI
4257 ?>