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