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