ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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  if(!in_array($this->ctrl->getCmdClass(),
93  array('ilpublicuserprofilegui', 'ilobjportfoliogui')))
94  {
95  $this->addHeaderAction();
96  $this->infoScreen(); // forwards command
97  }
98  else
99  {
100  // #16891
101  $ilTabs->clearTargets();
102  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
103  $info = new ilInfoScreenGUI($this);
104  $this->ctrl->forwardCommand($info);
105  }
106  break;
107 
108  case 'ilmdeditorgui':
109  $this->handleWriteAccess();
110  $ilTabs->activateTab("meta_data");
111  $this->addHeaderAction();
112  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
113  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
114  $md_gui->addObserver($this->object,'MDUpdateListener','General');
115 
116  $this->ctrl->forwardCommand($md_gui);
117  break;
118 
119  case "ilsurveyevaluationgui":
120  $ilTabs->activateTab("svy_results");
121  $this->addHeaderAction();
122  include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
123  $eval_gui = new ilSurveyEvaluationGUI($this->object);
124  $this->ctrl->forwardCommand($eval_gui);
125  break;
126 
127  case "ilsurveyexecutiongui":
128  $ilTabs->clearTargets();
129  include_once("./Modules/Survey/classes/class.ilSurveyExecutionGUI.php");
130  $exec_gui = new ilSurveyExecutionGUI($this->object);
131  $this->ctrl->forwardCommand($exec_gui);
132  break;
133 
134  case 'ilpermissiongui':
135  $ilTabs->activateTab("perm_settings");
136  $this->addHeaderAction();
137  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
138  $perm_gui =& new ilPermissionGUI($this);
139  $this->ctrl->forwardCommand($perm_gui);
140  break;
141 
142  case 'ilobjectcopygui':
143  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
144  $cp = new ilObjectCopyGUI($this);
145  $cp->setType('svy');
146  $this->ctrl->forwardCommand($cp);
147  break;
148 
149  case "ilcommonactiondispatchergui":
150  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
152  $this->ctrl->forwardCommand($gui);
153  break;
154 
155  // 360, skill service
156  case 'ilsurveyskillgui':
157  $ilTabs->activateTab("survey_competences");
158  include_once("./Modules/Survey/classes/class.ilSurveySkillGUI.php");
159  $gui = new ilSurveySkillGUI($this->object);
160  $this->ctrl->forwardCommand($gui);
161  break;
162 
163  case 'ilsurveyskilldeterminationgui':
164  $ilTabs->activateTab("maintenance");
165  include_once("./Modules/Survey/classes/class.ilSurveySkillDeterminationGUI.php");
166  $gui = new ilSurveySkillDeterminationGUI($this->object);
167  $this->ctrl->forwardCommand($gui);
168  break;
169 
170  case 'ilsurveyeditorgui':
171  $this->handleWriteAccess();
172  $ilTabs->activateTab("survey_questions");
173  include_once("./Modules/Survey/classes/class.ilSurveyEditorGUI.php");
174  $gui = new ilSurveyEditorGUI($this);
175  $this->ctrl->forwardCommand($gui);
176  break;
177 
178  case 'ilsurveyconstraintsgui':
179  $this->handleWriteAccess();
180  $ilTabs->activateTab("constraints");
181  include_once("./Modules/Survey/classes/class.ilSurveyConstraintsGUI.php");
182  $gui = new ilSurveyConstraintsGUI($this);
183  $this->ctrl->forwardCommand($gui);
184  break;
185 
186  case 'ilsurveyparticipantsgui':
187  if(!$this->object->get360Mode())
188  {
189  $ilTabs->activateTab("maintenance");
190  }
191  else
192  {
193  $ilTabs->activateTab("survey_360_appraisees");
194  }
195  include_once("./Modules/Survey/classes/class.ilSurveyParticipantsGUI.php");
196  $gui = new ilSurveyParticipantsGUI($this);
197  $this->ctrl->forwardCommand($gui);
198  break;
199 
200  default:
201  $this->addHeaderAction();
202  $cmd.= "Object";
203  $this->$cmd();
204  break;
205  }
206 
207  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
208  $this->getCreationMode() != true)
209  {
210  $this->tpl->show();
211  }
212  }
213 
221  public function evaluationObject()
222  {
223  include_once("./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php");
224  $eval_gui = new ilSurveyEvaluationGUI($this->object);
225  $this->ctrl->setCmdClass(get_class($eval_gui));
226  $this->ctrl->redirect($eval_gui, "evaluation");
227  }
228 
229  protected function addDidacticTemplateOptions(array &$a_options)
230  {
231  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
233  if($templates)
234  {
235  foreach($templates as $item)
236  {
237  $a_options["svytpl_".$item["id"]] = array($item["title"],
238  nl2br(trim($item["description"])));
239  }
240  }
241 
242  // JF, 2013-06-10
243  $a_options["svy360_1"] = array($this->lng->txt("survey_360_mode"),
244  $this->lng->txt("survey_360_mode_info"));
245  }
246 
251  function afterSave(ilObject $a_new_object)
252  {
253  // #16446
254  $a_new_object->loadFromDb();
255 
256  $tpl = $this->getDidacticTemplateVar("svytpl");
257  if($tpl)
258  {
259  $a_new_object->applySettingsTemplate($tpl);
260  }
261 
262  $a_new_object->set360Mode((bool)$this->getDidacticTemplateVar("svy360"));
263  if($a_new_object->get360Mode())
264  {
265  // this should rather be ilObjSurvey::ANONYMIZE_ON - see ilObjSurvey::getUserDataFromActiveId()
266  $a_new_object->setAnonymize(ilObjSurvey::ANONYMIZE_CODE_ALL);
267  $a_new_object->setEvaluationAccess(ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS);
268  }
269  $a_new_object->saveToDB();
270 
271  // always send a message
272  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
273  ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=".
274  $a_new_object->getRefId()."&cmd=properties");
275  }
276 
282  function getTabs(&$tabs_gui)
283  {
284  global $ilAccess, $ilUser, $ilHelp;
285 
286  if($this->object instanceof ilObjSurveyQuestionPool)
287  {
288  return true;
289  }
290 
291  $ilHelp->setScreenIdComponent("svy");
292 
293  $hidden_tabs = array();
294  $template = $this->object->getTemplate();
295  if($template)
296  {
297  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
298  $template = new ilSettingsTemplate($template);
299  $hidden_tabs = $template->getHiddenTabs();
300  }
301 
302  if ($ilAccess->checkAccess("write", "", $this->ref_id))
303  {
304  $tabs_gui->addTab("survey_questions",
305  $this->lng->txt("survey_questions"),
306  $this->ctrl->getLinkTargetByClass(array("ilsurveyeditorgui", "ilsurveypagegui"), "renderPage"));
307  }
308 
309  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
310  {
311  $tabs_gui->addTab("info_short",
312  $this->lng->txt("info_short"),
313  $this->ctrl->getLinkTarget($this,'infoScreen'));
314  }
315 
316  // properties
317  if ($ilAccess->checkAccess("write", "", $this->ref_id))
318  {
319  $tabs_gui->addTab("settings",
320  $this->lng->txt("settings"),
321  $this->ctrl->getLinkTarget($this,'properties'));
322  }
323  else if ($ilAccess->checkAccess("read", "", $this->ref_id))
324  {
325  if($this->object->get360Mode() &&
326  $this->object->get360SelfRaters() &&
327  $this->object->isAppraisee($ilUser->getId()) &&
328  !$this->object->isAppraiseeClosed($ilUser->getId()))
329  {
330  $tabs_gui->addTab("survey_360_edit_raters",
331  $this->lng->txt("survey_360_edit_raters"),
332  $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui','editRaters'));
333 
334  // :TODO: mail to raters
335  }
336  }
337 
338  // questions
339  if ($ilAccess->checkAccess("write", "", $this->ref_id) &&
340  !in_array("constraints", $hidden_tabs) &&
341  !$this->object->get360Mode())
342  {
343  // constraints
344  $tabs_gui->addTab("constraints",
345  $this->lng->txt("constraints"),
346  $this->ctrl->getLinkTargetByClass("ilsurveyconstraintsgui", "constraints"));
347  }
348 
349  if ($ilAccess->checkAccess("write", "", $this->ref_id))
350  {
351  // 360°
352  if($this->object->get360Mode())
353  {
354  // 360 mode + competence service
355  include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
356  $skmg_set = new ilSkillManagementSettings();
357  if ($this->object->get360SkillService() && $skmg_set->isActivated())
358  {
359  $tabs_gui->addTab("survey_competences",
360  $this->lng->txt("survey_competences"),
361  $this->ctrl->getLinkTargetByClass("ilsurveyskillgui", "listQuestionAssignment"));
362  }
363 
364  $tabs_gui->addTab("survey_360_appraisees",
365  $this->lng->txt("survey_360_appraisees"),
366  $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui', 'listAppraisees'));
367  }
368  else
369  {
370  // maintenance
371  $tabs_gui->addTab("maintenance",
372  $this->lng->txt("maintenance"),
373  $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui', 'maintenance'));
374  }
375  }
376 
377  include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
378  if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
379  ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
380  {
381  // evaluation
382  $tabs_gui->addTab("svy_results",
383  $this->lng->txt("svy_results"),
384  $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"));
385  }
386 
387  if ($ilAccess->checkAccess("write", "", $this->ref_id))
388  {
389  if(!in_array("meta_data", $hidden_tabs))
390  {
391  // meta data
392  $tabs_gui->addTab("meta_data",
393  $this->lng->txt("meta_data"),
394  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'));
395  }
396 
397  if(!in_array("export", $hidden_tabs))
398  {
399  // export
400  $tabs_gui->addTab("export",
401  $this->lng->txt("export"),
402  $this->ctrl->getLinkTarget($this,'export'));
403  }
404  }
405 
406  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
407  {
408  // permissions
409  $tabs_gui->addTab("perm_settings",
410  $this->lng->txt("perm_settings"),
411  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
412  }
413  }
414 
422  public function handleWriteAccess()
423  {
424  global $ilAccess;
425  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
426  {
427  // allow only write access
428  ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), TRUE);
429  $this->ctrl->redirect($this, "infoScreen");
430  }
431  }
432 
433 
434  //
435  // SETTINGS
436  //
437 
446  {
447  global $rbacsystem;
448 
449  $form = $this->initPropertiesForm();
450  if ($form->checkInput())
451  {
452  $valid = true;
453 
454  if(!$this->object->get360Mode())
455  {
456  if($form->getInput("tut"))
457  {
458  // check if given "tutors" have write permission
459  $tut_ids =array();
460  $tut_logins = $form->getInput("tut_ids");
461  foreach($tut_logins as $tut_login)
462  {
463  $tut_id = ilObjUser::_lookupId($tut_login);
464  if($tut_id && $rbacsystem->checkAccessOfUser($tut_id, "write", $this->object->getRefId()))
465  {
466  $tut_ids[] = $tut_id;
467  }
468  }
469  if(!$tut_ids)
470  {
471  $tut_ids = $form->getItemByPostVar("tut_ids");
472  $tut_ids->setAlert($this->lng->txt("survey_notification_tutor_recipients_invalid"));
473  $valid = false;
474  }
475  }
476  }
477 
478  if($valid)
479  {
480  if(!$this->object->get360Mode())
481  {
482  if($form->getInput("rmd"))
483  {
484  $rmd_start = $form->getInput("rmd_start");
485  $rmd_start = $rmd_start["date"];
486  $rmd_end = null;
487  if($form->getInput("rmd_end_tgl"))
488  {
489  $rmd_end = $form->getInput("rmd_end");
490  $rmd_end = $rmd_end["date"];
491  if($rmd_start > $rmd_end)
492  {
493  $tmp = $rmd_start;
494  $rmd_start = $rmd_end;
495  $rmd_end = $tmp;
496  }
497  $rmd_end = new ilDate($rmd_end, IL_CAL_DATE);
498  }
499  $rmd_start = new ilDate($rmd_start, IL_CAL_DATE);
500 
501  $this->object->setReminderStatus(true);
502  $this->object->setReminderStart($rmd_start);
503  $this->object->setReminderEnd($rmd_end);
504  $this->object->setReminderFrequency($form->getInput("rmd_freq"));
505  $this->object->setReminderTarget($form->getInput("rmd_grp"));
506  }
507  else
508  {
509  $this->object->setReminderStatus(false);
510  }
511 
512  if($form->getInput("tut"))
513  {
514  $this->object->setTutorNotificationStatus(true);
515  $this->object->setTutorNotificationRecipients($tut_ids); // see above
516  $this->object->setTutorNotificationTarget($form->getInput("tut_grp"));
517  }
518  else
519  {
520  $this->object->setTutorNotificationStatus(false);
521  }
522  }
523 
524  // #10055
525  if ($_POST['online'] && count($this->object->questions) == 0)
526  {
527  $_POST['online'] = null;
528  ilUtil::sendFailure($this->lng->txt("cannot_switch_to_online_no_questions"), true);
529  }
530 
531  $template_settings = null;
532  $template = $this->object->getTemplate();
533  if($template)
534  {
535  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
536  $template = new ilSettingsTemplate($template);
537  $template_settings = $template->getSettings();
538  }
539 
540  include_once 'Services/MetaData/classes/class.ilMD.php';
541  $md_obj =& new ilMD($this->object->getId(), 0, "svy");
542  $md_section = $md_obj->getGeneral();
543 
544  // title
545  $md_section->setTitle(ilUtil::stripSlashes($_POST['title']));
546  $md_section->update();
547 
548  // Description
549  $md_desc_ids = $md_section->getDescriptionIds();
550  if($md_desc_ids)
551  {
552  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
553  $md_desc->setDescription(ilUtil::stripSlashes($_POST['description']));
554  $md_desc->update();
555  }
556 
557  $this->object->setViewOwnResults($_POST["view_own"]);
558  $this->object->setMailOwnResults($_POST["mail_own"]);
559 
560  // both are saved in object, too
561  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
562  $this->object->setDescription(ilUtil::stripSlashes($_POST['description']));
563  $this->object->update();
564 
565  $this->object->setStatus($_POST['online']);
566 
567  // activation
568  if($_POST["access_type"])
569  {
570  $this->object->setActivationLimited(true);
571  $this->object->setActivationVisibility($_POST["access_visiblity"]);
572 
573  $period = $form->getItemByPostVar("access_period");
574  $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
575  $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
576  }
577  else
578  {
579  $this->object->setActivationLimited(false);
580  }
581 
582 
583  if(!$template_settings["enabled_start_date"]["hide"])
584  {
585  if ($_POST["enabled_start_date"])
586  {
587  $this->object->setStartDateAndTime($_POST["start_date"]['date'], $_POST["start_date"]['time']);
588  }
589  else
590  {
591  $this->object->setStartDate(null);
592  }
593  }
594 
595  if(!$template_settings["enabled_end_date"]["hide"])
596  {
597  if ($_POST["enabled_end_date"])
598  {
599  $this->object->setEndDateAndTime($_POST["end_date"]['date'], $_POST["end_date"]['time']);
600  }
601  else
602  {
603  $this->object->setEndDate(null);
604  }
605  }
606 
607 
608  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
609  $introduction = $_POST["introduction"];
610  $this->object->setIntroduction($introduction);
611  $outro = $_POST["outro"];
612  $this->object->setOutro($outro);
613 
614  if(!$template_settings["show_question_titles"]["hide"])
615  {
616  $this->object->setShowQuestionTitles($_POST["show_question_titles"]);
617  }
618 
619  if(!$template_settings["use_pool"]["hide"])
620  {
621  $this->object->setPoolUsage($_POST["use_pool"]);
622  }
623 
624  $this->object->setMailNotification($_POST['mailnotification']);
625  $this->object->setMailAddresses($_POST['mailaddresses']);
626  $this->object->setMailParticipantData($_POST['mailparticipantdata']);
627 
628  // 360°
629  if($this->object->get360Mode())
630  {
631  $this->object->set360SelfEvaluation((bool)$_POST["self_eval"]);
632  $this->object->set360SelfAppraisee((bool)$_POST["self_appr"]);
633  $this->object->set360SelfRaters((bool)$_POST["self_rate"]);
634  $this->object->set360Results((int)$_POST["ts_res"]);;
635  $this->object->set360SkillService((int)$_POST["skill_service"]);
636  }
637  else
638  {
639  $this->object->setEvaluationAccess($_POST["evaluation_access"]);
640 
641  $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
642  if (!$hasDatasets)
643  {
644  $codes = (bool)$_POST["acc_codes"];
645  $anon = ((string)$_POST["anonymization_options"] == "statanon");
646  if (!$anon)
647  {
648  if (!$codes)
649  {
650  $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_OFF);
651  }
652  else
653  {
654  $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_CODE_ALL);
655  }
656  }
657  else
658  {
659  if ($codes)
660  {
661  $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_ON);
662  }
663  else
664  {
665  $this->object->setAnonymize(ilObjSurvey::ANONYMIZE_FREEACCESS);
666  }
667  }
668 
669  // if settings were changed get rid of existing code
670  unset($_SESSION["anonymous_id"][$this->object->getId()]);
671  }
672  }
673 
674  $this->object->saveToDb();
675 
676  if (strcmp($_SESSION["info"], "") != 0)
677  {
678  ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("settings_saved"), true);
679  }
680  else
681  {
682  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
683  }
684  $this->ctrl->redirect($this, "properties");
685  }
686  }
687 
688  $form->setValuesByPost();
689  $this->propertiesObject($form);
690  }
691 
698  {
699  $template_settings = $hide_rte_switch = null;
700  $template = $this->object->getTemplate();
701  if($template)
702  {
703  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
704  $template = new ilSettingsTemplate($template);
705 
706  $template_settings = $template->getSettings();
707  $hide_rte_switch = $template_settings["rte_switch"]["hide"];
708  }
709 
710  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
711  $form = new ilPropertyFormGUI();
712  $form->setFormAction($this->ctrl->getFormAction($this));
713  $form->setTableWidth("100%");
714  $form->setId("survey_properties");
715 
716  // general properties
717  $header = new ilFormSectionHeaderGUI();
718  $header->setTitle($this->lng->txt("settings"));
719  $form->addItem($header);
720 
721 
722  // title & description (meta data)
723 
724  include_once 'Services/MetaData/classes/class.ilMD.php';
725  $md_obj = new ilMD($this->object->getId(), 0, "svy");
726  $md_section = $md_obj->getGeneral();
727 
728  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
729  $title->setRequired(true);
730  $title->setValue($md_section->getTitle());
731  $form->addItem($title);
732 
733  $ids = $md_section->getDescriptionIds();
734  if($ids)
735  {
736  $desc_obj = $md_section->getDescription(array_pop($ids));
737 
738  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
739  $desc->setCols(50);
740  $desc->setRows(4);
741  $desc->setValue($desc_obj->getDescription());
742  $form->addItem($desc);
743  }
744 
745  // pool usage
746  $pool_usage = new ilRadioGroupInputGUI($this->lng->txt("survey_question_pool_usage"), "use_pool");
747  $opt = new ilRadioOption($this->lng->txt("survey_question_pool_usage_active"), 1);
748  $opt->setInfo($this->lng->txt("survey_question_pool_usage_active_info"));
749  $pool_usage->addOption($opt);
750  $opt = new ilRadioOption($this->lng->txt("survey_question_pool_usage_inactive"), 0);
751  $opt->setInfo($this->lng->txt("survey_question_pool_usage_inactive_info"));
752  $pool_usage->addOption($opt);
753  $pool_usage->setValue($this->object->getPoolUsage());
754  $form->addItem($pool_usage);
755 
756  // 360°: appraisees
757  if($this->object->get360Mode())
758  {
759  $self_eval = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_evaluation"), "self_eval");
760  $self_eval->setInfo($this->lng->txt("survey_360_self_evaluation_info"));
761  $self_eval->setChecked($this->object->get360SelfEvaluation());
762  $form->addItem($self_eval);
763 
764  $self_rate = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_raters"), "self_rate");
765  $self_rate->setInfo($this->lng->txt("survey_360_self_raters_info"));
766  $self_rate->setChecked($this->object->get360SelfRaters());
767  $form->addItem($self_rate);
768 
769  $self_appr = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_appraisee"), "self_appr");
770  $self_appr->setInfo($this->lng->txt("survey_360_self_appraisee_info"));
771  $self_appr->setChecked($this->object->get360SelfAppraisee());
772  $form->addItem($self_appr);
773  }
774 
775 
776  // activation
777 
778  include_once "Services/Object/classes/class.ilObjectActivation.php";
779  $this->lng->loadLanguageModule('rep');
780 
782  $section->setTitle($this->lng->txt('rep_activation_availability'));
783  $form->addItem($section);
784 
785  // additional info only with multiple references
786  $act_obj_info = $act_ref_info = "";
787  if(sizeof(ilObject::_getAllReferences($this->object->getId())) > 1)
788  {
789  $act_obj_info = ' '.$this->lng->txt('rep_activation_online_object_info');
790  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
791  }
792 
793  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'),'online');
794  $online->setInfo($this->lng->txt('svy_activation_online_info').$act_obj_info);
795  $online->setChecked($this->object->isOnline());
796  $form->addItem($online);
797 
798  $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'),'access_type');
799  // $act_type->setInfo($this->lng->txt('svy_availability_until_info'));
800  $act_type->setChecked($this->object->isActivationLimited());
801 
802  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
803  include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
804  $dur = new ilDateDurationInputGUI($this->lng->txt('rep_time_period'), "access_period");
805  $dur->setShowTime(true);
806  $date = $this->object->getActivationStartDate();
807  $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
808  $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
809  $date = $this->object->getActivationEndDate();
810  $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
811  $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
812  $act_type->addSubItem($dur);
813 
814  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
815  $visible->setInfo($this->lng->txt('svy_activation_limited_visibility_info'));
816  $visible->setChecked($this->object->getActivationVisibility());
817  $act_type->addSubItem($visible);
818 
819  $form->addItem($act_type);
820 
821 
822  // before start
823 
825  $section->setTitle($this->lng->txt('svy_settings_section_before_start'));
826  $form->addItem($section);
827 
828  // introduction
829  $intro = new ilTextAreaInputGUI($this->lng->txt("introduction"), "introduction");
830  $intro->setValue($this->object->prepareTextareaOutput($this->object->getIntroduction()));
831  $intro->setRows(10);
832  $intro->setCols(80);
833  $intro->setUseRte(TRUE);
834  $intro->setInfo($this->lng->txt("survey_introduction_info"));
835  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
836  $intro->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
837  $intro->addPlugin("latex");
838  $intro->addButton("latex");
839  $intro->addButton("pastelatex");
840  $intro->setRTESupport($this->object->getId(), "svy", "survey", null, $hide_rte_switch);
841  $form->addItem($intro);
842 
843 
844  // access
845 
847  $section->setTitle($this->lng->txt('svy_settings_section_access'));
848  $form->addItem($section);
849 
850  // enable start date
851  $start = $this->object->getStartDate();
852  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("start_date"), "enabled_start_date");
853  $enablestartingtime->setValue(1);
854  // $enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
855  $enablestartingtime->setChecked($start);
856  // start date
857  $startingtime = new ilDateTimeInputGUI('', 'start_date');
858  $startingtime->setShowTime(true);
859  if ($start)
860  {
861  $startingtime->setDate(new ilDate($start, IL_CAL_TIMESTAMP));
862  }
863  $enablestartingtime->addSubItem($startingtime);
864  $form->addItem($enablestartingtime);
865 
866  // enable end date
867  $end = $this->object->getEndDate();
868  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("end_date"), "enabled_end_date");
869  $enableendingtime->setValue(1);
870  // $enableendingtime->setOptionTitle($this->lng->txt("enabled"));
871  $enableendingtime->setChecked($end);
872  // end date
873  $endingtime = new ilDateTimeInputGUI('', 'end_date');
874  $endingtime->setShowTime(true);
875  if ($end)
876  {
877  $endingtime->setDate(new ilDate($end, IL_CAL_TIMESTAMP));
878  }
879  $enableendingtime->addSubItem($endingtime);
880  $form->addItem($enableendingtime);
881 
882  // anonymization
883  if(!$this->object->get360Mode())
884  {
885  $codes = new ilCheckboxInputGUI($this->lng->txt("survey_access_codes"), "acc_codes");
886  $codes->setInfo($this->lng->txt("survey_access_codes_info"));
887  $codes->setChecked(!$this->object->isAccessibleWithoutCode());
888  $form->addItem($codes);
889 
890  if ($this->object->_hasDatasets($this->object->getSurveyId()))
891  {
892  $codes->setDisabled(true);
893  }
894  }
895 
896 
897  // question behaviour
898 
900  $section->setTitle($this->lng->txt('svy_settings_section_question_behaviour'));
901  $form->addItem($section);
902 
903  // show question titles
904  $show_question_titles = new ilCheckboxInputGUI($this->lng->txt("svy_show_questiontitles"), "show_question_titles");
905  $show_question_titles->setValue(1);
906  $show_question_titles->setChecked($this->object->getShowQuestionTitles());
907  $form->addItem($show_question_titles);
908 
909 
910  // finishing
911 
912  $info = new ilFormSectionHeaderGUI();
913  $info->setTitle($this->lng->txt("svy_settings_section_finishing"));
914  $form->addItem($info);
915 
916  $view_own = new ilCheckboxInputGUI($this->lng->txt("svy_results_view_own"), "view_own");
917  $view_own->setInfo($this->lng->txt("svy_results_view_own_info"));
918  $view_own->setChecked($this->object->hasViewOwnResults());
919  $form->addItem($view_own);
920 
921  $mail_own = new ilCheckboxInputGUI($this->lng->txt("svy_results_mail_own"), "mail_own");
922  $mail_own->setInfo($this->lng->txt("svy_results_mail_own_info"));
923  $mail_own->setChecked($this->object->hasMailOwnResults());
924  $form->addItem($mail_own);
925 
926  // final statement
927  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("outro"), "outro");
928  $finalstatement->setValue($this->object->prepareTextareaOutput($this->object->getOutro()));
929  $finalstatement->setRows(10);
930  $finalstatement->setCols(80);
931  $finalstatement->setUseRte(TRUE);
932  $finalstatement->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
933  $finalstatement->addPlugin("latex");
934  $finalstatement->addButton("latex");
935  $finalstatement->addButton("pastelatex");
936  $finalstatement->setRTESupport($this->object->getId(), "svy", "survey", null, $hide_rte_switch);
937  $form->addItem($finalstatement);
938 
939  // mail notification
940  $mailnotification = new ilCheckboxInputGUI($this->lng->txt("mailnotification"), "mailnotification");
941  // $mailnotification->setOptionTitle($this->lng->txt("activate"));
942  $mailnotification->setInfo($this->lng->txt("svy_result_mail_notification_info")); // #11762
943  $mailnotification->setValue(1);
944  $mailnotification->setChecked($this->object->getMailNotification());
945 
946  // addresses
947  $mailaddresses = new ilTextInputGUI($this->lng->txt("mailaddresses"), "mailaddresses");
948  $mailaddresses->setValue($this->object->getMailAddresses());
949  $mailaddresses->setSize(80);
950  $mailaddresses->setInfo($this->lng->txt('mailaddresses_info'));
951  $mailaddresses->setRequired(true);
952 
953  // participant data
954  $participantdata = new ilTextAreaInputGUI($this->lng->txt("mailparticipantdata"), "mailparticipantdata");
955  $participantdata->setValue($this->object->getMailParticipantData());
956  $participantdata->setRows(6);
957  $participantdata->setCols(80);
958  $participantdata->setUseRte(false);
959  $participantdata->setInfo($this->lng->txt("mailparticipantdata_info"));
960 
961  // #12755 - because of privacy concerns we restrict user data to a minimum
962  $placeholders = array(
963  "FIRST_NAME" => "firstname",
964  "LAST_NAME" => "lastname",
965  "LOGIN" => "login"
966  );
967  $txt = array();
968  foreach($placeholders as $placeholder => $caption)
969  {
970  $txt[] = "[".strtoupper($placeholder)."]: ".$this->lng->txt($caption);
971  }
972  $txt = implode("<br />", $txt);
973  $participantdatainfo = new ilNonEditableValueGUI($this->lng->txt("mailparticipantdata_placeholder"), "", true);
974  $participantdatainfo->setValue($txt);
975 
976  $mailnotification->addSubItem($mailaddresses);
977  $mailnotification->addSubItem($participantdata);
978  $mailnotification->addSubItem($participantdatainfo);
979  $form->addItem($mailnotification);
980 
981  // tutor notification - currently not available for 360°
982  if(!$this->object->get360Mode())
983  {
984  // parent course?
985  global $tree;
986  $has_parent = $tree->checkForParentType($this->object->getRefId(), "grp");
987  if(!$has_parent)
988  {
989  $has_parent = $tree->checkForParentType($this->object->getRefId(), "crs");
990  }
991  $num_inv = sizeof($this->object->getInvitedUsers());
992 
993  // notification
994  $tut = new ilCheckboxInputGUI($this->lng->txt("survey_notification_tutor_setting"), "tut");
995  $tut->setChecked($this->object->getTutorNotificationStatus());
996  $form->addItem($tut);
997 
998  $tut_logins = array();
999  $tuts = $this->object->getTutorNotificationRecipients();
1000  if($tuts)
1001  {
1002  foreach($tuts as $tut_id)
1003  {
1004  $tmp = ilObjUser::_lookupName($tut_id);
1005  if($tmp["login"])
1006  {
1007  $tut_logins[] = $tmp["login"];
1008  }
1009  }
1010  }
1011  $tut_ids = new ilTextInputGUI($this->lng->txt("survey_notification_tutor_recipients"), "tut_ids");
1012  $tut_ids->setDataSource($this->ctrl->getLinkTarget($this, "doAutoComplete", "", true));
1013  $tut_ids->setRequired(true);
1014  $tut_ids->setMulti(true);
1015  $tut_ids->setMultiValues($tut_logins);
1016  $tut_ids->setValue(array_shift($tut_logins));
1017  $tut->addSubItem($tut_ids);
1018 
1019  $tut_grp = new ilRadioGroupInputGUI($this->lng->txt("survey_notification_target_group"), "tut_grp");
1020  $tut_grp->setRequired(true);
1021  $tut_grp->setValue($this->object->getTutorNotificationTarget());
1022  $tut->addSubItem($tut_grp);
1023 
1024  $tut_grp_crs = new ilRadioOption($this->lng->txt("survey_notification_target_group_parent_course"),
1026  if(!$has_parent)
1027  {
1028  $tut_grp_crs->setInfo($this->lng->txt("survey_notification_target_group_parent_course_inactive"));
1029  }
1030  $tut_grp->addOption($tut_grp_crs);
1031 
1032  $tut_grp_inv = new ilRadioOption($this->lng->txt("survey_notification_target_group_invited"),
1034  $tut_grp_inv->setInfo(sprintf($this->lng->txt("survey_notification_target_group_invited_info"), $num_inv));
1035  $tut_grp->addOption($tut_grp_inv);
1036  }
1037 
1038 
1039  // reminders
1040 
1041  // reminder - currently not available for 360°
1042  if(!$this->object->get360Mode())
1043  {
1044  $info = new ilFormSectionHeaderGUI();
1045  $info->setTitle($this->lng->txt("svy_settings_section_reminders"));
1046  $form->addItem($info);
1047 
1048  $rmd = new ilCheckboxInputGUI($this->lng->txt("survey_reminder_setting"), "rmd");
1049  $rmd->setChecked($this->object->getReminderStatus());
1050  $form->addItem($rmd);
1051 
1052  $rmd_start = new ilDateTimeInputGUI($this->lng->txt("survey_reminder_start"), "rmd_start");
1053  $rmd_start->setRequired(true);
1054  $start = $this->object->getReminderStart();
1055  if($start)
1056  {
1057  $rmd_start->setDate($start);
1058  }
1059  $rmd->addSubItem($rmd_start);
1060 
1061  $end = $this->object->getReminderEnd();
1062  $rmd_end = new ilDateTimeInputGUI($this->lng->txt("survey_reminder_end"), "rmd_end");
1063  $rmd_end->enableDateActivation("", "rmd_end_tgl", (bool)$end);
1064  if($end)
1065  {
1066  $rmd_end->setDate($end);
1067  }
1068  $rmd->addSubItem($rmd_end);
1069 
1070  $rmd_freq = new ilNumberInputGUI($this->lng->txt("survey_reminder_frequency"), "rmd_freq");
1071  $rmd_freq->setRequired(true);
1072  $rmd_freq->setSize(3);
1073  $rmd_freq->setSuffix($this->lng->txt("survey_reminder_frequency_days"));
1074  $rmd_freq->setValue($this->object->getReminderFrequency());
1075  $rmd_freq->setMinValue(1);
1076  $rmd->addSubItem($rmd_freq);
1077 
1078  $rmd_grp = new ilRadioGroupInputGUI($this->lng->txt("survey_notification_target_group"), "rmd_grp");
1079  $rmd_grp->setRequired(true);
1080  $rmd_grp->setValue($this->object->getReminderTarget());
1081  $rmd->addSubItem($rmd_grp);
1082 
1083  $rmd_grp_crs = new ilRadioOption($this->lng->txt("survey_notification_target_group_parent_course"),
1085  if(!$has_parent)
1086  {
1087  $rmd_grp_crs->setInfo($this->lng->txt("survey_notification_target_group_parent_course_inactive"));
1088  }
1089  $rmd_grp->addOption($rmd_grp_crs);
1090 
1091  $rmd_grp_inv = new ilRadioOption($this->lng->txt("survey_notification_target_group_invited"),
1093  $rmd_grp_inv->setInfo(sprintf($this->lng->txt("survey_notification_target_group_invited_info"), $num_inv));
1094  $rmd_grp->addOption($rmd_grp_inv);
1095  }
1096 
1097 
1098  // results
1099 
1101  $results->setTitle($this->lng->txt("results"));
1102  $form->addItem($results);
1103 
1104  // evaluation access
1105  if(!$this->object->get360Mode())
1106  {
1107  $evaluation_access = new ilRadioGroupInputGUI($this->lng->txt('evaluation_access'), "evaluation_access");
1108 
1109  $option = new ilCheckboxOption($this->lng->txt("evaluation_access_off"), ilObjSurvey::EVALUATION_ACCESS_OFF, '');
1110  $option->setInfo($this->lng->txt("svy_evaluation_access_off_info"));
1111  $evaluation_access->addOption($option);
1112 
1113  $option = new ilCheckboxOption($this->lng->txt("evaluation_access_all"), ilObjSurvey::EVALUATION_ACCESS_ALL, '');
1114  $option->setInfo($this->lng->txt("svy_evaluation_access_all_info"));
1115  $evaluation_access->addOption($option);
1116 
1117  $option = new ilCheckboxOption($this->lng->txt("evaluation_access_participants"), ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS, '');
1118  $option->setInfo($this->lng->txt("svy_evaluation_access_participants_info"));
1119  $evaluation_access->addOption($option);
1120 
1121  $evaluation_access->setValue($this->object->getEvaluationAccess());
1122  $form->addItem($evaluation_access);
1123 
1124 
1125  $anonymization_options = new ilRadioGroupInputGUI($this->lng->txt("survey_results_anonymization"), "anonymization_options");
1126 
1127  $option = new ilCheckboxOption($this->lng->txt("survey_results_personalized"), "statpers");
1128  $option->setInfo($this->lng->txt("survey_results_personalized_info"));
1129  $anonymization_options->addOption($option);
1130 
1131  $option = new ilCheckboxOption($this->lng->txt("survey_results_anonymized"), "statanon");
1132  $option->setInfo($this->lng->txt("survey_results_anonymized_info"));
1133  $anonymization_options->addOption($option);
1134  $anonymization_options->setValue($this->object->hasAnonymizedResults()
1135  ? "statanon"
1136  : "statpers");
1137  $form->addItem($anonymization_options);
1138 
1139  if ($this->object->_hasDatasets($this->object->getSurveyId()))
1140  {
1141  $anonymization_options->setDisabled(true);
1142  }
1143  }
1144  // 360°
1145  else
1146  {
1147  $ts_results = new ilRadioGroupInputGUI($this->lng->txt("survey_360_results"), "ts_res");
1148  $ts_results->setValue($this->object->get360Results());
1149 
1150  $option = new ilRadioOption($this->lng->txt("survey_360_results_none"), ilObjSurvey::RESULTS_360_NONE);
1151  $option->setInfo($this->lng->txt("survey_360_results_none_info"));
1152  $ts_results->addOption($option);
1153 
1154  $option = new ilRadioOption($this->lng->txt("survey_360_results_own"), ilObjSurvey::RESULTS_360_OWN);
1155  $option->setInfo($this->lng->txt("survey_360_results_own_info"));
1156  $ts_results->addOption($option);
1157 
1158  $option = new ilRadioOption($this->lng->txt("survey_360_results_all"), ilObjSurvey::RESULTS_360_ALL);
1159  $option->setInfo($this->lng->txt("survey_360_results_all_info"));
1160  $ts_results->addOption($option);
1161  $form->addItem($ts_results);
1162  }
1163 
1164 
1165  // competence service activation for 360 mode
1166 
1167  include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
1168  $skmg_set = new ilSkillManagementSettings();
1169  if($this->object->get360Mode() && $skmg_set->isActivated())
1170  {
1171  $other = new ilFormSectionHeaderGUI();
1172  $other->setTitle($this->lng->txt("other"));
1173  $form->addItem($other);
1174 
1175  $skill_service = new ilCheckboxInputGUI($this->lng->txt("survey_activate_skill_service"), "skill_service");
1176  $skill_service->setInfo($this->lng->txt("survey_activate_skill_service_info"));
1177  $skill_service->setChecked($this->object->get360SkillService());
1178  $form->addItem($skill_service);
1179  }
1180 
1181 
1182  $form->addCommandButton("saveProperties", $this->lng->txt("save"));
1183 
1184  // remove items when using template
1185  if($template_settings)
1186  {
1187  foreach($template_settings as $id => $item)
1188  {
1189  if($item["hide"])
1190  {
1191  $form->removeItemByPostVar($id);
1192  }
1193  }
1194  }
1195 
1196  return $form;
1197  }
1198 
1204  function propertiesObject(ilPropertyFormGUI $a_form = null)
1205  {
1206  global $ilTabs, $ilHelp;
1207 
1208  $this->handleWriteAccess();
1209 
1210  $ilTabs->activateTab("settings");
1211 
1212 
1213  if ($this->object->get360Mode())
1214  {
1215  $ilHelp->setScreenId("settings_360");
1216  }
1217 
1218  if(!$a_form)
1219  {
1220  $a_form = $this->initPropertiesForm();
1221  }
1222 
1223  // using template?
1224  $message = "";
1225  if($this->object->getTemplate())
1226  {
1227  $link = $this->ctrl->getLinkTarget($this, "confirmResetTemplate");
1228  $link = "<a href=\"".$link."\">".$this->lng->txt("survey_using_template_link")."</a>";
1229  $message = "<div style=\"margin-top:10px\">".
1230  $this->tpl->getMessageHTML(sprintf($this->lng->txt("survey_using_template"),
1231  ilSettingsTemplate::lookupTitle($this->object->getTemplate()), $link), "info"). // #10651
1232  "</div>";
1233  }
1234 
1235  $this->tpl->setContent($a_form->getHTML().$message);
1236  }
1237 
1239  {
1240  $fields = array('login','firstname','lastname','email');
1241 
1242  include_once './Services/User/classes/class.ilUserAutoComplete.php';
1243  $auto = new ilUserAutoComplete();
1244  $auto->setSearchFields($fields);
1245  $auto->setResultField('login');
1246  $auto->enableFieldSearchableCheck(true);
1247  $auto->setMoreLinkAvailable(true);
1248 
1249  if(($_REQUEST['fetchall']))
1250  {
1251  $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1252  }
1253 
1254  echo $auto->getList(ilUtil::stripSlashes($_REQUEST['term']));
1255  exit();
1256  }
1257 
1262  {
1263  ilUtil::sendQuestion($this->lng->txt("survey_confirm_template_reset"));
1264  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_confirm_resettemplate.html", "Modules/Survey");
1265  $this->tpl->setCurrentBlock("adm_content");
1266  $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
1267  $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
1268  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "resetTemplateObject"));
1269  $this->tpl->parseCurrentBlock();
1270  }
1271 
1276  {
1277  $this->object->setTemplate(null);
1278  $this->object->saveToDB();
1279 
1280  ilUtil::sendSuccess($this->lng->txt("survey_template_reset"), true);
1281  $this->ctrl->redirect($this, "properties");
1282  }
1283 
1284 
1285 
1286  //
1287  // IMPORT/EXPORT
1288  //
1289 
1290  protected function initImportForm($a_new_type)
1291  {
1292  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1293  $form = new ilPropertyFormGUI();
1294  $form->setTarget("_top");
1295  $form->setFormAction($this->ctrl->getFormAction($this));
1296  $form->setTitle($this->lng->txt("import_svy"));
1297 
1298  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1299  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1300  $fi->setSuffixes(array("zip"));
1301  $fi->setRequired(true);
1302  $form->addItem($fi);
1303 
1304  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
1305  $svy = new ilObjSurvey();
1306  $questionspools = $svy->getAvailableQuestionpools(true, true, true);
1307 
1308  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool_short"), "spl");
1309  $pools->setOptions(array(""=>$this->lng->txt("dont_use_questionpool")) + $questionspools);
1310  $pools->setRequired(false);
1311  $form->addItem($pools);
1312 
1313  $form->addCommandButton("importFile", $this->lng->txt("import"));
1314  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1315 
1316  return $form;
1317  }
1318 
1322  function importFileObject()
1323  {
1324  global $tpl, $ilErr;
1325 
1326  $parent_id = $_GET["ref_id"];
1327  $new_type = $_REQUEST["new_type"];
1328 
1329  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1330  if (!$this->checkPermissionBool("create", "", $new_type))
1331  {
1332  $ilErr->raiseError($this->lng->txt("no_create_permission"));
1333  }
1334 
1335  $this->lng->loadLanguageModule($new_type);
1336  $this->ctrl->setParameter($this, "new_type", $new_type);
1337 
1338  $form = $this->initImportForm($new_type);
1339  if ($form->checkInput())
1340  {
1341  include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
1342  $newObj = new ilObjSurvey();
1343  $newObj->setType($new_type);
1344  $newObj->setTitle("dummy");
1345  $newObj->setDescription("dummy");
1346  $newObj->create(true);
1347  $this->putObjectInTree($newObj);
1348 
1349  // copy uploaded file to import directory
1350  $error = $newObj->importObject($_FILES["importfile"], $form->getInput("spl"));
1351  if (strlen($error))
1352  {
1353  $newObj->delete();
1354  $this->ilias->raiseError($error, $this->ilias->error_obj->MESSAGE);
1355  return;
1356  }
1357 
1358  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
1359  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1360  "&baseClass=ilObjSurveyGUI");
1361 
1362  // using template?
1363  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1364  $templates = ilSettingsTemplate::getAllSettingsTemplates("svy");
1365  if($templates)
1366  {
1367  global $tpl;
1368  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery.js");
1369  // $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery-ui-min.js");
1370 
1371  $this->tpl->setCurrentBlock("template_option");
1372  $this->tpl->setVariable("VAL_TEMPLATE_OPTION", "");
1373  $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $this->lng->txt("none"));
1374  $this->tpl->parseCurrentBlock();
1375 
1376  foreach($templates as $item)
1377  {
1378  $this->tpl->setCurrentBlock("template_option");
1379  $this->tpl->setVariable("VAL_TEMPLATE_OPTION", $item["id"]);
1380  $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $item["title"]);
1381  $this->tpl->parseCurrentBlock();
1382 
1383  $desc = str_replace("\n", "", nl2br($item["description"]));
1384  $desc = str_replace("\r", "", $desc);
1385 
1386  $this->tpl->setCurrentBlock("js_data");
1387  $this->tpl->setVariable("JS_DATA_ID", $item["id"]);
1388  $this->tpl->setVariable("JS_DATA_TEXT", $desc);
1389  $this->tpl->parseCurrentBlock();
1390  }
1391 
1392  $this->tpl->setCurrentBlock("templates");
1393  $this->tpl->setVariable("TXT_TEMPLATE", $this->lng->txt("svy_settings_template"));
1394  $this->tpl->parseCurrentBlock();
1395  }
1396  }
1397 
1398  // display form to correct errors
1399  $form->setValuesByPost();
1400  $tpl->setContent($form->getHtml());
1401  }
1402 
1403  /*
1404  * list all export files
1405  */
1406  public function exportObject()
1407  {
1408  global $ilTabs, $ilToolbar;
1409 
1410  $this->handleWriteAccess();
1411  $ilTabs->activateTab("export");
1412 
1413  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1414  $button = ilLinkButton::getInstance();
1415  $button->setCaption("svy_create_export_file");
1416  $button->setUrl($this->ctrl->getLinkTarget($this, "createExportFile"));
1417  $ilToolbar->addButtonInstance($button);
1418 
1419  $export_dir = $this->object->getExportDirectory();
1420  $export_files = $this->object->getExportFiles($export_dir);
1421  $data = array();
1422  if(count($export_files) > 0)
1423  {
1424  foreach($export_files as $exp_file)
1425  {
1426  $file_arr = explode("__", $exp_file);
1427  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
1428  array_push($data, array(
1429  'file' => $exp_file,
1430  'size' => filesize($export_dir."/".$exp_file),
1431  'date' => $date->get(IL_CAL_DATETIME)
1432  ));
1433  }
1434  }
1435 
1436  include_once "./Modules/Survey/classes/tables/class.ilSurveyExportTableGUI.php";
1437  $table_gui = new ilSurveyExportTableGUI($this, 'export');
1438  $table_gui->setData($data);
1439  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1440  }
1441 
1445  public function createExportFileObject()
1446  {
1447  $this->handleWriteAccess();
1448  include_once("./Modules/Survey/classes/class.ilSurveyExport.php");
1449  $survey_exp = new ilSurveyExport($this->object);
1450  $survey_exp->buildExportFile();
1451  $this->ctrl->redirect($this, "export");
1452  }
1453 
1457  public function downloadExportFileObject()
1458  {
1459  if(!isset($_POST["file"]))
1460  {
1461  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1462  $this->ctrl->redirect($this, "export");
1463  }
1464 
1465  if (count($_POST["file"]) > 1)
1466  {
1467  ilUtil::sendFailure($this->lng->txt("select_max_one_item"), true);
1468  $this->ctrl->redirect($this, "export");
1469  }
1470 
1471  $file = basename($_POST["file"][0]);
1472 
1473  $export_dir = $this->object->getExportDirectory();
1474  include_once "./Services/Utilities/classes/class.ilUtil.php";
1475  ilUtil::deliverFile($export_dir."/".$file, $file);
1476  }
1477 
1482  {
1483  global $ilTabs;
1484 
1485  $this->handleWriteAccess();
1486  $ilTabs->activateTab("export");
1487 
1488  if (!isset($_POST["file"]))
1489  {
1490  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1491  $this->ctrl->redirect($this, "export");
1492  }
1493 
1494  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1495 
1496  $export_dir = $this->object->getExportDirectory();
1497  $export_files = $this->object->getExportFiles($export_dir);
1498  $data = array();
1499  if (count($_POST["file"]) > 0)
1500  {
1501  foreach ($_POST["file"] as $exp_file)
1502  {
1503  $file_arr = explode("__", $exp_file);
1504  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
1505  array_push($data, array(
1506  'file' => $exp_file,
1507  'size' => filesize($export_dir."/".$exp_file),
1508  'date' => $date->get(IL_CAL_DATETIME)
1509  ));
1510  }
1511  }
1512 
1513  include_once "./Modules/Survey/classes/tables/class.ilSurveyExportTableGUI.php";
1514  $table_gui = new ilSurveyExportTableGUI($this, 'export', true);
1515  $table_gui->setData($data);
1516  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1517  }
1518 
1519 
1524  {
1525  ilUtil::sendInfo($this->lng->txt('msg_cancel'), true);
1526  $this->ctrl->redirect($this, "export");
1527  }
1528 
1529 
1533  public function deleteExportFileObject()
1534  {
1535  $export_dir = $this->object->getExportDirectory();
1536  foreach ($_POST["file"] as $file)
1537  {
1538  $file = basename($file);
1539 
1540  $exp_file = $export_dir."/".$file;
1541  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
1542  if (@is_file($exp_file))
1543  {
1544  unlink($exp_file);
1545  }
1546  if (@is_dir($exp_dir))
1547  {
1548  include_once "./Services/Utilities/classes/class.ilUtil.php";
1549  ilUtil::delDir($exp_dir);
1550  }
1551  }
1552  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
1553  $this->ctrl->redirect($this, "export");
1554  }
1555 
1556 
1557  //
1558  // INFOSCREEN
1559  //
1560 
1566  function infoScreenObject()
1567  {
1568  $this->ctrl->setCmd("showSummary");
1569  $this->ctrl->setCmdClass("ilinfoscreengui");
1570  $this->infoScreen();
1571  }
1572 
1576  function infoScreen()
1577  {
1578  global $ilAccess, $ilTabs, $ilUser, $ilToolbar;
1579 
1580  if (!$this->external_rater_360 &&
1581  !$ilAccess->checkAccess("visible", "", $this->ref_id))
1582  {
1583  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1584  }
1585 
1586  $ilTabs->activateTab("info_short");
1587 
1588  include_once "./Modules/Survey/classes/class.ilSurveyExecutionGUI.php";
1589  $output_gui =& new ilSurveyExecutionGUI($this->object);
1590 
1591  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1592  $info = new ilInfoScreenGUI($this);
1593  $info->enablePrivateNotes();
1594 
1595  // "active" survey?
1596  $canStart = $this->object->canStartSurvey(null, $this->external_rater_360);
1597 
1598  $showButtons = $canStart["result"];
1599  if (!$showButtons)
1600  {
1601  if($canStart["edit_settings"] &&
1602  $ilAccess->checkAccess("write", "", $this->ref_id))
1603  {
1604  $canStart["messages"][] = "<a href=\"".$this->ctrl->getLinkTarget($this, "properties")."\">&raquo; ".
1605  $this->lng->txt("survey_edit_settings")."</a>";
1606  }
1607  ilUtil::sendInfo(implode("<br />", $canStart["messages"]));
1608  }
1609 
1610  $big_button = false;
1611  if ($showButtons)
1612  {
1613  // closing survey?
1614  $is_appraisee = false;
1615  if($this->object->get360Mode() &&
1616  $this->object->isAppraisee($ilUser->getId()))
1617  {
1618  $info->addSection($this->lng->txt("survey_360_appraisee_info"));
1619 
1620  $appr_data = $this->object->getAppraiseesData();
1621  $appr_data = $appr_data[$ilUser->getId()];
1622  $info->addProperty($this->lng->txt("survey_360_raters_status_info"), $appr_data["finished"]);
1623 
1624  if(!$appr_data["closed"])
1625  {
1626  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1627  $button = ilLinkButton::getInstance();
1628  $button->setCaption("survey_360_appraisee_close_action");
1629  $button->setUrl($this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "confirmappraiseeclose"));
1630  $close_button_360 = '<div>'.$button->render().'</div>';
1631 
1632  $txt = "survey_360_appraisee_close_action_info";
1633  if($this->object->get360SkillService())
1634  {
1635  $txt .= "_skill";
1636  }
1637  $info->addProperty($this->lng->txt("status"),
1638  $close_button_360.$this->lng->txt($txt));
1639  }
1640  else
1641  {
1643 
1644  $dt = new ilDateTime($appr_data["closed"], IL_CAL_UNIX);
1645  $info->addProperty($this->lng->txt("status"),
1646  sprintf($this->lng->txt("survey_360_appraisee_close_action_status"),
1648  }
1649 
1650  $is_appraisee = true;
1651  }
1652 
1653 
1654  // handle code
1655 
1656  // validate incoming
1657  $code_input = false;
1658  $anonymous_code = $_POST["anonymous_id"];
1659  if ($anonymous_code)
1660  {
1661  $code_input = true;
1662  // if(!$this->object->isUnusedCode($anonymous_code, $ilUser->getId()))
1663  if(!$this->object->checkSurveyCode($anonymous_code)) // #15031 - valid as long survey is not finished
1664  {
1665  $anonymous_code = null;
1666  }
1667  else
1668  {
1669  // #15860
1670  $this->object->bindSurveyCodeToUser($ilUser->getId(), $anonymous_code);
1671  }
1672  }
1673  if ($anonymous_code)
1674  {
1675  $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code;
1676  }
1677  else
1678  {
1679  $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
1680  if($anonymous_code)
1681  {
1682  $code_input = true;
1683  }
1684  }
1685 
1686  // try to find code for current (registered) user from existing run
1687  if($this->object->getAnonymize() && !$anonymous_code)
1688  {
1689  $anonymous_code = $this->object->findCodeForUser($ilUser->getId());
1690  }
1691 
1692  // get existing runs for current user, might generate code
1693  $participant_status = $this->object->getUserSurveyExecutionStatus($anonymous_code);
1694  if($participant_status)
1695  {
1696  $anonymous_code = $participant_status["code"];
1697  $participant_status = $participant_status["runs"];
1698  }
1699 
1700  // (final) check for proper anonymous code
1701  if(!$this->object->isAccessibleWithoutCode() &&
1702  !$is_appraisee &&
1703  $code_input && // #11346
1704  (!$anonymous_code || !$this->object->isAnonymousKey($anonymous_code)))
1705  {
1706  $anonymous_code = null;
1707  ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used"));
1708  }
1709 
1710  // :TODO: really save in session?
1711  $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code;
1712 
1713  // code is mandatory and not given yet
1714  if(!$is_appraisee &&
1715  !$anonymous_code &&
1716  !$this->object->isAccessibleWithoutCode())
1717  {
1718  $info->setFormAction($this->ctrl->getFormAction($this, "infoScreen"));
1719  $info->addSection($this->lng->txt("anonymization"));
1720  $info->addProperty("", $this->lng->txt("anonymize_anonymous_introduction"));
1721  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_id"), "anonymous_id", "", 8, "infoScreen", $this->lng->txt("submit"), true);
1722  }
1723  else
1724  {
1725  // trunk/default
1726  if(!$this->object->get360Mode())
1727  {
1728  if($anonymous_code)
1729  {
1730  $info->addHiddenElement("anonymous_id", $anonymous_code);
1731  }
1732 
1733  $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymous_code);
1734  if ($survey_started === 1)
1735  {
1736  if($ilUser->getId() != ANONYMOUS_USER_ID)
1737  {
1738  if($this->object->hasViewOwnResults())
1739  {
1740  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1741  $button = ilLinkButton::getInstance();
1742  $button->setCaption("svy_view_own_results");
1743  $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
1744  $ilToolbar->addButtonInstance($button);
1745  }
1746 
1747  if($this->object->hasMailOwnResults())
1748  {
1749  if($this->object->hasViewOwnResults())
1750  {
1751  $ilToolbar->addSeparator();
1752  }
1753 
1754  require_once "Services/Form/classes/class.ilTextInputGUI.php";
1755  $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
1756  $mail->setSize(25);
1757  $mail->setValue($ilUser->getEmail());
1758  $ilToolbar->addInputItem($mail, true);
1759 
1760  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
1761 
1762  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
1763  $button = ilSubmitButton::getInstance();
1764  $button->setCaption("svy_mail_own_results");
1765  $button->setCommand("mailUserResults");
1766  $ilToolbar->addButtonInstance($button);
1767  }
1768  }
1769 
1770  ilUtil::sendInfo($this->lng->txt("already_completed_survey"));
1771  }
1772  elseif ($survey_started === 0)
1773  {
1774  $big_button = array("resume", $this->lng->txt("resume_survey"));
1775  }
1776  elseif ($survey_started === FALSE)
1777  {
1778  $big_button = array("start", $this->lng->txt("start_survey"));
1779  }
1780  }
1781  // 360°
1782  else
1783  {
1784  $appr_ids = array();
1785 
1786  // use given code (if proper external one)
1787  if($anonymous_code)
1788  {
1789  $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
1790  if($anonymous_id)
1791  {
1792  $appr_ids = $this->object->getAppraiseesToRate(0, $anonymous_id);
1793  }
1794  }
1795 
1796  // registered user
1797  // if an auto-code was generated, we still have to check for the original user id
1798  if(!$appr_ids && $ilUser->getId() != ANONYMOUS_USER_ID)
1799  {
1800  $appr_ids = $this->object->getAppraiseesToRate($ilUser->getId());
1801  }
1802 
1803  if(sizeof($appr_ids))
1804  {
1805  // map existing runs to appraisees
1806  $active_appraisees = array();
1807  if($participant_status)
1808  {
1809  foreach($participant_status as $item)
1810  {
1811  $active_appraisees[$item["appr_id"]] = $item["finished"];
1812  }
1813  }
1814 
1815  $list = array();
1816 
1817  foreach($appr_ids as $appr_id)
1818  {
1819  if($this->object->isAppraiseeClosed($appr_id))
1820  {
1821  // closed
1822  $list[$appr_id] = $this->lng->txt("survey_360_appraisee_is_closed");
1823  }
1824  else if(array_key_exists($appr_id, $active_appraisees))
1825  {
1826  // already done
1827  if($active_appraisees[$appr_id])
1828  {
1829  $list[$appr_id] = $this->lng->txt("already_completed_survey");
1830  }
1831  // resume
1832  else
1833  {
1834  $list[$appr_id] = array("resume", $this->lng->txt("resume_survey"));
1835  }
1836  }
1837  else
1838  {
1839  // start
1840  $list[$appr_id] = array("start", $this->lng->txt("start_survey"));
1841  }
1842  }
1843 
1844  $info->addSection($this->lng->txt("survey_360_rate_other_appraisees"));
1845 
1846  include_once "Services/User/classes/class.ilUserUtil.php";
1847  foreach($list as $appr_id => $item)
1848  {
1849  $appr_name = ilUserUtil::getNamePresentation($appr_id, false, false, "", true);
1850 
1851  if(!is_array($item))
1852  {
1853  $info->addProperty($appr_name, $item);
1854  }
1855  else
1856  {
1857  $this->ctrl->setParameter($output_gui, "appr_id", $appr_id);
1858  $href = $this->ctrl->getLinkTarget($output_gui, $item[0]);
1859  $this->ctrl->setParameter($output_gui, "appr_id", "");
1860 
1861  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1862  $button = ilLinkButton::getInstance();
1863  $button->setCaption($item[1], false);
1864  $button->setUrl($href);
1865  $big_button_360 = '<div>'.$button->render().'</div>';
1866 
1867  $info->addProperty($appr_name, $big_button_360);
1868  }
1869  }
1870  }
1871  else if(!$is_appraisee)
1872  {
1873  ilUtil::sendFailure($this->lng->txt("survey_360_no_appraisees"));
1874  }
1875  }
1876  }
1877 
1878  if($this->object->get360Mode() &&
1879  $this->object->get360SelfAppraisee() &&
1880  !$this->object->isAppraisee($ilUser->getId()) &&
1881  $ilUser->getId() != ANONYMOUS_USER_ID) // #14968
1882  {
1883  $link = $this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "addSelfAppraisee");
1884  $link = '<a href="'.$link.'">'.$this->lng->txt("survey_360_add_self_appraisee").'</a>';
1885  $info->addProperty("&nbsp;", $link);
1886  }
1887  }
1888 
1889  if($big_button)
1890  {
1891  $ilToolbar->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
1892 
1893  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
1894  $button = ilSubmitButton::getInstance();
1895  $button->setCaption($big_button[1], false);
1896  $button->setCommand($big_button[0]);
1897  $button->setPrimary(true);
1898  $ilToolbar->addButtonInstance($button);
1899 
1900  $ilToolbar->setCloseFormTag(false);
1901  $info->setOpenFormTag(false);
1902  }
1903  /* #12016
1904  else
1905  {
1906  $info->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen"));
1907  }
1908  */
1909 
1910  if (strlen($this->object->getIntroduction()))
1911  {
1912  $introduction = $this->object->getIntroduction();
1913  $info->addSection($this->lng->txt("introduction"));
1914  $info->addProperty("", $this->object->prepareTextareaOutput($introduction).
1915  "<br />".$info->getHiddenToggleButton());
1916  }
1917  else
1918  {
1919  $info->addSection("");
1920  $info->addProperty("", $info->getHiddenToggleButton());
1921  }
1922 
1923  $info->hideFurtherSections(false);
1924 
1925  if(!$this->object->get360Mode())
1926  {
1927  $info->addSection($this->lng->txt("svy_general_properties"));
1928 
1929  $info->addProperty($this->lng->txt("survey_results_anonymization"),
1930  !$this->object->hasAnonymizedResults()
1931  ? $this->lng->txt("survey_results_personalized_info")
1932  : $this->lng->txt("survey_results_anonymized_info"));
1933 
1934  include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php";
1935  if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
1936  ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
1937  {
1938  $info->addProperty($this->lng->txt("evaluation_access"), $this->lng->txt("evaluation_access_info"));
1939  }
1940  }
1941 
1942  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1943 
1944  $this->ctrl->forwardCommand($info);
1945  }
1946 
1947  function addLocatorItems()
1948  {
1949  global $ilLocator;
1950  switch ($this->ctrl->getCmd())
1951  {
1952  case "next":
1953  case "previous":
1954  case "start":
1955  case "resume":
1956  case "redirectQuestion":
1957  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1958  break;
1959  case "evaluation":
1960  case "checkEvaluationAccess":
1961  case "evaluationdetails":
1962  case "evaluationuser":
1963  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"), "", $_GET["ref_id"]);
1964  break;
1965  case "create":
1966  case "save":
1967  case "cancel":
1968  case "importFile":
1969  case "cloneAll":
1970  break;
1971  case "infoScreen":
1972  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1973  break;
1974  default:
1975  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
1976 
1977  // this has to be done here because ilSurveyEditorGUI is called after finalizing the locator
1978  if ((int)$_GET["q_id"] && !(int)$_REQUEST["new_for_survey"])
1979  {
1980  // not on create
1981  // see ilObjSurveyQuestionPool::addLocatorItems
1982  $q_id = (int)$_GET["q_id"];
1983  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1984  $q_type = SurveyQuestion::_getQuestionType($q_id)."GUI";
1985  $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
1986  $ilLocator->addItem(SurveyQuestion::_getTitle($q_id),
1987  $this->ctrl->getLinkTargetByClass(array("ilSurveyEditorGUI", $q_type), "editQuestion"));
1988  }
1989  break;
1990  }
1991  }
1992 
1993 
1994 
2000  public static function _goto($a_target, $a_access_code = "")
2001  {
2002  global $ilAccess, $ilErr, $lng;
2003 
2004  // see ilObjSurveyAccess::_checkGoto()
2005  include_once "./Services/Utilities/classes/class.ilUtil.php";
2006  if (strlen($a_access_code))
2007  {
2008  $_SESSION["anonymous_id"][ilObject::_lookupObjId($a_target)] = $a_access_code;
2009  $_GET["baseClass"] = "ilObjSurveyGUI";
2010  $_GET["cmd"] = "infoScreen";
2011  $_GET["ref_id"] = $a_target;
2012  include("ilias.php");
2013  exit;
2014  }
2015 
2016  if ($ilAccess->checkAccess("read", "", $a_target))
2017  {
2018  $_GET["baseClass"] = "ilObjSurveyGUI";
2019  $_GET["cmd"] = "infoScreen";
2020  $_GET["ref_id"] = $a_target;
2021  include("ilias.php");
2022  exit;
2023  }
2024  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2025  {
2026  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
2027  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2029  }
2030 
2031  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
2032  }
2033 
2034  public function getUserResultsTable($a_active_id)
2035  {
2036  $rtpl = new ilTemplate("tpl.svy_view_user_results.html", true, true, "Modules/Survey");
2037 
2038  $show_titles = (bool)$this->object->getShowQuestionTitles();
2039 
2040  foreach($this->object->getSurveyPages() as $page)
2041  {
2042  if(count($page) > 0)
2043  {
2044  // question block
2045  if(count($page) > 1)
2046  {
2047  if((bool)$page[0]["questionblock_show_blocktitle"])
2048  {
2049  $rtpl->setVariable("BLOCK_TITLE", trim($page[0]["questionblock_title"]));
2050  }
2051  }
2052 
2053  // questions
2054  foreach($page as $question)
2055  {
2056  $question_gui = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]);
2057  if(is_object($question_gui))
2058  {
2059  $rtpl->setCurrentBlock("question_bl");
2060 
2061  // heading
2062  if(strlen($question["heading"]))
2063  {
2064  $rtpl->setVariable("HEADING", trim($question["heading"]));
2065  }
2066 
2067  $rtpl->setVariable("QUESTION_DATA",
2068  $question_gui->getPrintView(
2069  $show_titles,
2070  (bool)$question["questionblock_show_questiontext"],
2071  $this->object->getId(),
2072  $this->object->loadWorkingData($question["question_id"], $a_active_id)
2073  )
2074  );
2075 
2076  $rtpl->parseCurrentBlock();
2077  }
2078  }
2079 
2080  $rtpl->setCurrentBlock("block_bl");
2081  $rtpl->parseCurrentBlock();
2082  }
2083  }
2084 
2085  return $rtpl->get();
2086  }
2087 
2088  protected function viewUserResultsObject()
2089  {
2090  global $ilUser, $tpl, $ilTabs;
2091 
2092  $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
2093  $active_id = $this->object->getActiveID($ilUser->getId(), $anonymous_code, 0);
2094  if($this->object->isSurveyStarted($ilUser->getId(), $anonymous_code) !== 1 ||
2095  !$active_id)
2096  {
2097  $this->ctrl->redirect($this, "infoScreen");
2098  }
2099 
2100  $ilTabs->clearTargets();
2101  $ilTabs->setBackTarget($this->lng->txt("btn_back"),
2102  $this->ctrl->getLinkTarget($this, "infoScreen"));
2103 
2104  $html = $this->getUserResultsTable($active_id);
2105  $tpl->setContent($html);
2106  }
2107 
2108  protected function getUserResultsPlain($a_active_id)
2109  {
2110  $res = array();
2111 
2112  $show_titles = (bool)$this->object->getShowQuestionTitles();
2113 
2114  foreach($this->object->getSurveyPages() as $page)
2115  {
2116  if(count($page) > 0)
2117  {
2118  $res[] = "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
2119 
2120  // question block
2121  if(count($page) > 1)
2122  {
2123  if((bool)$page[0]["questionblock_show_blocktitle"])
2124  {
2125  $res[$this->lng->txt("questionblock")] = trim($page[0]["questionblock_title"])."\n";
2126  }
2127  }
2128 
2129  // questions
2130 
2131  $page_res = array();
2132 
2133  foreach($page as $question)
2134  {
2135  $question_gui = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]);
2136  if(is_object($question_gui))
2137  {
2138  $question_parts = array();
2139 
2140  // heading
2141  if(strlen($question["heading"]))
2142  {
2143  $question_parts[$this->lng->txt("heading")] = trim($question["heading"]);
2144  }
2145 
2146  if($show_titles)
2147  {
2148  $question_parts[$this->lng->txt("title")] = trim($question["title"]);
2149  }
2150 
2151  if((bool)$question["questionblock_show_questiontext"])
2152  {
2153  $question_parts[$this->lng->txt("question")] = trim(strip_tags($question_gui->object->getQuestionText()));
2154  }
2155 
2156  $answers = $question_gui->getParsedAnswers(
2157  $this->object->loadWorkingData($question["question_id"], $a_active_id),
2158  true
2159  );
2160 
2161  if(sizeof($answers))
2162  {
2163  $multiline = false;
2164  if(sizeof($answers) > 1 ||
2165  get_class($question_gui) == "SurveyTextQuestionGUI")
2166  {
2167  $multiline = true;
2168  }
2169 
2170  $parts = array();
2171  foreach($answers as $answer)
2172  {
2173  $text = null;
2174  if($answer["textanswer"])
2175  {
2176  $text = ' ("'.$answer["textanswer"].'")';
2177  }
2178  if(!isset($answer["cols"]))
2179  {
2180  if(isset($answer["title"]))
2181  {
2182  $parts[] = $answer["title"].$text;
2183  }
2184  else if(isset($answer["value"]))
2185  {
2186  $parts[] = $answer["value"];
2187  }
2188  else if($text)
2189  {
2190  $parts[] = substr($text, 2, -1);
2191  }
2192  }
2193  // matrix
2194  else
2195  {
2196  $tmp = array();
2197  foreach($answer["cols"] as $col)
2198  {
2199  $tmp[] = $col["title"];
2200  }
2201  $parts[] = $answer["title"].": ".implode(", ", $tmp).$text;
2202  }
2203 
2204  }
2205  $question_parts[$this->lng->txt("answer")] =
2206  ($multiline ? "\n" : "").implode("\n", $parts);
2207  }
2208 
2209  $tmp = array();
2210  foreach($question_parts as $type => $value)
2211  {
2212  $tmp[] = $type.": ".$value;
2213  }
2214  $page_res[] = implode("\n", $tmp);
2215  }
2216  }
2217 
2218  $res[] = implode("\n\n-------------------------------\n\n", $page_res);
2219  }
2220  }
2221 
2222  $res[] = "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
2223 
2224  return implode("\n", $res);
2225  }
2226 
2227  public function sendUserResultsMail($a_active_id, $a_recipient)
2228  {
2229  global $ilUser;
2230 
2231  $finished = $this->object->getSurveyParticipants(array($a_active_id));
2232  $finished = array_pop($finished);
2233  $finished = ilDatePresentation::formatDate(new ilDateTime($finished["finished_tstamp"], IL_CAL_UNIX));
2234 
2235  require_once "Services/Mail/classes/class.ilMail.php";
2236  require_once "Services/Link/classes/class.ilLink.php";
2237 
2238  $body = ilMail::getSalutation($ilUser->getId())."\n\n";
2239  $body .= $this->lng->txt("svy_mail_own_results_body")."\n";
2240  $body .= "\n".$this->lng->txt("obj_svy").": ".$this->object->getTitle()."\n";
2241  $body .= ilLink::_getLink($this->object->getRefId(), "svy")."\n";
2242  $body .= "\n".$this->lng->txt("survey_results_finished").": ".$finished."\n\n";
2243 
2244  $body .= $this->getUserResultsPlain($a_active_id);
2245 
2246  // $body .= ilMail::_getAutoGeneratedMessageString($this->lng);
2248 
2249  require_once "Services/Mail/classes/class.ilMail.php";
2250  $mail = new ilMail(ANONYMOUS_USER_ID);
2251  $mail->sendMimeMail(
2252  $a_recipient,
2253  null,
2254  null,
2255  sprintf($this->lng->txt("svy_mail_own_results_subject"), $this->object->getTitle()),
2256  $body,
2257  null,
2258  true
2259  );
2260  }
2261 
2263  {
2264  global $ilUser;
2265 
2266  $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
2267  $active_id = $this->object->getActiveID($ilUser->getId(), $anonymous_code, 0);
2268  if($this->object->isSurveyStarted($ilUser->getId(), $anonymous_code) !== 1 ||
2269  !$active_id)
2270  {
2271  $this->ctrl->redirect($this, "infoScreen");
2272  }
2273 
2274  $recipient = $_POST["mail"];
2275  if(!ilUtil::is_email($recipient))
2276  {
2277  $this->ctrl->redirect($this, "infoScreen");
2278  }
2279 
2280  $this->sendUserResultsMail($active_id, $recipient);
2281 
2282  ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
2283  $this->ctrl->redirect($this, "infoScreen");
2284  }
2285 }
2286 
2287 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilSurveyParticipantsGUI.
static _lookupName($a_user_id)
lookup user name
This class represents an option in a radio group.
print $file
Survey skill service GUI class.
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
setDataSource($href, $a_delimiter=null)
set datasource link for js autocomplete
confirmDeleteExportFileObject()
confirmation screen for export file deletion
exit
Definition: login.php:54
static _goto($a_target, $a_access_code="")
redirect script
Class ilInfoScreenGUI.
$_POST['username']
Definition: cron.php:12
importFileObject()
form for new survey object import
const IL_CAL_DATETIME
Class ilSurveyEditorGUI.
This class represents an option in a checkbox group.
This class represents a selection list property in a property form.
resetTemplateObject()
Enable all settings - remove template.
const EVALUATION_ACCESS_OFF
This class represents a property form user interface.
GUI class for the workflow of copying objects.
static validateExternalRaterCode($a_ref_id, $a_code)
_getTitle($question_id)
Returns the question title of a question with a given id.
const EVALUATION_ACCESS_PARTICIPANTS
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
This class represents a section header in a property form.
Class ilSurveyConstraintsGUI.
This class represents a file property in a property form.
handleWriteAccess()
Checks for write access and returns to the parent object.
Class ilObject Basic functions for all objects.
$valid
$cmd
Definition: sahs_server.php:35
addObserver(&$a_class, $a_method, $a_element)
setValue($a_value)
Set Value.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static _lookupId($a_user_str)
lookup id by login
This class represents a checkbox property in a property form.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
getUserResultsPlain($a_active_id)
const IL_CAL_UNIX
setInfo($a_info)
Set Info.
initImportForm($a_new_type)
savePropertiesObject()
Save the survey properties.
static _getAllReferences($a_id)
get all reference ids of object
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
Auto completion class for user lists.
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
getTabs(&$tabs_gui)
adds tabs to tab gui object
setInfo($a_info)
Set Information Text.
Class ilObjSurveyGUI.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$section
Definition: Utf8Test.php:84
setChecked($a_checked)
Set Checked.
input GUI for a time span (start and end date)
addDidacticTemplateOptions(array &$a_options)
This class represents a property in a property form.
Class for single dates.
afterSave(ilObject $a_new_object)
save object public
const ANONYMIZE_FREEACCESS
Export class for surveys.
const NOTIFICATION_PARENT_COURSE
This class represents a number property in a property form.
Class Mail this class handles base functions for mail handling.
Survey execution graphical output.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
setValue($a_value)
Set Value.
special template class to simplify handling of ITX/PEAR
setSize($a_size)
Set Size.
This class represents a text property in a property form.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
static formatDate(ilDateTime $date)
Format a date public.
& getGeneral()
Definition: class.ilMD.php:55
Date and time handling
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
redirection script todo: (a better solution should control the processing via a xml file) ...
deleteExportFileObject()
delete export files
$results
setShowTime($a_showtime)
Set Show Time Information.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static lookupTitle($a_id)
Lookup title.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
const NOTIFICATION_INVITED_USERS
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
setOptions($a_options)
Set Options.
$txt
Definition: error.php:10
infoScreen()
show information screen
prepareOutput()
prepare output
evaluationObject()
Redirects the evaluation object call to the ilSurveyEvaluationGUI class.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const EVALUATION_ACCESS_ALL
enableDateActivation($a_title, $a_postvar, $a_checked=true)
Enable date activation.
sendUserResultsMail($a_active_id, $a_recipient)
const IL_CAL_DATE
propertiesObject(ilPropertyFormGUI $a_form=null)
Display and fill the properties form of the test.
confirmResetTemplateObject()
Enable all settings - Confirmation.
This class represents a non editable value in a property form.
global $ilUser
Definition: imgupload.php:15
_getQuestionType($question_id)
Returns the question type of a question with a given id.
& _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
_hasEvaluationAccess($a_obj_id, $user_id)
This class represents a text area property in a property form.
getCreationMode()
get creation mode
getRefId()
get reference id public
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
Survey skill determination GUI class.
cancelDeleteExportFileObject()
cancel deletion of export files
const IL_CAL_TIMESTAMP
Survey evaluation graphical output.
getUserResultsTable($a_active_id)
const ANONYMIZE_CODE_ALL
createExportFileObject()
create export file
setValue($a_value)
Set Value.
static redirect($a_script)
http redirect to other script
addHeaderAction()
Add header action menu.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
Settings template application class.
setRequired($a_required)
Set Required.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _getInstallationSignature()
Static getter for the installation signature.
downloadExportFileObject()
download export file
initPropertiesForm()
Init survey settings form.