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