ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSurveyGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Services/Object/classes/class.ilObjectGUI.php";
5 
23 {
24  public function __construct()
25  {
26  global $lng, $ilCtrl;
27 
28  $this->type = "svy";
29  $lng->loadLanguageModule("survey");
30  $this->ctrl = $ilCtrl;
31  $this->ctrl->saveParameter($this, "ref_id");
32 
33  parent::__construct("", (int)$_GET["ref_id"], true, false);
34  }
35 
36  public function executeCommand()
37  {
38  global $ilAccess, $ilNavigationHistory, $ilErr, $ilTabs;
39 
40  $this->external_rater_360 = false;
41  if(!$this->creation_mode &&
42  $this->object->get360Mode() &&
43  $_SESSION["anonymous_id"][$this->object->getId()] &&
44  ilObjSurvey::validateExternalRaterCode($this->object->getRefId(),
45  $_SESSION["anonymous_id"][$this->object->getId()]))
46  {
47  $this->external_rater_360 = true;
48  }
49 
50  if(!$this->external_rater_360)
51  {
52  if (!$ilAccess->checkAccess("read", "", $this->ref_id) &&
53  !$ilAccess->checkAccess("visible", "", $this->ref_id))
54  {
55  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
56  }
57 
58  // add entry to navigation history
59  if (!$this->getCreationMode() &&
60  $ilAccess->checkAccess("read", "", $this->ref_id))
61  {
62  $this->ctrl->setParameterByClass("ilobjsurveygui", "ref_id", $this->ref_id);
63  $link = $this->ctrl->getLinkTargetByClass("ilobjsurveygui", "");
64  $ilNavigationHistory->addItem($this->ref_id, $link, "svy");
65  }
66  }
67 
68  $cmd = $this->ctrl->getCmd("properties");
69 
70  // workaround for bug #6288, needs better solution
71  if ($cmd == "saveTags")
72  {
73  $this->ctrl->setCmdClass("ilinfoscreengui");
74  }
75 
76  // deep link from repository - "redirect" to page view
77  if(!$this->ctrl->getCmdClass() && $cmd == "questionsrepo")
78  {
79  $_REQUEST["pgov"] = 1;
80  $this->ctrl->setCmd("questions");
81  $this->ctrl->setCmdClass("ilsurveyeditorgui");
82  }
83 
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  switch($next_class)
90  {
91  case "ilinfoscreengui":
92  $this->addHeaderAction();
93  $this->infoScreen(); // forwards command
94  break;
95 
96  case 'ilmdeditorgui':
97  $this->handleWriteAccess();
98  $ilTabs->activateTab("meta_data");
99  $this->addHeaderAction();
100  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
101  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
102  $md_gui->addObserver($this->object,'MDUpdateListener','General');
103 
104  $this->ctrl->forwardCommand($md_gui);
105  break;
106 
107  case "ilsurveyevaluationgui":
108  $ilTabs->activateTab("svy_results");
109  $this->addHeaderAction();
110  include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
111  $eval_gui = new ilSurveyEvaluationGUI($this->object);
112  $this->ctrl->forwardCommand($eval_gui);
113  break;
114 
115  case "ilsurveyexecutiongui":
116  $ilTabs->clearTargets();
117  include_once("./Modules/Survey/classes/class.ilSurveyExecutionGUI.php");
118  $exec_gui = new ilSurveyExecutionGUI($this->object);
119  $this->ctrl->forwardCommand($exec_gui);
120  break;
121 
122  case 'ilpermissiongui':
123  $ilTabs->activateTab("perm_settings");
124  $this->addHeaderAction();
125  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
126  $perm_gui =& new ilPermissionGUI($this);
127  $this->ctrl->forwardCommand($perm_gui);
128  break;
129 
130  case 'ilobjectcopygui':
131  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
132  $cp = new ilObjectCopyGUI($this);
133  $cp->setType('svy');
134  $this->ctrl->forwardCommand($cp);
135  break;
136 
137  case "ilcommonactiondispatchergui":
138  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
140  $this->ctrl->forwardCommand($gui);
141  break;
142 
143  // 360, skill service
144  case 'ilsurveyskillgui':
145  $ilTabs->activateTab("survey_competences");
146  include_once("./Modules/Survey/classes/class.ilSurveySkillGUI.php");
147  $gui = new ilSurveySkillGUI($this->object);
148  $this->ctrl->forwardCommand($gui);
149  break;
150 
151  case 'ilsurveyskilldeterminationgui':
152  $ilTabs->activateTab("maintenance");
153  include_once("./Modules/Survey/classes/class.ilSurveySkillDeterminationGUI.php");
154  $gui = new ilSurveySkillDeterminationGUI($this->object);
155  $this->ctrl->forwardCommand($gui);
156  break;
157 
158  case 'ilsurveyeditorgui':
159  $this->handleWriteAccess();
160  $ilTabs->activateTab("survey_questions");
161  include_once("./Modules/Survey/classes/class.ilSurveyEditorGUI.php");
162  $gui = new ilSurveyEditorGUI($this);
163  $this->ctrl->forwardCommand($gui);
164  break;
165 
166  case 'ilsurveyconstraintsgui':
167  $this->handleWriteAccess();
168  $ilTabs->activateTab("constraints");
169  include_once("./Modules/Survey/classes/class.ilSurveyConstraintsGUI.php");
170  $gui = new ilSurveyConstraintsGUI($this);
171  $this->ctrl->forwardCommand($gui);
172  break;
173 
174  case 'ilsurveyparticipantsgui':
175  if(!$this->object->get360Mode())
176  {
177  $ilTabs->activateTab("maintenance");
178  }
179  else
180  {
181  $ilTabs->activateTab("survey_360_appraisees");
182  }
183  include_once("./Modules/Survey/classes/class.ilSurveyParticipantsGUI.php");
184  $gui = new ilSurveyParticipantsGUI($this);
185  $this->ctrl->forwardCommand($gui);
186  break;
187 
188  default:
189  $this->addHeaderAction();
190  $cmd.= "Object";
191  $this->$cmd();
192  break;
193  }
194 
195  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
196  $this->getCreationMode() != true)
197  {
198  $this->tpl->show();
199  }
200  }
201 
209  public function evaluationObject()
210  {
211  include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
212  $eval_gui = new ilSurveyEvaluationGUI($this->object);
213  $this->ctrl->setCmdClass(get_class($eval_gui));
214  $this->ctrl->redirect($eval_gui, "evaluation");
215  }
216 
217  protected function addDidacticTemplateOptions(array &$a_options)
218  {
219  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
221  if($templates)
222  {
223  foreach($templates as $item)
224  {
225  $a_options["svytpl_".$item["id"]] = array($item["title"],
226  nl2br(trim($item["description"])));
227  }
228  }
229 
230  // JF, 2013-06-10
231  $a_options["svy360_1"] = array($this->lng->txt("survey_360_mode"),
232  $this->lng->txt("survey_360_mode_info"));
233  }
234 
239  function afterSave(ilObject $a_new_object)
240  {
241  $tpl = $this->getDidacticTemplateVar("svytpl");
242  if($tpl)
243  {
244  $a_new_object->applySettingsTemplate($tpl);
245  }
246 
247  $a_new_object->set360Mode((bool)$this->getDidacticTemplateVar("svy360"));
248  if($a_new_object->get360Mode())
249  {
250  $a_new_object->setAnonymize(ilObjSurvey::ANONYMIZE_CODE_ALL);
251  $a_new_object->setEvaluationAccess(ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS);
252  }
253  $a_new_object->saveToDB();
254 
255  // always send a message
256  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
257  ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=".
258  $a_new_object->getRefId()."&cmd=properties");
259  }
260 
266  function getTabs(&$tabs_gui)
267  {
268  global $ilAccess, $ilUser, $ilHelp;
269 
270  if($this->object instanceof ilObjSurveyQuestionPool)
271  {
272  return true;
273  }
274 
275  $ilHelp->setScreenIdComponent("svy");
276 
277  $hidden_tabs = array();
278  $template = $this->object->getTemplate();
279  if($template)
280  {
281  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
282  $template = new ilSettingsTemplate($template);
283  $hidden_tabs = $template->getHiddenTabs();
284  }
285 
286  if ($ilAccess->checkAccess("write", "", $this->ref_id))
287  {
288  $tabs_gui->addTab("survey_questions",
289  $this->lng->txt("survey_questions"),
290  $this->ctrl->getLinkTargetByClass(array("ilsurveyeditorgui", "ilsurveypagegui"), "renderPage"));
291  }
292 
293  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
294  {
295  $tabs_gui->addTab("info_short",
296  $this->lng->txt("info_short"),
297  $this->ctrl->getLinkTarget($this,'infoScreen'));
298  }
299 
300  // properties
301  if ($ilAccess->checkAccess("write", "", $this->ref_id))
302  {
303  $tabs_gui->addTab("settings",
304  $this->lng->txt("settings"),
305  $this->ctrl->getLinkTarget($this,'properties'));
306  }
307  else if ($ilAccess->checkAccess("read", "", $this->ref_id))
308  {
309  if($this->object->get360Mode() &&
310  $this->object->get360SelfRaters() &&
311  $this->object->isAppraisee($ilUser->getId()) &&
312  !$this->object->isAppraiseeClosed($ilUser->getId()))
313  {
314  $tabs_gui->addTab("survey_360_edit_raters",
315  $this->lng->txt("survey_360_edit_raters"),
316  $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui','editRaters'));
317 
318  // :TODO: mail to raters
319  }
320  }
321 
322  // questions
323  if ($ilAccess->checkAccess("write", "", $this->ref_id) &&
324  !in_array("constraints", $hidden_tabs) &&
325  !$this->object->get360Mode())
326  {
327  // constraints
328  $tabs_gui->addTab("constraints",
329  $this->lng->txt("constraints"),
330  $this->ctrl->getLinkTargetByClass("ilsurveyconstraintsgui", "constraints"));
331  }
332 
333  if ($ilAccess->checkAccess("write", "", $this->ref_id))
334  {
335  // 360°
336  if($this->object->get360Mode())
337  {
338  // 360 mode + competence service
339  include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
340  $skmg_set = new ilSkillManagementSettings();
341  if ($this->object->get360SkillService() && $skmg_set->isActivated())
342  {
343  $tabs_gui->addTab("survey_competences",
344  $this->lng->txt("survey_competences"),
345  $this->ctrl->getLinkTargetByClass("ilsurveyskillgui", "listQuestionAssignment"));
346  }
347 
348  $tabs_gui->addTab("survey_360_appraisees",
349  $this->lng->txt("survey_360_appraisees"),
350  $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui', 'listAppraisees'));
351  }
352  else
353  {
354  // maintenance
355  $tabs_gui->addTab("maintenance",
356  $this->lng->txt("maintenance"),
357  $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui', 'maintenance'));
358  }
359  }
360 
361  include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
362  if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
363  ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
364  {
365  // evaluation
366  $tabs_gui->addTab("svy_results",
367  $this->lng->txt("svy_results"),
368  $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", ""));
369  }
370 
371  if ($ilAccess->checkAccess("write", "", $this->ref_id))
372  {
373  if(!in_array("meta_data", $hidden_tabs))
374  {
375  // meta data
376  $tabs_gui->addTab("meta_data",
377  $this->lng->txt("meta_data"),
378  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'));
379  }
380 
381  if(!in_array("export", $hidden_tabs))
382  {
383  // export
384  $tabs_gui->addTab("export",
385  $this->lng->txt("export"),
386  $this->ctrl->getLinkTarget($this,'export'));
387  }
388  }
389 
390  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
391  {
392  // permissions
393  $tabs_gui->addTab("perm_settings",
394  $this->lng->txt("perm_settings"),
395  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
396  }
397  }
398 
406  public function handleWriteAccess()
407  {
408  global $ilAccess;
409  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
410  {
411  // allow only write access
412  ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), TRUE);
413  $this->ctrl->redirect($this, "infoScreen");
414  }
415  }
416 
417 
418  //
419  // SETTINGS
420  //
421 
430  {
431  global $rbacsystem;
432 
433  $form = $this->initPropertiesForm();
434  if ($form->checkInput())
435  {
436  $valid = true;
437 
438  if(!$this->object->get360Mode())
439  {
440  if($form->getInput("tut"))
441  {
442  // check if given "tutors" have write permission
443  $tut_ids =array();
444  $tut_logins = $form->getInput("tut_ids");
445  foreach($tut_logins as $tut_login)
446  {
447  $tut_id = ilObjUser::_lookupId($tut_login);
448  if($tut_id && $rbacsystem->checkAccessOfUser($tut_id, "write", $this->object->getRefId()))
449  {
450  $tut_ids[] = $tut_id;
451  }
452  }
453  if(!$tut_ids)
454  {
455  $tut_ids = $form->getItemByPostVar("tut_ids");
456  $tut_ids->setAlert($this->lng->txt("survey_notification_tutor_recipients_invalid"));
457  $valid = false;
458  }
459  }
460  }
461 
462  if($valid)
463  {
464  if(!$this->object->get360Mode())
465  {
466  if($form->getInput("rmd"))
467  {
468  $rmd_start = $form->getInput("rmd_start");
469  $rmd_start = $rmd_start["date"];
470  $rmd_end = null;
471  if($form->getInput("rmd_end_tgl"))
472  {
473  $rmd_end = $form->getInput("rmd_end");
474  $rmd_end = $rmd_end["date"];
475  if($rmd_start > $rmd_end)
476  {
477  $tmp = $rmd_start;
478  $rmd_start = $rmd_end;
479  $rmd_end = $tmp;
480  }
481  $rmd_end = new ilDate($rmd_end, IL_CAL_DATE);
482  }
483  $rmd_start = new ilDate($rmd_start, IL_CAL_DATE);
484 
485  $this->object->setReminderStatus(true);
486  $this->object->setReminderStart($rmd_start);
487  $this->object->setReminderEnd($rmd_end);
488  $this->object->setReminderFrequency($form->getInput("rmd_freq"));
489  $this->object->setReminderTarget($form->getInput("rmd_grp"));
490  }
491  else
492  {
493  $this->object->setReminderStatus(false);
494  }
495 
496  if($form->getInput("tut"))
497  {
498  $this->object->setTutorNotificationStatus(true);
499  $this->object->setTutorNotificationRecipients($tut_ids); // see above
500  $this->object->setTutorNotificationTarget($form->getInput("tut_grp"));
501  }
502  else
503  {
504  $this->object->setTutorNotificationStatus(false);
505  }
506  }
507 
508  // #10055
509  if ($_POST['online'] && count($this->object->questions) == 0)
510  {
511  $_POST['online'] = null;
512  ilUtil::sendFailure($this->lng->txt("cannot_switch_to_online_no_questions"), true);
513  }
514 
515  $template_settings = null;
516  $template = $this->object->getTemplate();
517  if($template)
518  {
519  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
520  $template = new ilSettingsTemplate($template);
521  $template_settings = $template->getSettings();
522  }
523 
524  include_once 'Services/MetaData/classes/class.ilMD.php';
525  $md_obj =& new ilMD($this->object->getId(), 0, "svy");
526  $md_section = $md_obj->getGeneral();
527 
528  // title
529  $md_section->setTitle(ilUtil::stripSlashes($_POST['title']));
530  $md_section->update();
531 
532  // Description
533  $md_desc_ids = $md_section->getDescriptionIds();
534  if($md_desc_ids)
535  {
536  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
537  $md_desc->setDescription(ilUtil::stripSlashes($_POST['description']));
538  $md_desc->update();
539  }
540 
541  // both are saved in object, too
542  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
543  $this->object->setDescription(ilUtil::stripSlashes($_POST['description']));
544  $this->object->update();
545 
546  $this->object->setStatus($_POST['online']);
547 
548  // activation
549  if($_POST["access_type"])
550  {
551  $this->object->setActivationLimited(true);
552  $this->object->setActivationVisibility($_POST["access_visiblity"]);
553 
554  $period = $form->getItemByPostVar("access_period");
555  $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
556  $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
557  }
558  else
559  {
560  $this->object->setActivationLimited(false);
561  }
562 
563 
564  if(!$template_settings["enabled_start_date"]["hide"])
565  {
566  if ($_POST["enabled_start_date"])
567  {
568  $this->object->setStartDateAndTime($_POST["start_date"]['date'], $_POST["start_date"]['time']);
569  }
570  else
571  {
572  $this->object->setStartDate(null);
573  }
574  }
575 
576  if(!$template_settings["enabled_end_date"]["hide"])
577  {
578  if ($_POST["enabled_end_date"])
579  {
580  $this->object->setEndDateAndTime($_POST["end_date"]['date'], $_POST["end_date"]['time']);
581  }
582  else
583  {
584  $this->object->setEndDate(null);
585  }
586  }
587 
588 
589  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
590  $introduction = $_POST["introduction"];
591  $this->object->setIntroduction($introduction);
592  $outro = $_POST["outro"];
593  $this->object->setOutro($outro);
594 
595  if(!$template_settings["show_question_titles"]["hide"])
596  {
597  $this->object->setShowQuestionTitles($_POST["show_question_titles"]);
598  }
599 
600  if(!$template_settings["use_pool"]["hide"])
601  {
602  $this->object->setPoolUsage($_POST["use_pool"]);
603  }
604 
605  $this->object->setMailNotification($_POST['mailnotification']);
606  $this->object->setMailAddresses($_POST['mailaddresses']);
607  $this->object->setMailParticipantData($_POST['mailparticipantdata']);
608 
609  // 360°
610  if($this->object->get360Mode())
611  {
612  $this->object->set360SelfEvaluation((bool)$_POST["self_eval"]);
613  $this->object->set360SelfAppraisee((bool)$_POST["self_appr"]);
614  $this->object->set360SelfRaters((bool)$_POST["self_rate"]);
615  $this->object->set360Results((int)$_POST["ts_res"]);;
616  $this->object->set360SkillService((int)$_POST["skill_service"]);
617  }
618  else
619  {
620  $this->object->setEvaluationAccess($_POST["evaluation_access"]);
621 
622  $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
623  if (!$hasDatasets)
624  {
625  $anon_map = array('personalized' => ilObjSurvey::ANONYMIZE_OFF,
626  'anonymize_with_code' => ilObjSurvey::ANONYMIZE_ON,
627  'anonymize_without_code' => ilObjSurvey::ANONYMIZE_FREEACCESS);
628  if(array_key_exists($_POST["anonymization_options"], $anon_map))
629  {
630  $this->object->setAnonymize($anon_map[$_POST["anonymization_options"]]);
631  if (strcmp($_POST['anonymization_options'], 'anonymize_with_code') == 0) $anonymize = ilObjSurvey::ANONYMIZE_ON;
632  if (strcmp($_POST['anonymization_options'], 'anonymize_with_code_all') == 0) $anonymize = ilObjSurvey::ANONYMIZE_CODE_ALL;
633  }
634  }
635  }
636 
637  $this->object->saveToDb();
638 
639  if (strcmp($_SESSION["info"], "") != 0)
640  {
641  ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("settings_saved"), true);
642  }
643  else
644  {
645  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
646  }
647  $this->ctrl->redirect($this, "properties");
648  }
649  }
650 
651  $form->setValuesByPost();
652  $this->propertiesObject($form);
653  }
654 
661  {
662  $template_settings = $hide_rte_switch = null;
663  $template = $this->object->getTemplate();
664  if($template)
665  {
666  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
667  $template = new ilSettingsTemplate($template);
668 
669  $template_settings = $template->getSettings();
670  $hide_rte_switch = $template_settings["rte_switch"]["hide"];
671  }
672 
673  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
674  $form = new ilPropertyFormGUI();
675  $form->setFormAction($this->ctrl->getFormAction($this));
676  $form->setTableWidth("100%");
677  $form->setId("survey_properties");
678 
679  // general properties
680  $header = new ilFormSectionHeaderGUI();
681  $header->setTitle($this->lng->txt("settings"));
682  $form->addItem($header);
683 
684  // title & description (meta data)
685 
686  include_once 'Services/MetaData/classes/class.ilMD.php';
687  $md_obj = new ilMD($this->object->getId(), 0, "svy");
688  $md_section = $md_obj->getGeneral();
689 
690  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
691  $title->setRequired(true);
692  $title->setValue($md_section->getTitle());
693  $form->addItem($title);
694 
695  $ids = $md_section->getDescriptionIds();
696  if($ids)
697  {
698  $desc_obj = $md_section->getDescription(array_pop($ids));
699 
700  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
701  $desc->setCols(50);
702  $desc->setRows(4);
703  $desc->setValue($desc_obj->getDescription());
704  $form->addItem($desc);
705  }
706 
707  // anonymization
708  if(!$this->object->get360Mode())
709  {
710  $anonymization_options = new ilRadioGroupInputGUI($this->lng->txt("survey_auth_mode"), "anonymization_options");
711  $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
712  if ($hasDatasets)
713  {
714  $anonymization_options->setDisabled(true);
715  }
716  $anonymization_options->addOption(new ilCheckboxOption($this->lng->txt("anonymize_personalized"),
717  'personalized', ''));
718  $anonymization_options->addOption(new ilCheckboxOption(
719  $this->lng->txt("anonymize_without_code"), 'anonymize_without_code', ''));
720  $anonymization_options->addOption(new ilCheckboxOption(
721  $this->lng->txt("anonymize_with_code"), 'anonymize_with_code', ''));
722  if(!$this->object->getAnonymize())
723  {
724  $anonymization_options->setValue('personalized');
725  }
726  else
727  {
728  $anonymization_options->setValue(($this->object->isAccessibleWithoutCode()) ?
729  'anonymize_without_code' : 'anonymize_with_code');
730  }
731  $anonymization_options->setInfo($this->lng->txt("anonymize_survey_description"));
732  $form->addItem($anonymization_options);
733  }
734  // 360°
735  else
736  {
737  $self_eval = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_evaluation"), "self_eval");
738  $self_eval->setChecked($this->object->get360SelfEvaluation());
739  $form->addItem($self_eval);
740 
741  $self_rate = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_raters"), "self_rate");
742  $self_rate->setChecked($this->object->get360SelfRaters());
743  $form->addItem($self_rate);
744 
745  $self_appr = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_appraisee"), "self_appr");
746  $self_appr->setChecked($this->object->get360SelfAppraisee());
747  $form->addItem($self_appr);
748  }
749 
750  // pool usage
751  $pool_usage = new ilRadioGroupInputGUI($this->lng->txt("survey_question_pool_usage"), "use_pool");
752  $opt = new ilRadioOption($this->lng->txt("survey_question_pool_usage_active"), 1);
753  $opt->setInfo($this->lng->txt("survey_question_pool_usage_active_info"));
754  $pool_usage->addOption($opt);
755  $opt = new ilRadioOption($this->lng->txt("survey_question_pool_usage_inactive"), 0);
756  $opt->setInfo($this->lng->txt("survey_question_pool_usage_inactive_info"));
757  $pool_usage->addOption($opt);
758  $pool_usage->setValue($this->object->getPoolUsage());
759  $form->addItem($pool_usage);
760 
761 
762  // activation
763 
764  include_once "Services/Object/classes/class.ilObjectActivation.php";
765  $this->lng->loadLanguageModule('rep');
766 
768  $section->setTitle($this->lng->txt('rep_activation_availability'));
769  $form->addItem($section);
770 
771  // additional info only with multiple references
772  $act_obj_info = $act_ref_info = "";
773  if(sizeof(ilObject::_getAllReferences($this->object->getId())) > 1)
774  {
775  $act_obj_info = ' '.$this->lng->txt('rep_activation_online_object_info');
776  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
777  }
778 
779  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'),'online');
780  $online->setInfo($this->lng->txt('svy_activation_online_info').$act_obj_info);
781  $online->setChecked($this->object->isOnline());
782  $form->addItem($online);
783 
784  $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'),'access_type');
785  // $act_type->setInfo($this->lng->txt('svy_availability_until_info'));
786  $act_type->setChecked($this->object->isActivationLimited());
787 
788  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
789  include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
790  $dur = new ilDateDurationInputGUI($this->lng->txt('rep_time_period'), "access_period");
791  $dur->setShowTime(true);
792  $date = $this->object->getActivationStartDate();
793  $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
794  $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
795  $date = $this->object->getActivationEndDate();
796  $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
797  $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
798  $act_type->addSubItem($dur);
799 
800  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
801  $visible->setInfo($this->lng->txt('svy_activation_limited_visibility_info'));
802  $visible->setChecked($this->object->getActivationVisibility());
803  $act_type->addSubItem($visible);
804 
805  $form->addItem($act_type);
806 
807 
808  // enable start date
809  $start = $this->object->getStartDate();
810  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("start_date"), "enabled_start_date");
811  $enablestartingtime->setValue(1);
812  // $enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
813  $enablestartingtime->setChecked($start);
814  // start date
815  $startingtime = new ilDateTimeInputGUI('', 'start_date');
816  $startingtime->setShowDate(true);
817  $startingtime->setShowTime(true);
818  if ($start)
819  {
820  $startingtime->setDate(new ilDate($start, IL_CAL_TIMESTAMP));
821  }
822  $enablestartingtime->addSubItem($startingtime);
823  $form->addItem($enablestartingtime);
824 
825  // enable end date
826  $end = $this->object->getEndDate();
827  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("end_date"), "enabled_end_date");
828  $enableendingtime->setValue(1);
829  // $enableendingtime->setOptionTitle($this->lng->txt("enabled"));
830  $enableendingtime->setChecked($end);
831  // end date
832  $endingtime = new ilDateTimeInputGUI('', 'end_date');
833  $endingtime->setShowDate(true);
834  $endingtime->setShowTime(true);
835  if ($end)
836  {
837  $endingtime->setDate(new ilDate($end, IL_CAL_TIMESTAMP));
838  }
839  $enableendingtime->addSubItem($endingtime);
840  $form->addItem($enableendingtime);
841 
842 
843  // presentation properties
844  $info = new ilFormSectionHeaderGUI();
845  $info->setTitle($this->lng->txt("svy_presentation_properties"));
846  $form->addItem($info);
847 
848  // show question titles
849  $show_question_titles = new ilCheckboxInputGUI($this->lng->txt("svy_show_questiontitles"), "show_question_titles");
850  $show_question_titles->setValue(1);
851  $show_question_titles->setChecked($this->object->getShowQuestionTitles());
852  $form->addItem($show_question_titles);
853 
854  // introduction
855  $intro = new ilTextAreaInputGUI($this->lng->txt("introduction"), "introduction");
856  $intro->setValue($this->object->prepareTextareaOutput($this->object->getIntroduction()));
857  $intro->setRows(10);
858  $intro->setCols(80);
859  $intro->setUseRte(TRUE);
860  $intro->setInfo($this->lng->txt("survey_introduction_info"));
861  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
862  $intro->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
863  $intro->addPlugin("latex");
864  $intro->addButton("latex");
865  $intro->addButton("pastelatex");
866  $intro->setRTESupport($this->object->getId(), "svy", "survey", null, $hide_rte_switch);
867  $form->addItem($intro);
868 
869  // final statement
870  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("outro"), "outro");
871  $finalstatement->setValue($this->object->prepareTextareaOutput($this->object->getOutro()));
872  $finalstatement->setRows(10);
873  $finalstatement->setCols(80);
874  $finalstatement->setUseRte(TRUE);
875  $finalstatement->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
876  $finalstatement->addPlugin("latex");
877  $finalstatement->addButton("latex");
878  $finalstatement->addButton("pastelatex");
879  $finalstatement->setRTESupport($this->object->getId(), "svy", "survey", null, $hide_rte_switch);
880  $form->addItem($finalstatement);
881 
882 
883  // results properties
885  $results->setTitle($this->lng->txt("results"));
886  $form->addItem($results);
887 
888  // evaluation access
889  if(!$this->object->get360Mode())
890  {
891  $evaluation_access = new ilRadioGroupInputGUI($this->lng->txt('evaluation_access'), "evaluation_access");
892  $evaluation_access->setInfo($this->lng->txt('evaluation_access_description'));
893  $evaluation_access->addOption(new ilCheckboxOption($this->lng->txt("evaluation_access_off"), ilObjSurvey::EVALUATION_ACCESS_OFF, ''));
894  $evaluation_access->addOption(new ilCheckboxOption($this->lng->txt("evaluation_access_all"), ilObjSurvey::EVALUATION_ACCESS_ALL, ''));
895  $evaluation_access->addOption(new ilCheckboxOption($this->lng->txt("evaluation_access_participants"), ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS, ''));
896  $evaluation_access->setValue($this->object->getEvaluationAccess());
897  $form->addItem($evaluation_access);
898  }
899  // 360°
900  else
901  {
902  $ts_results = new ilRadioGroupInputGUI($this->lng->txt("survey_360_results"), "ts_res");
903  $ts_results->setValue($this->object->get360Results());
904  $ts_results->addOption(new ilRadioOption($this->lng->txt("survey_360_results_none"), ilObjSurvey::RESULTS_360_NONE));
905  $ts_results->addOption(new ilRadioOption($this->lng->txt("survey_360_results_own"), ilObjSurvey::RESULTS_360_OWN));
906  $ts_results->addOption(new ilRadioOption($this->lng->txt("survey_360_results_all"), ilObjSurvey::RESULTS_360_ALL));
907  $form->addItem($ts_results);
908  }
909 
910  // mail notification
911  $mailnotification = new ilCheckboxInputGUI($this->lng->txt("mailnotification"), "mailnotification");
912  // $mailnotification->setOptionTitle($this->lng->txt("activate"));
913  $mailnotification->setInfo($this->lng->txt("svy_result_mail_notification_info")); // #11762
914  $mailnotification->setValue(1);
915  $mailnotification->setChecked($this->object->getMailNotification());
916 
917  // addresses
918  $mailaddresses = new ilTextInputGUI($this->lng->txt("mailaddresses"), "mailaddresses");
919  $mailaddresses->setValue($this->object->getMailAddresses());
920  $mailaddresses->setSize(80);
921  $mailaddresses->setInfo($this->lng->txt('mailaddresses_info'));
922  $mailaddresses->setRequired(true);
923 
924  // participant data
925  $participantdata = new ilTextAreaInputGUI($this->lng->txt("mailparticipantdata"), "mailparticipantdata");
926  $participantdata->setValue($this->object->getMailParticipantData());
927  $participantdata->setRows(6);
928  $participantdata->setCols(80);
929  $participantdata->setUseRte(false);
930  $participantdata->setInfo($this->lng->txt('mailparticipantdata_info'));
931 
932  // #12755 - because of privacy concerns we restrict user data to a minimum
933  $placeholders = array(
934  "FIRST_NAME" => "firstname",
935  "LAST_NAME" => "lastname",
936  "LOGIN" => "login"
937  );
938  $txt = array();
939  foreach($placeholders as $placeholder => $caption)
940  {
941  $txt[] = "[".strtoupper($placeholder)."]: ".$this->lng->txt($caption);
942  }
943  $txt = implode("<br />", $txt);
944  $participantdatainfo = new ilNonEditableValueGUI($this->lng->txt("mailparticipantdata_placeholder"), "", true);
945  $participantdatainfo->setValue($txt);
946 
947  $mailnotification->addSubItem($mailaddresses);
948  $mailnotification->addSubItem($participantdata);
949  $mailnotification->addSubItem($participantdatainfo);
950  $form->addItem($mailnotification);
951 
952  // reminder/notification - currently not available for 360°
953  if(!$this->object->get360Mode())
954  {
955  // parent course?
956  global $tree;
957  $has_parent = $tree->checkForParentType($this->object->getRefId(), "grp");
958  if(!$has_parent)
959  {
960  $has_parent = $tree->checkForParentType($this->object->getRefId(), "crs");
961  }
962  $num_inv = sizeof($this->object->getInvitedUsers());
963 
964  $ntf = new ilFormSectionHeaderGUI();
965  $ntf->setTitle($this->lng->txt("survey_notification_settings"));
966  $form->addItem($ntf);
967 
968  // reminder
969  $rmd = new ilCheckboxInputGUI($this->lng->txt("survey_reminder_setting"), "rmd");
970  $rmd->setChecked($this->object->getReminderStatus());
971  $form->addItem($rmd);
972 
973  $rmd_start = new ilDateTimeInputGUI($this->lng->txt("survey_reminder_start"), "rmd_start");
974  $rmd_start->setRequired(true);
975  $start = $this->object->getReminderStart();
976  if($start)
977  {
978  $rmd_start->setDate($start);
979  }
980  $rmd->addSubItem($rmd_start);
981 
982  $end = $this->object->getReminderEnd();
983  $rmd_end = new ilDateTimeInputGUI($this->lng->txt("survey_reminder_end"), "rmd_end");
984  $rmd_end->enableDateActivation("", "rmd_end_tgl", (bool)$end);
985  if($end)
986  {
987  $rmd_end->setDate($end);
988  }
989  $rmd->addSubItem($rmd_end);
990 
991  $rmd_freq = new ilNumberInputGUI($this->lng->txt("survey_reminder_frequency"), "rmd_freq");
992  $rmd_freq->setRequired(true);
993  $rmd_freq->setSize(3);
994  $rmd_freq->setSuffix($this->lng->txt("survey_reminder_frequency_days"));
995  $rmd_freq->setValue($this->object->getReminderFrequency());
996  $rmd_freq->setMinValue(1);
997  $rmd->addSubItem($rmd_freq);
998 
999  $rmd_grp = new ilRadioGroupInputGUI($this->lng->txt("survey_notification_target_group"), "rmd_grp");
1000  $rmd_grp->setRequired(true);
1001  $rmd_grp->setValue($this->object->getReminderTarget());
1002  $rmd->addSubItem($rmd_grp);
1003 
1004  $rmd_grp_crs = new ilRadioOption($this->lng->txt("survey_notification_target_group_parent_course"),
1006  if(!$has_parent)
1007  {
1008  $rmd_grp_crs->setInfo($this->lng->txt("survey_notification_target_group_parent_course_inactive"));
1009  }
1010  $rmd_grp->addOption($rmd_grp_crs);
1011 
1012  $rmd_grp_inv = new ilRadioOption($this->lng->txt("survey_notification_target_group_invited"),
1014  $rmd_grp_inv->setInfo(sprintf($this->lng->txt("survey_notification_target_group_invited_info"), $num_inv));
1015  $rmd_grp->addOption($rmd_grp_inv);
1016 
1017 
1018  // notification
1019  $tut = new ilCheckboxInputGUI($this->lng->txt("survey_notification_tutor_setting"), "tut");
1020  $tut->setChecked($this->object->getTutorNotificationStatus());
1021  $form->addItem($tut);
1022 
1023  $tut_logins = array();
1024  $tuts = $this->object->getTutorNotificationRecipients();
1025  if($tuts)
1026  {
1027  foreach($tuts as $tut_id)
1028  {
1029  $tmp = ilObjUser::_lookupName($tut_id);
1030  if($tmp["login"])
1031  {
1032  $tut_logins[] = $tmp["login"];
1033  }
1034  }
1035  }
1036  $tut_ids = new ilTextInputGUI($this->lng->txt("survey_notification_tutor_recipients"), "tut_ids");
1037  $tut_ids->setDataSource($this->ctrl->getLinkTarget($this, "doAutoComplete", "", true));
1038  $tut_ids->setRequired(true);
1039  $tut_ids->setMulti(true);
1040  $tut_ids->setMultiValues($tut_logins);
1041  $tut_ids->setValue(array_shift($tut_logins));
1042  $tut->addSubItem($tut_ids);
1043 
1044  $tut_grp = new ilRadioGroupInputGUI($this->lng->txt("survey_notification_target_group"), "tut_grp");
1045  $tut_grp->setRequired(true);
1046  $tut_grp->setValue($this->object->getTutorNotificationTarget());
1047  $tut->addSubItem($tut_grp);
1048 
1049  $tut_grp_crs = new ilRadioOption($this->lng->txt("survey_notification_target_group_parent_course"),
1051  if(!$has_parent)
1052  {
1053  $tut_grp_crs->setInfo($this->lng->txt("survey_notification_target_group_parent_course_inactive"));
1054  }
1055  $tut_grp->addOption($tut_grp_crs);
1056 
1057  $tut_grp_inv = new ilRadioOption($this->lng->txt("survey_notification_target_group_invited"),
1059  $tut_grp_inv->setInfo(sprintf($this->lng->txt("survey_notification_target_group_invited_info"), $num_inv));
1060  $tut_grp->addOption($tut_grp_inv);
1061  }
1062 
1063  // competence service activation for 360 mode
1064  include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
1065  $skmg_set = new ilSkillManagementSettings();
1066  if($this->object->get360Mode() && $skmg_set->isActivated())
1067  {
1068  $other = new ilFormSectionHeaderGUI();
1069  $other->setTitle($this->lng->txt("other"));
1070  $form->addItem($other);
1071 
1072  $skill_service = new ilCheckboxInputGUI($this->lng->txt("survey_activate_skill_service"), "skill_service");
1073  $skill_service->setChecked($this->object->get360SkillService());
1074  $form->addItem($skill_service);
1075  }
1076 
1077  $form->addCommandButton("saveProperties", $this->lng->txt("save"));
1078 
1079  // remove items when using template
1080  if($template_settings)
1081  {
1082  foreach($template_settings as $id => $item)
1083  {
1084  if($item["hide"])
1085  {
1086  $form->removeItemByPostVar($id);
1087  }
1088  }
1089  }
1090 
1091  return $form;
1092  }
1093 
1099  function propertiesObject(ilPropertyFormGUI $a_form = null)
1100  {
1101  global $ilAccess, $ilTabs, $ilHelp;
1102 
1103  $this->handleWriteAccess();
1104 
1105  $ilTabs->activateTab("settings");
1106 
1107 
1108  if ($this->object->get360Mode())
1109  {
1110  $ilHelp->setScreenId("settings_360");
1111  }
1112 
1113  if(!$a_form)
1114  {
1115  $a_form = $this->initPropertiesForm();
1116  }
1117 
1118  // using template?
1119  $message = "";
1120  if($this->object->getTemplate())
1121  {
1122  $link = $this->ctrl->getLinkTarget($this, "confirmResetTemplate");
1123  $link = "<a href=\"".$link."\">".$this->lng->txt("survey_using_template_link")."</a>";
1124  $message = "<div style=\"margin-top:10px\">".
1125  $this->tpl->getMessageHTML(sprintf($this->lng->txt("survey_using_template"),
1126  ilSettingsTemplate::lookupTitle($this->object->getTemplate()), $link), "info"). // #10651
1127  "</div>";
1128  }
1129 
1130  $this->tpl->setContent($a_form->getHTML().$message);
1131  }
1132 
1134  {
1135  $fields = array('login','firstname','lastname','email');
1136 
1137  include_once './Services/User/classes/class.ilUserAutoComplete.php';
1138  $auto = new ilUserAutoComplete();
1139  $auto->setSearchFields($fields);
1140  $auto->setResultField('login');
1141  $auto->enableFieldSearchableCheck(true);
1142  echo $auto->getList(ilUtil::stripSlashes($_REQUEST['term']));
1143  exit();
1144  }
1145 
1150  {
1151  ilUtil::sendQuestion($this->lng->txt("survey_confirm_template_reset"));
1152  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_confirm_resettemplate.html", "Modules/Survey");
1153  $this->tpl->setCurrentBlock("adm_content");
1154  $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
1155  $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
1156  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "resetTemplateObject"));
1157  $this->tpl->parseCurrentBlock();
1158  }
1159 
1164  {
1165  $this->object->setTemplate(null);
1166  $this->object->saveToDB();
1167 
1168  ilUtil::sendSuccess($this->lng->txt("survey_template_reset"), true);
1169  $this->ctrl->redirect($this, "properties");
1170  }
1171 
1172 
1173 
1174  //
1175  // IMPORT/EXPORT
1176  //
1177 
1178  protected function initImportForm($a_new_type)
1179  {
1180  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1181  $form = new ilPropertyFormGUI();
1182  $form->setTarget("_top");
1183  $form->setFormAction($this->ctrl->getFormAction($this));
1184  $form->setTitle($this->lng->txt("import_svy"));
1185 
1186  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1187  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1188  $fi->setSuffixes(array("zip"));
1189  $fi->setRequired(true);
1190  $form->addItem($fi);
1191 
1192  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
1193  $svy = new ilObjSurvey();
1194  $questionspools = $svy->getAvailableQuestionpools(true, true, true);
1195 
1196  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool_short"), "spl");
1197  $pools->setOptions(array(""=>$this->lng->txt("dont_use_questionpool")) + $questionspools);
1198  $pools->setRequired(false);
1199  $form->addItem($pools);
1200 
1201  $form->addCommandButton("importFile", $this->lng->txt("import"));
1202  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1203 
1204  return $form;
1205  }
1206 
1210  function importFileObject()
1211  {
1212  global $tpl, $ilErr;
1213 
1214  $parent_id = $_GET["ref_id"];
1215  $new_type = $_REQUEST["new_type"];
1216 
1217  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1218  if (!$this->checkPermissionBool("create", "", $new_type))
1219  {
1220  $ilErr->raiseError($this->lng->txt("no_create_permission"));
1221  }
1222 
1223  $this->lng->loadLanguageModule($new_type);
1224  $this->ctrl->setParameter($this, "new_type", $new_type);
1225 
1226  $form = $this->initImportForm($new_type);
1227  if ($form->checkInput())
1228  {
1229  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
1230  $newObj = new ilObjSurvey();
1231  $newObj->setType($new_type);
1232  $newObj->setTitle("dummy");
1233  $newObj->setDescription("dummy");
1234  $newObj->create(true);
1235  $this->putObjectInTree($newObj);
1236 
1237  // copy uploaded file to import directory
1238  $error = $newObj->importObject($_FILES["importfile"], $form->getInput("spl"));
1239  if (strlen($error))
1240  {
1241  $newObj->delete();
1242  $this->ilias->raiseError($error, $this->ilias->error_obj->MESSAGE);
1243  return;
1244  }
1245 
1246  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
1247  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1248  "&baseClass=ilObjSurveyGUI");
1249 
1250  // using template?
1251  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1252  $templates = ilSettingsTemplate::getAllSettingsTemplates("svy");
1253  if($templates)
1254  {
1255  global $tpl;
1256  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery.js");
1257  // $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery-ui-min.js");
1258 
1259  $this->tpl->setCurrentBlock("template_option");
1260  $this->tpl->setVariable("VAL_TEMPLATE_OPTION", "");
1261  $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $this->lng->txt("none"));
1262  $this->tpl->parseCurrentBlock();
1263 
1264  foreach($templates as $item)
1265  {
1266  $this->tpl->setCurrentBlock("template_option");
1267  $this->tpl->setVariable("VAL_TEMPLATE_OPTION", $item["id"]);
1268  $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $item["title"]);
1269  $this->tpl->parseCurrentBlock();
1270 
1271  $desc = str_replace("\n", "", nl2br($item["description"]));
1272  $desc = str_replace("\r", "", $desc);
1273 
1274  $this->tpl->setCurrentBlock("js_data");
1275  $this->tpl->setVariable("JS_DATA_ID", $item["id"]);
1276  $this->tpl->setVariable("JS_DATA_TEXT", $desc);
1277  $this->tpl->parseCurrentBlock();
1278  }
1279 
1280  $this->tpl->setCurrentBlock("templates");
1281  $this->tpl->setVariable("TXT_TEMPLATE", $this->lng->txt("svy_settings_template"));
1282  $this->tpl->parseCurrentBlock();
1283  }
1284  }
1285 
1286  // display form to correct errors
1287  $form->setValuesByPost();
1288  $tpl->setContent($form->getHtml());
1289  }
1290 
1291  /*
1292  * list all export files
1293  */
1294  public function exportObject()
1295  {
1296  global $ilTabs;
1297 
1298  $this->handleWriteAccess();
1299  $ilTabs->activateTab("export");
1300 
1301  $export_dir = $this->object->getExportDirectory();
1302  $export_files = $this->object->getExportFiles($export_dir);
1303  $data = array();
1304  if(count($export_files) > 0)
1305  {
1306  foreach($export_files as $exp_file)
1307  {
1308  $file_arr = explode("__", $exp_file);
1309  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
1310  array_push($data, array(
1311  'file' => $exp_file,
1312  'size' => filesize($export_dir."/".$exp_file),
1313  'date' => $date->get(IL_CAL_DATETIME)
1314  ));
1315  }
1316  }
1317 
1318  include_once "./Modules/Survey/classes/tables/class.ilSurveyExportTableGUI.php";
1319  $table_gui = new ilSurveyExportTableGUI($this, 'export');
1320  $table_gui->setData($data);
1321  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1322  }
1323 
1327  public function createExportFileObject()
1328  {
1329  $this->handleWriteAccess();
1330  include_once("./Modules/Survey/classes/class.ilSurveyExport.php");
1331  $survey_exp = new ilSurveyExport($this->object);
1332  $survey_exp->buildExportFile();
1333  $this->ctrl->redirect($this, "export");
1334  }
1335 
1339  public function downloadExportFileObject()
1340  {
1341  if(!isset($_POST["file"]))
1342  {
1343  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1344  $this->ctrl->redirect($this, "export");
1345  }
1346 
1347  if (count($_POST["file"]) > 1)
1348  {
1349  ilUtil::sendFailure($this->lng->txt("select_max_one_item"), true);
1350  $this->ctrl->redirect($this, "export");
1351  }
1352 
1353  $file = basename($_POST["file"][0]);
1354 
1355  $export_dir = $this->object->getExportDirectory();
1356  include_once "./Services/Utilities/classes/class.ilUtil.php";
1357  ilUtil::deliverFile($export_dir."/".$file, $file);
1358  }
1359 
1364  {
1365  global $ilTabs;
1366 
1367  $this->handleWriteAccess();
1368  $ilTabs->activateTab("export");
1369 
1370  if (!isset($_POST["file"]))
1371  {
1372  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1373  $this->ctrl->redirect($this, "export");
1374  }
1375 
1376  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1377 
1378  $export_dir = $this->object->getExportDirectory();
1379  $export_files = $this->object->getExportFiles($export_dir);
1380  $data = array();
1381  if (count($_POST["file"]) > 0)
1382  {
1383  foreach ($_POST["file"] as $exp_file)
1384  {
1385  $file_arr = explode("__", $exp_file);
1386  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
1387  array_push($data, array(
1388  'file' => $exp_file,
1389  'size' => filesize($export_dir."/".$exp_file),
1390  'date' => $date->get(IL_CAL_DATETIME)
1391  ));
1392  }
1393  }
1394 
1395  include_once "./Modules/Survey/classes/tables/class.ilSurveyExportTableGUI.php";
1396  $table_gui = new ilSurveyExportTableGUI($this, 'export', true);
1397  $table_gui->setData($data);
1398  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1399  }
1400 
1401 
1406  {
1407  ilUtil::sendInfo($this->lng->txt('msg_cancel'), true);
1408  $this->ctrl->redirect($this, "export");
1409  }
1410 
1411 
1415  public function deleteExportFileObject()
1416  {
1417  $export_dir = $this->object->getExportDirectory();
1418  foreach ($_POST["file"] as $file)
1419  {
1420  $file = basename($file);
1421 
1422  $exp_file = $export_dir."/".$file;
1423  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
1424  if (@is_file($exp_file))
1425  {
1426  unlink($exp_file);
1427  }
1428  if (@is_dir($exp_dir))
1429  {
1430  include_once "./Services/Utilities/classes/class.ilUtil.php";
1431  ilUtil::delDir($exp_dir);
1432  }
1433  }
1434  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
1435  $this->ctrl->redirect($this, "export");
1436  }
1437 
1438 
1439  //
1440  // INFOSCREEN
1441  //
1442 
1448  function infoScreenObject()
1449  {
1450  $this->ctrl->setCmd("showSummary");
1451  $this->ctrl->setCmdClass("ilinfoscreengui");
1452  $this->infoScreen();
1453  }
1454 
1458  function infoScreen()
1459  {
1460  global $ilAccess, $ilTabs, $ilUser, $ilToolbar;
1461 
1462  if (!$this->external_rater_360 &&
1463  !$ilAccess->checkAccess("visible", "", $this->ref_id))
1464  {
1465  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1466  }
1467 
1468  $ilTabs->activateTab("info_short");
1469 
1470  include_once "./Modules/Survey/classes/class.ilSurveyExecutionGUI.php";
1471  $output_gui =& new ilSurveyExecutionGUI($this->object);
1472 
1473  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1474  $info = new ilInfoScreenGUI($this);
1475  $info->enablePrivateNotes();
1476 
1477  // "active" survey?
1478  $canStart = $this->object->canStartSurvey(null, $this->external_rater_360);
1479 
1480  $showButtons = $canStart["result"];
1481  if (!$showButtons)
1482  {
1483  if($canStart["edit_settings"] &&
1484  $ilAccess->checkAccess("write", "", $this->ref_id))
1485  {
1486  $canStart["messages"][] = "<a href=\"".$this->ctrl->getLinkTarget($this, "properties")."\">&raquo; ".
1487  $this->lng->txt("survey_edit_settings")."</a>";
1488  }
1489  ilUtil::sendInfo(implode("<br />", $canStart["messages"]));
1490  }
1491 
1492  $big_button = false;
1493  if ($showButtons)
1494  {
1495  // closing survey?
1496  $is_appraisee = false;
1497  if($this->object->get360Mode() &&
1498  $this->object->isAppraisee($ilUser->getId()))
1499  {
1500  $info->addSection($this->lng->txt("survey_360_appraisee_info"));
1501 
1502  $appr_data = $this->object->getAppraiseesData();
1503  $appr_data = $appr_data[$ilUser->getId()];
1504  $info->addProperty($this->lng->txt("survey_360_raters_status_info"), $appr_data["finished"]);
1505 
1506  if(!$appr_data["closed"])
1507  {
1508  $close_button_360 = '<div>'.
1509  '<a class="submit" href="'.$this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "confirmappraiseeclose").'">'.
1510  $this->lng->txt("survey_360_appraisee_close_action").'</a></div>';
1511 
1512  $txt = "survey_360_appraisee_close_action_info";
1513  if($this->object->get360SkillService())
1514  {
1515  $txt .= "_skill";
1516  }
1517  $info->addProperty($this->lng->txt("status"),
1518  $close_button_360.$this->lng->txt($txt));
1519  }
1520  else
1521  {
1523 
1524  $dt = new ilDateTime($appr_data["closed"], IL_CAL_UNIX);
1525  $info->addProperty($this->lng->txt("status"),
1526  sprintf($this->lng->txt("survey_360_appraisee_close_action_status"),
1528  }
1529 
1530  $is_appraisee = true;
1531  }
1532 
1533 
1534  // handle code
1535 
1536  // validate incoming
1537  $code_input = false;
1538  $anonymous_code = $_POST["anonymous_id"];
1539  if ($anonymous_code)
1540  {
1541  $code_input = true;
1542  // if(!$this->object->isUnusedCode($anonymous_code, $ilUser->getId()))
1543  if(!$this->object->checkSurveyCode($anonymous_code)) // #15031 - valid as long survey is not finished
1544  {
1545  $anonymous_code = null;
1546  }
1547  else
1548  {
1549  // #15860
1550  $this->object->bindSurveyCodeToUser($ilUser->getId(), $anonymous_code);
1551  }
1552  }
1553  if ($anonymous_code)
1554  {
1555  $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code;
1556  }
1557  else
1558  {
1559  $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
1560  if($anonymous_code)
1561  {
1562  $code_input = true;
1563  }
1564  }
1565 
1566  // try to find code for current (registered) user from existing run
1567  if($this->object->getAnonymize() && !$anonymous_code)
1568  {
1569  $anonymous_code = $this->object->findCodeForUser($ilUser->getId());
1570  }
1571 
1572  // get existing runs for current user, might generate code
1573  $participant_status = $this->object->getUserSurveyExecutionStatus($anonymous_code);
1574  if($participant_status)
1575  {
1576  $anonymous_code = $participant_status["code"];
1577  $participant_status = $participant_status["runs"];
1578  }
1579 
1580  // (final) check for proper anonymous code
1581  if(!$this->object->isAccessibleWithoutCode() &&
1582  !$is_appraisee &&
1583  $code_input && // #11346
1584  (!$anonymous_code || !$this->object->isAnonymousKey($anonymous_code)))
1585  {
1586  $anonymous_code = null;
1587  ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used"));
1588  }
1589 
1590  // :TODO: really save in session?
1591  $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code;
1592 
1593  // code is mandatory and not given yet
1594  if(!$is_appraisee &&
1595  !$anonymous_code &&
1596  !$this->object->isAccessibleWithoutCode())
1597  {
1598  $info->setFormAction($this->ctrl->getFormAction($this, "infoScreen"));
1599  $info->addSection($this->lng->txt("anonymization"));
1600  $info->addProperty("", $this->lng->txt("anonymize_anonymous_introduction"));
1601  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_id"), "anonymous_id", "", 8, "infoScreen", $this->lng->txt("submit"), true);
1602  }
1603  else
1604  {
1605  // trunk/default
1606  if(!$this->object->get360Mode())
1607  {
1608  if($anonymous_code)
1609  {
1610  $info->addHiddenElement("anonymous_id", $anonymous_code);
1611  }
1612 
1613  $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymous_code);
1614  if ($survey_started === 1)
1615  {
1616  ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
1617  }
1618  elseif ($survey_started === 0)
1619  {
1620  $big_button = array("resume", $this->lng->txt("resume_survey"));
1621  }
1622  elseif ($survey_started === FALSE)
1623  {
1624  $big_button = array("start", $this->lng->txt("start_survey"));
1625  }
1626  }
1627  // 360°
1628  else
1629  {
1630  $appr_ids = array();
1631 
1632  // use given code (if proper external one)
1633  if($anonymous_code)
1634  {
1635  $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
1636  if($anonymous_id)
1637  {
1638  $appr_ids = $this->object->getAppraiseesToRate(0, $anonymous_id);
1639  }
1640  }
1641 
1642  // registered user
1643  // if an auto-code was generated, we still have to check for the original user id
1644  if(!$appr_ids && $ilUser->getId() != ANONYMOUS_USER_ID)
1645  {
1646  $appr_ids = $this->object->getAppraiseesToRate($ilUser->getId());
1647  }
1648 
1649  if(sizeof($appr_ids))
1650  {
1651  // map existing runs to appraisees
1652  $active_appraisees = array();
1653  if($participant_status)
1654  {
1655  foreach($participant_status as $item)
1656  {
1657  $active_appraisees[$item["appr_id"]] = $item["finished"];
1658  }
1659  }
1660 
1661  $list = array();
1662 
1663  foreach($appr_ids as $appr_id)
1664  {
1665  if($this->object->isAppraiseeClosed($appr_id))
1666  {
1667  // closed
1668  $list[$appr_id] = $this->lng->txt("survey_360_appraisee_is_closed");
1669  }
1670  else if(array_key_exists($appr_id, $active_appraisees))
1671  {
1672  // already done
1673  if($active_appraisees[$appr_id])
1674  {
1675  $list[$appr_id] = $this->lng->txt("already_completed_survey");
1676  }
1677  // resume
1678  else
1679  {
1680  $list[$appr_id] = array("resume", $this->lng->txt("resume_survey"));
1681  }
1682  }
1683  else
1684  {
1685  // start
1686  $list[$appr_id] = array("start", $this->lng->txt("start_survey"));
1687  }
1688  }
1689 
1690  $info->addSection($this->lng->txt("survey_360_rate_other_appraisees"));
1691 
1692  include_once "Services/User/classes/class.ilUserUtil.php";
1693  foreach($list as $appr_id => $item)
1694  {
1695  $appr_name = ilUserUtil::getNamePresentation($appr_id, false, false, "", true);
1696 
1697  if(!is_array($item))
1698  {
1699  $info->addProperty($appr_name, $item);
1700  }
1701  else
1702  {
1703  $this->ctrl->setParameter($output_gui, "appr_id", $appr_id);
1704  $href = $this->ctrl->getLinkTarget($output_gui, $item[0]);
1705  $this->ctrl->setParameter($output_gui, "appr_id", "");
1706 
1707  $big_button_360 = '<div>'.
1708  '<a class="submit" href="'.$href.'">'.$item[1].'</a></div>';
1709 
1710  $info->addProperty($appr_name, $big_button_360);
1711  }
1712  }
1713  }
1714  else if(!$is_appraisee)
1715  {
1716  ilUtil::sendFailure($this->lng->txt("survey_360_no_appraisees"));
1717  }
1718  }
1719  }
1720 
1721  if($this->object->get360Mode() &&
1722  $this->object->get360SelfAppraisee() &&
1723  !$this->object->isAppraisee($ilUser->getId()) &&
1724  $ilUser->getId() != ANONYMOUS_USER_ID) // #14968
1725  {
1726  $link = $this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "addSelfAppraisee");
1727  $link = '<a href="'.$link.'">'.$this->lng->txt("survey_360_add_self_appraisee").'</a>';
1728  $info->addProperty("&nbsp;", $link);
1729  }
1730  }
1731 
1732  if($big_button)
1733  {
1734  $ilToolbar->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
1735  $ilToolbar->addFormButton($big_button[1], $big_button[0], "", true);
1736  $ilToolbar->setCloseFormTag(false);
1737  $info->setOpenFormTag(false);
1738  }
1739  /* #12016
1740  else
1741  {
1742  $info->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
1743  }
1744  */
1745 
1746  if (strlen($this->object->getIntroduction()))
1747  {
1748  $introduction = $this->object->getIntroduction();
1749  $info->addSection($this->lng->txt("introduction"));
1750  $info->addProperty("", $this->object->prepareTextareaOutput($introduction).
1751  "<br />".$info->getHiddenToggleButton());
1752  }
1753  else
1754  {
1755  $info->addSection("");
1756  $info->addProperty("", $info->getHiddenToggleButton());
1757  }
1758 
1759  $info->hideFurtherSections(false);
1760 
1761  $info->addSection($this->lng->txt("svy_general_properties"));
1762  if (strlen($this->object->getAuthor()))
1763  {
1764  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
1765  }
1766  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
1767  switch ($this->object->getAnonymize())
1768  {
1770  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("anonymize_personalized"));
1771  break;
1773  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
1774  {
1775  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_with_code"));
1776  }
1777  else
1778  {
1779  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_registered_user"));
1780  }
1781  break;
1783  $info->addProperty($this->lng->txt("anonymization"), $this->lng->txt("info_anonymize_without_code"));
1784  break;
1785  }
1786  include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
1787  if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
1788  {
1789  $info->addProperty($this->lng->txt("evaluation_access"), $this->lng->txt("evaluation_access_info"));
1790  }
1791  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1792  $this->ctrl->forwardCommand($info);
1793  }
1794 
1795  function addLocatorItems()
1796  {
1797  global $ilLocator;
1798  switch ($this->ctrl->getCmd())
1799  {
1800  case "next":
1801  case "previous":
1802  case "start":
1803  case "resume":
1804  case "redirectQuestion":
1805  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1806  break;
1807  case "evaluation":
1808  case "checkEvaluationAccess":
1809  case "evaluationdetails":
1810  case "evaluationuser":
1811  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"), "", $_GET["ref_id"]);
1812  break;
1813  case "create":
1814  case "save":
1815  case "cancel":
1816  case "importFile":
1817  case "cloneAll":
1818  break;
1819  case "infoScreen":
1820  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1821  break;
1822  default:
1823  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1824 
1825  // this has to be done here because ilSurveyEditorGUI is called after finalizing the locator
1826  if ((int)$_GET["q_id"] && !(int)$_REQUEST["new_for_survey"])
1827  {
1828  // not on create
1829  // see ilObjSurveyQuestionPool::addLocatorItems
1830  $q_id = (int)$_GET["q_id"];
1831  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1832  $q_type = SurveyQuestion::_getQuestionType($q_id)."GUI";
1833  $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
1834  $ilLocator->addItem(SurveyQuestion::_getTitle($q_id),
1835  $this->ctrl->getLinkTargetByClass(array("ilSurveyEditorGUI", $q_type), "editQuestion"));
1836  }
1837  break;
1838  }
1839  }
1840 
1841 
1842 
1848  function _goto($a_target, $a_access_code = "")
1849  {
1850  global $ilAccess, $ilErr, $lng;
1851 
1852  // see ilObjSurveyAccess::_checkGoto()
1853  include_once "./Services/Utilities/classes/class.ilUtil.php";
1854  if (strlen($a_access_code))
1855  {
1856  $_SESSION["anonymous_id"][ilObject::_lookupObjId($a_target)] = $a_access_code;
1857  $_GET["baseClass"] = "ilObjSurveyGUI";
1858  $_GET["cmd"] = "infoScreen";
1859  $_GET["ref_id"] = $a_target;
1860  include("ilias.php");
1861  exit;
1862  }
1863 
1864  if ($ilAccess->checkAccess("read", "", $a_target))
1865  {
1866  $_GET["baseClass"] = "ilObjSurveyGUI";
1867  $_GET["cmd"] = "infoScreen";
1868  $_GET["ref_id"] = $a_target;
1869  include("ilias.php");
1870  exit;
1871  }
1872  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1873  {
1874  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1875  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1877  }
1878 
1879  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1880  }
1881 }
1882 
1883 ?>