ILIAS  release_8 Revision v8.24
class.SettingsFormGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21namespace ILIAS\Survey\Settings;
22
26
32{
34 protected \ilObjectServiceInterface $object_service;
35 protected \ilObjSurvey $survey;
38 protected \ILIAS\Survey\Mode\FeatureConfig $feature_config;
39 protected \ilRbacSystem $rbacsystem;
40 private \ilGlobalTemplateInterface $main_tpl;
41
42 public function __construct(
48 ) {
49 global $DIC;
50 $this->main_tpl = $DIC->ui()->mainTemplate();
51
52 $this->rbacsystem = $DIC->rbac()->system();
53
54 $this->survey = $survey;
55 $this->object_service = $object_service;
56 $this->ui_service = $ui_service;
57 $this->domain_service = $domain_service;
58 $this->modifier = $modifier;
59 $this->feature_config = $this->domain_service->modeFeatureConfig($survey->getMode());
60 }
61
62 public function checkForm(\ilPropertyFormGUI $form): bool
63 {
65 $lng = $this->ui_service->lng();
66
67 $valid = false;
68
69 if ($form->checkInput()) {
70 $valid = true;
71
72 if ($feature_config->supportsTutorNotification()) {
73 if ($form->getInput("tut")) {
74 $tut_ids = $this->getTutorIdsFromForm($form);
75 // check if given "tutors" have write permission
76 if (!$tut_ids) {
77 $tut_ids = $form->getItemByPostVar("tut_ids");
78 $tut_ids->setAlert($lng->txt("survey_notification_tutor_recipients_invalid"));
79 $valid = false;
80 }
81 }
82 if ($form->getInput("tut_res")) {
83 $end = $form->getItemByPostVar("end_date");
84 if (!$end->getDate()) {
85 $tut_res = $form->getItemByPostVar("tut_res");
86 $tut_res->setAlert($lng->txt("svy_notification_tutor_results_alert"));
87 $valid = false;
88 }
89
90 // check if given "tutors" have write permission
91 $tut_res_ids = $this->getTutorResIdsFromForm($form);
92 if (!$tut_res_ids) {
93 $tut_res_ids = $form->getItemByPostVar("tut_res_ids");
94 $tut_res_ids->setAlert($lng->txt("survey_notification_tutor_recipients_invalid"));
95 $valid = false;
96 }
97 }
98 }
99 }
100
101 return $valid;
102 }
103
108 protected function getTutorIdsFromForm(\ilPropertyFormGUI $form): array
109 {
112
113 $tut_ids = array();
114 $tut_logins = $form->getInput("tut_ids");
115 foreach ($tut_logins as $tut_login) {
116 $tut_id = \ilObjUser::_lookupId($tut_login);
117 if ($tut_id && $rbacsystem->checkAccessOfUser($tut_id, "write", $survey->getRefId())) {
118 $tut_ids[] = $tut_id;
119 }
120 }
121 return $tut_ids;
122 }
123
128 protected function getTutorResIdsFromForm(\ilPropertyFormGUI $form): array
129 {
132
133 $tut_res_ids = array();
134 $tut_logins = $form->getInput("tut_res_ids");
135 foreach ($tut_logins as $tut_login) {
136 $tut_id = \ilObjUser::_lookupId($tut_login);
137 if ($tut_id && $rbacsystem->checkAccessOfUser($tut_id, "write", $survey->getRefId())) {
138 $tut_res_ids[] = $tut_id;
139 }
140 }
141 return $tut_res_ids;
142 }
143
148 public function getForm(
149 string $target_class
151 $ctrl = $this->ui_service->ctrl();
152 $lng = $this->ui_service->lng();
153
154 $form = new \ilPropertyFormGUI();
155 $form->setFormAction($ctrl->getFormActionByClass(
156 $target_class
157 ));
158 $form->setId("survey_properties");
159
160 $form = $this->withGeneral($form);
161 $form = $this->withActivation($form);
162 $form = $this->withPresentation($form);
163 $form = $this->withBeforeStart($form);
164 $form = $this->withAccess($form);
165 $form = $this->withQuestionBehaviour($form);
166 $form = $this->withAfterEnd($form, $target_class);
167 $form = $this->withReminders($form);
168 $form = $this->withResults($form);
169 $form = $this->withOther($form);
170
171 $form->addCommandButton("saveProperties", $lng->txt("save"));
172
173 return $form;
174 }
175
179 public function withGeneral(
180 \ilPropertyFormGUI $form
182 $survey = $this->survey;
183 $lng = $this->ui_service->lng();
185
186 // general properties
187 $header = new \ilFormSectionHeaderGUI();
188 $header->setTitle($lng->txt("settings"));
189 $form->addItem($header);
190
191 // title & description (meta data)
192 //$md_obj = new ilMD($this->object->getId(), 0, "svy");
193 //$md_section = $md_obj->getGeneral();
194
195 $title = new \ilTextInputGUI($lng->txt("title"), "title");
196 $title->setRequired(true);
197 $title->setValue($survey->getTitle());
198 $form->addItem($title);
199
200 //$ids = $md_section->getDescriptionIds();
201 //if ($ids) {
202 // $desc_obj = $md_section->getDescription(array_pop($ids));
203
204 $desc = new \ilTextAreaInputGUI($lng->txt("description"), "description");
205 $desc->setRows(4);
206 $desc->setValue($survey->getLongDescription());
207 $form->addItem($desc);
208 //}
209
210 // pool usage
211 $pool_usage = new \ilRadioGroupInputGUI($lng->txt("survey_question_pool_usage"), "use_pool");
212 $opt = new \ilRadioOption($lng->txt("survey_question_pool_usage_active"), "1");
213 $opt->setInfo($lng->txt("survey_question_pool_usage_active_info"));
214 $pool_usage->addOption($opt);
215 $opt = new \ilRadioOption($lng->txt("survey_question_pool_usage_inactive"), "0");
216 $opt->setInfo($lng->txt("survey_question_pool_usage_inactive_info"));
217 $pool_usage->addOption($opt);
218 $pool_usage->setValue((string) (int) $survey->getPoolUsage());
219 $form->addItem($pool_usage);
220
222 $self_rate = new \ilCheckboxInputGUI($lng->txt("survey_360_self_raters"), "self_rate");
223 $self_rate->setInfo($lng->txt("survey_360_self_raters_info"));
224 $self_rate->setChecked($survey->get360SelfRaters());
225 $form->addItem($self_rate);
226
227 $self_appr = new \ilCheckboxInputGUI($lng->txt("survey_360_self_appraisee"), "self_appr");
228 $self_appr->setInfo($lng->txt("survey_360_self_appraisee_info"));
229 $self_appr->setChecked($survey->get360SelfAppraisee());
230 $form->addItem($self_appr);
231 }
232
233 foreach ($this->modifier->getSurveySettingsGeneral($survey) as $item) {
234 $form->addItem($item);
235 }
236 return $form;
237 }
238
243 public function withActivation(
244 \ilPropertyFormGUI $form
246 $lng = $this->ui_service->lng();
247 $survey = $this->survey;
248
249 // activation
250 $lng->loadLanguageModule('rep');
251
252 $section = new \ilFormSectionHeaderGUI();
253 $section->setTitle($lng->txt('rep_activation_availability'));
254 $form->addItem($section);
255
256 // additional info only with multiple references
257 $act_obj_info = $act_ref_info = "";
258 if (count(\ilObject::_getAllReferences($survey->getId())) > 1) {
259 $act_obj_info = ' ' . $lng->txt('rep_activation_online_object_info');
260 $act_ref_info = $lng->txt('rep_activation_access_ref_info');
261 }
262
263 $online = new \ilCheckboxInputGUI($lng->txt('rep_activation_online'), 'online');
264 $online->setInfo($lng->txt('svy_activation_online_info') . $act_obj_info);
265 $online->setChecked(!$survey->getOfflineStatus());
266 $form->addItem($online);
267
268 $dur = new \ilDateDurationInputGUI($lng->txt('rep_visibility_until'), "access_period");
269 $dur->setShowTime(true);
270 $date = $survey->getActivationStartDate();
271 $dur->setStart($date
272 ? new \ilDateTime($date, IL_CAL_UNIX)
273 : null);
274 $date = $survey->getActivationEndDate();
275 $dur->setEnd($date
276 ? new \ilDateTime($date, IL_CAL_UNIX)
277 : null);
278 $form->addItem($dur);
279
280 $visible = new \ilCheckboxInputGUI($lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
281 $visible->setInfo($lng->txt('svy_activation_limited_visibility_info'));
282 $visible->setChecked($survey->getActivationVisibility());
283 $dur->addSubItem($visible);
284
285 return $form;
286 }
287
291 public function withPresentation(
292 \ilPropertyFormGUI $form
294 $obj_service = $this->object_service;
295 $survey = $this->survey;
296 $lng = $this->ui_service->lng();
297
298 // presentation
299 $section = new \ilFormSectionHeaderGUI();
300 $section->setTitle($lng->txt('obj_presentation'));
301 $form->addItem($section);
302
303 // tile image
304 $obj_service->commonSettings()->legacyForm($form, $survey)->addTileImage();
305
306 return $form;
307 }
308
312 public function withBeforeStart(
313 \ilPropertyFormGUI $form
315 $survey = $this->survey;
316 $lng = $this->ui_service->lng();
317
318 $section = new \ilFormSectionHeaderGUI();
319 $section->setTitle($lng->txt('svy_settings_section_before_start'));
320 $form->addItem($section);
321
322 // introduction
323 $intro = new \ilTextAreaInputGUI($lng->txt("introduction"), "introduction");
324 $intro->setValue($survey->prepareTextareaOutput($survey->getIntroduction()));
325 $intro->setRows(10);
326 $intro->setCols(80);
327 $intro->setInfo($lng->txt("survey_introduction_info"));
328 if (\ilObjAdvancedEditing::_getRichTextEditor() === "tinymce") {
329 $intro->setUseRte(true);
330 $intro->setRteTags(\ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
331 $intro->addPlugin("latex");
332 $intro->addButton("latex");
333 $intro->addButton("pastelatex");
334 $intro->setRTESupport($survey->getId(), "svy", "survey", null);
335 }
336 $form->addItem($intro);
337
338 return $form;
339 }
340
344 public function withAccess(
345 \ilPropertyFormGUI $form
347 $survey = $this->survey;
348 $lng = $this->ui_service->lng();
350
351 // access
352
353 $section = new \ilFormSectionHeaderGUI();
354 $section->setTitle($lng->txt('svy_settings_section_access'));
355 $form->addItem($section);
356
357 // enable start date
358 $start = $survey->getStartDate();
359 // start date
360 $startingtime = new \ilDateTimeInputGUI($lng->txt("start_date"), 'start_date');
361 $startingtime->setShowTime(true);
362 if ($start) {
363 $startingtime->setDate(new \ilDateTime($start, IL_CAL_TIMESTAMP));
364 }
365 $form->addItem($startingtime);
366
367 // enable end date
368 $end = $survey->getEndDate();
369 // end date
370 $endingtime = new \ilDateTimeInputGUI($lng->txt("end_date"), 'end_date');
371 $endingtime->setShowTime(true);
372 if ($end) {
373 $endingtime->setDate(new \ilDateTime($end, IL_CAL_TIMESTAMP));
374 }
375 $form->addItem($endingtime);
376
377 // anonymization
379 $codes = new \ilCheckboxInputGUI($lng->txt("survey_access_codes"), "acc_codes");
380 $codes->setInfo($lng->txt("survey_access_codes_info"));
381 $codes->setChecked(!$survey->isAccessibleWithoutCode());
382 $form->addItem($codes);
383
384 if (\ilObjSurvey::_hasDatasets($survey->getSurveyId())) {
385 $codes->setDisabled(true);
386 }
387 }
388
389 return $form;
390 }
391
395 public function withQuestionBehaviour(
396 \ilPropertyFormGUI $form
398 $survey = $this->survey;
399 $lng = $this->ui_service->lng();
400
401 // question behaviour
402
403 $section = new \ilFormSectionHeaderGUI();
404 $section->setTitle($lng->txt('svy_settings_section_question_behaviour'));
405 $form->addItem($section);
406
407 // show question titles
408 $show_question_titles = new \ilCheckboxInputGUI($lng->txt("svy_show_questiontitles"), "show_question_titles");
409 $show_question_titles->setValue("1");
410 $show_question_titles->setChecked($survey->getShowQuestionTitles());
411 $form->addItem($show_question_titles);
412
413 return $form;
414 }
415
419 public function withAfterEnd(
420 \ilPropertyFormGUI $form,
421 string $target_class
423 $survey = $this->survey;
424 $lng = $this->ui_service->lng();
426 $ctrl = $this->ui_service->ctrl();
427 $invitation_manager = $this->domain_service->participants()->invitations();
428
429 // finishing
430
431 $info = new \ilFormSectionHeaderGUI();
432 $info->setTitle($lng->txt("svy_settings_section_finishing"));
433 $form->addItem($info);
434
435 $view_own = new \ilCheckboxInputGUI($lng->txt("svy_results_view_own"), "view_own");
436 $view_own->setInfo($lng->txt("svy_results_view_own_info"));
437 $view_own->setChecked($survey->hasViewOwnResults());
438 $form->addItem($view_own);
439
440 $mail_confirm = new \ilCheckboxInputGUI($lng->txt("svy_results_mail_confirm"), "mail_confirm");
441 $mail_confirm->setInfo($lng->txt("svy_results_mail_confirm_info"));
442 $mail_confirm->setChecked($survey->hasMailConfirmation());
443 $form->addItem($mail_confirm);
444
445 $mail_own = new \ilCheckboxInputGUI($lng->txt("svy_results_mail_own"), "mail_own");
446 $mail_own->setInfo($lng->txt("svy_results_mail_own_info"));
447 $mail_own->setChecked($survey->hasMailOwnResults());
448 $mail_confirm->addSubItem($mail_own);
449
450 // final statement
451 $finalstatement = new \ilTextAreaInputGUI($lng->txt("outro"), "outro");
452 $finalstatement->setValue($survey->prepareTextareaOutput($survey->getOutro()));
453 $finalstatement->setRows(10);
454 $finalstatement->setCols(80);
455 if (\ilObjAdvancedEditing::_getRichTextEditor() === "tinymce") {
456 $finalstatement->setUseRte(true);
457 $finalstatement->setRteTags(\ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
458 $finalstatement->addPlugin("latex");
459 $finalstatement->addButton("latex");
460 $finalstatement->addButton("pastelatex");
461 $finalstatement->setRTESupport($survey->getId(), "svy", "survey", null);
462 }
463 $form->addItem($finalstatement);
464
465 // mail notification
466 $mailnotification = new \ilCheckboxInputGUI($lng->txt("mailnotification"), "mailnotification");
467 // $mailnotification->setOptionTitle($lng->txt("activate"));
468 $mailnotification->setInfo($lng->txt("svy_result_mail_notification_info")); // #11762
469 $mailnotification->setValue("1");
470 $mailnotification->setChecked($survey->getMailNotification());
471
472 // addresses
473 $mailaddresses = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "mailaddresses");
474 $mailaddresses->setValue($survey->getMailAddresses());
475 $mailaddresses->setSize(80);
476 $mailaddresses->setInfo($lng->txt('mailaddresses_info'));
477 $mailaddresses->setRequired(true);
478
479 // participant data
480 $participantdata = new \ilTextAreaInputGUI($lng->txt("mailparticipantdata"), "mailparticipantdata");
481 $participantdata->setValue($survey->getMailParticipantData());
482 $participantdata->setRows(6);
483 $participantdata->setCols(80);
484 $participantdata->setUseRte(false);
485 $participantdata->setInfo($lng->txt("mailparticipantdata_info"));
486
487 // #12755 - because of privacy concerns we restrict user data to a minimum
488 $placeholders = array(
489 "FIRST_NAME" => "firstname",
490 "LAST_NAME" => "lastname",
491 "LOGIN" => "login"
492 );
493 $txt = array();
494 foreach ($placeholders as $placeholder => $caption) {
495 $txt[] = "[" . strtoupper($placeholder) . "]: " . $lng->txt($caption);
496 }
497 $txt = implode("<br />", $txt);
498 $participantdatainfo = new \ilNonEditableValueGUI($lng->txt("svy_placeholders_label"), "", true);
499 $participantdatainfo->setValue($lng->txt("mailparticipantdata_placeholder") . "<br />" . $txt);
500
501 $mailnotification->addSubItem($mailaddresses);
502 $mailnotification->addSubItem($participantdata);
503 $mailnotification->addSubItem($participantdatainfo);
504 $form->addItem($mailnotification);
505
506 // tutor notification - currently not available for 360°
508 $num_inv = count($invitation_manager->getAllForSurvey($survey->getSurveyId()));
509
510 // notification, if "all participants" have finished the survey
511 $tut = new \ilCheckboxInputGUI($lng->txt("survey_notification_tutor_setting"), "tut");
512 $tut->setChecked($survey->getTutorNotificationStatus());
513 $form->addItem($tut);
514
515 $tut_logins = array();
516 $tuts = $survey->getTutorNotificationRecipients();
517 if ($tuts) {
518 foreach ($tuts as $tut_id) {
519 $tmp = \ilObjUser::_lookupName((int) $tut_id);
520 if ($tmp["login"]) {
521 $tut_logins[] = $tmp["login"];
522 }
523 }
524 }
525 $tut_ids = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "tut_ids");
526 $tut_ids->setDataSource($ctrl->getLinkTargetByClass($target_class, "doAutoComplete", "", true));
527 $tut_ids->setRequired(true);
528 $tut_ids->setMulti(true);
529 $tut_ids->setMultiValues($tut_logins);
530 $tut_ids->setValue(array_shift($tut_logins));
531 $tut->addSubItem($tut_ids);
532
533 // radio to define who are "all participants"
534 $tut_grp = new \ilRadioGroupInputGUI($lng->txt("survey_notification_target_group"), "tut_grp");
535 $tut_grp->setRequired(true);
536 $tut_grp->setValue((string) $survey->getTutorNotificationTarget());
537 $tut->addSubItem($tut_grp);
538
539 // (a) ... the member of the parent group or course
540 $tut_grp_crs = new \ilRadioOption(
541 $lng->txt("survey_notification_target_group_parent_course"),
543 );
544 if (!$this->hasGroupCourseParent()) {
545 $tut_grp_crs->setInfo($lng->txt("survey_notification_target_group_parent_course_inactive"));
546 } else {
547 $tut_grp_crs->setInfo(sprintf(
548 $lng->txt("survey_notification_target_group_invited_info"),
549 count($survey->getNotificationTargetUserIds(false))
550 ));
551 }
552 $tut_grp->addOption($tut_grp_crs);
553
554 // (b) ... all invited users
555 $tut_grp_inv = new \ilRadioOption(
556 $lng->txt("survey_notification_target_group_invited"),
558 );
559 $tut_grp_inv->setInfo(sprintf($lng->txt("survey_notification_target_group_invited_info"), $num_inv));
560 $tut_grp->addOption($tut_grp_inv);
561
562 /*
563 $tut_res = new \ilCheckboxInputGUI($lng->txt("svy_notification_tutor_results"), "tut_res");
564 $tut_res->setInfo($lng->txt("svy_notification_tutor_results_info"));
565 $tut_res->setChecked($survey->getTutorResultsStatus());
566 $form->addItem($tut_res);
567
568 $tut_res_logins = array();
569 $tuts = $survey->getTutorResultsRecipients();
570 if ($tuts) {
571 foreach ($tuts as $tut_id) {
572 $tmp = \ilObjUser::_lookupName((int) $tut_id);
573 if ($tmp["login"]) {
574 $tut_res_logins[] = $tmp["login"];
575 }
576 }
577 }
578 $tut_res_ids = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "tut_res_ids");
579 $tut_res_ids->setDataSource(
580 $ctrl->getLinkTargetByClass(
581 $target_class,
582 "doAutoComplete",
583 "",
584 true
585 )
586 );
587 $tut_res_ids->setRequired(true);
588 $tut_res_ids->setMulti(true);
589 $tut_res_ids->setMultiValues($tut_res_logins);
590 $tut_res_ids->setValue(array_shift($tut_res_logins));
591 $tut_res->addSubItem($tut_res_ids);*/
592 }
593
594 return $form;
595 }
596
600 protected function hasGroupCourseParent(): bool
601 {
602 $survey = $this->survey;
603
604 $tree = $this->domain_service->repositoryTree();
605 $has_parent = $tree->checkForParentType($survey->getRefId(), "grp");
606 if (!$has_parent) {
607 $has_parent = $tree->checkForParentType($survey->getRefId(), "crs");
608 }
609 return (bool) $has_parent;
610 }
611
615 public function withReminders(
616 \ilPropertyFormGUI $form
618 $survey = $this->survey;
619 $lng = $this->ui_service->lng();
621 $invitation_manager = $this->domain_service->participants()->invitations();
622
623 // reminders
624
625 $info = new \ilFormSectionHeaderGUI();
626 $info->setTitle($lng->txt("svy_settings_section_reminders"));
627 $form->addItem($info);
628
629 $rmd = new \ilCheckboxInputGUI($lng->txt("survey_reminder_setting"), "rmd");
630 $rmd->setChecked($survey->getReminderStatus());
631 $form->addItem($rmd);
632
633 $rmd_start = new \ilDateTimeInputGUI($lng->txt("survey_reminder_start"), "rmd_start");
634 $rmd_start->setRequired(true);
635 $start = $survey->getReminderStart();
636 if ($start) {
637 $rmd_start->setDate($start);
638 }
639 $rmd->addSubItem($rmd_start);
640
641 $end = $survey->getReminderEnd();
642 $rmd_end = new \ilDateTimeInputGUI($lng->txt("survey_reminder_end"), "rmd_end");
643 if ($end) {
644 $rmd_end->setDate($end);
645 }
646 $rmd->addSubItem($rmd_end);
647
648 $rmd_freq = new \ilNumberInputGUI($lng->txt("survey_reminder_frequency"), "rmd_freq");
649 $rmd_freq->setRequired(true);
650 $rmd_freq->setSize(3);
651 $rmd_freq->setSuffix($lng->txt("survey_reminder_frequency_days"));
652 $rmd_freq->setValue((string) $survey->getReminderFrequency());
653 $rmd_freq->setMinValue(1);
654 $rmd->addSubItem($rmd_freq);
655
657 $rmd_grp = new \ilRadioGroupInputGUI($lng->txt("survey_notification_target_group"), "rmd_grp");
658 $rmd_grp->setRequired(true);
659 $rmd_grp->setValue((string) $survey->getReminderTarget());
660 $rmd->addSubItem($rmd_grp);
661
662 $rmd_grp_crs = new \ilRadioOption(
663 $lng->txt("survey_notification_target_group_parent_course"),
665 );
666 if (!$this->hasGroupCourseParent()) {
667 $rmd_grp_crs->setInfo($lng->txt("survey_notification_target_group_parent_course_inactive"));
668 } else {
669 $rmd_grp_crs->setInfo(sprintf(
670 $lng->txt("survey_notification_target_group_invited_info"),
671 count($survey->getNotificationTargetUserIds(false))
672 ));
673 }
674 $rmd_grp->addOption($rmd_grp_crs);
675
676 $rmd_grp_inv = new \ilRadioOption(
677 $lng->txt("survey_notification_target_group_invited"),
679 );
680 $num_inv = count($invitation_manager->getAllForSurvey($survey->getSurveyId()));
681 $rmd_grp_inv->setInfo(sprintf($lng->txt("survey_notification_target_group_invited_info"), $num_inv));
682 $rmd_grp->addOption($rmd_grp_inv);
683
684 $mtmpl = $survey->getReminderMailTemplates();
685 if ($mtmpl) {
686 $rmdt = new \ilRadioGroupInputGUI($lng->txt("svy_reminder_mail_template"), "rmdt");
687 $rmdt->setRequired(true);
688 $rmdt->addOption(new \ilRadioOption($lng->txt("svy_reminder_mail_template_none"), "-1"));
689 foreach ($mtmpl as $mtmpl_id => $mtmpl_caption) {
690 $option = new \ilRadioOption($mtmpl_caption, (string) $mtmpl_id);
691 $rmdt->addOption($option);
692 }
693
694 $reminderTemplateValue = -1;
695 if ($survey->getReminderTemplate()) {
696 $reminderTemplateValue = $survey->getReminderTemplate();
697 }
698 $rmdt->setValue((string) $reminderTemplateValue);
699 $rmd->addSubItem($rmdt);
700 }
701 }
702
703 foreach ($this->modifier->getSurveySettingsReminderTargets(
704 $survey,
705 $this->ui_service
706 ) as $item) {
707 $rmd->addSubItem($item);
708 }
709
710 return $form;
711 }
712
716 public function withResults(
717 \ilPropertyFormGUI $form
719 $lng = $this->ui_service->lng();
720 $survey = $this->survey;
722
723 // results
724
725 $results = new \ilFormSectionHeaderGUI();
726 $results->setTitle($lng->txt("results"));
727 $form->addItem($results);
728
730 // calculate sum score
731 $sum_score = new \ilCheckboxInputGUI($lng->txt("survey_calculate_sum_score"), "calculate_sum_score");
732 $sum_score->setInfo($lng->txt("survey_calculate_sum_score_info"));
733 $sum_score->setValue("1");
734 $sum_score->setChecked($survey->getCalculateSumScore());
735 $form->addItem($sum_score);
736 }
737
738 foreach ($this->modifier->getSurveySettingsResults(
739 $survey,
740 $this->ui_service
741 ) as $item) {
742 $form->addItem($item);
743 }
744
745 return $form;
746 }
747
751 public function withOther(
752 \ilPropertyFormGUI $form
754 $lng = $this->ui_service->lng();
755 $survey = $this->survey;
757
758 $other_items = [];
759
760 // competence service activation for 360 mode
761
762 $skmg_set = new \ilSkillManagementSettings();
763
764 if ($feature_config->supportsCompetences() && $skmg_set->isActivated()) {
765 $skill_service = new \ilCheckboxInputGUI($lng->txt("survey_activate_skill_service"), "skill_service");
766 $skill_service->setInfo($lng->txt("survey_activate_skill_service_info"));
767 $skill_service->setChecked($survey->getSkillService());
768 $other_items[] = $skill_service;
769 }
770
771 $position_settings = \ilOrgUnitGlobalSettings::getInstance()
772 ->getObjectPositionSettingsByType($survey->getType());
773
774 if (count($other_items) > 0 ||
775 $position_settings->isActive()
776 ) {
777 $feat = new \ilFormSectionHeaderGUI();
778 $feat->setTitle($lng->txt('obj_features'));
779 $form->addItem($feat);
780
781 foreach ($other_items as $item) {
782 $form->addItem($item);
783 }
784 }
785
786 if ($position_settings->isActive()) {
787 // add orgunit settings
789 $survey->getId(),
790 $form,
791 array(
793 )
794 );
795 }
796
797 return $form;
798 }
799
800 public function saveForm(
801 \ilPropertyFormGUI $form
802 ): void {
803 $survey = $this->survey;
805 $obj_service = $this->object_service;
806 $lng = $this->ui_service->lng();
807
808 if ($form->getInput("rmd")) {
809 $rmd_start = $form->getItemByPostVar("rmd_start")->getDate();
810 $rmd_end = $form->getItemByPostVar("rmd_end")->getDate();
811 if ($rmd_end && $rmd_start->get(IL_CAL_UNIX) > $rmd_end->get(IL_CAL_UNIX)) {
812 $tmp = $rmd_start;
813 $rmd_start = $rmd_end;
814 $rmd_end = $tmp;
815 }
816 $survey->setReminderStatus(true);
817 $survey->setReminderStart($rmd_start);
818 $survey->setReminderEnd($rmd_end);
819 $survey->setReminderFrequency((int) $form->getInput("rmd_freq"));
821 $survey->setReminderTarget((int) $form->getInput("rmd_grp"));
822 $survey->setReminderTemplate(($form->getInput("rmdt") > 0)
823 ? (int) $form->getInput("rmdt")
824 : null);
825 }
826 } else {
827 $survey->setReminderStatus(false);
828 }
829
831
832 // "one mail after all participants finished"
833 if ($form->getInput("tut")) {
834 $tut_ids = $this->getTutorIdsFromForm($form);
835 $survey->setTutorNotificationStatus(true);
836 $survey->setTutorNotificationRecipients($tut_ids); // see above
837 $survey->setTutorNotificationTarget((int) $form->getInput("tut_grp"));
838 } else {
839 $survey->setTutorNotificationStatus(false);
840 }
841
842 /*
843 if ($form->getInput("tut_res")) {
844 $tut_res_ids = $this->getTutorResIdsFromForm($form);
845 $survey->setTutorResultsStatus(true);
846 $survey->setTutorResultsRecipients($tut_res_ids); // see above
847 } else {
848 $survey->setTutorResultsStatus(false);
849 }*/
850 }
851
852 // #10055
853 if ($form->getInput('online') && count($survey->questions) === 0) {
854 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("cannot_switch_to_online_no_questions"), true);
855 } else {
856 $survey->setOfflineStatus(!$form->getInput('online'));
857 }
858
859 $survey->setViewOwnResults((bool) $form->getInput("view_own"));
860 $survey->setMailOwnResults((bool) $form->getInput("mail_own"));
861 $survey->setMailConfirmation((bool) $form->getInput("mail_confirm"));
862
863 // both are saved in object, too
864 $survey->setTitle($form->getInput('title'));
865 $survey->setDescription($form->getInput('description'));
866 $survey->update();
867
868 // activation
869 $period = $form->getItemByPostVar("access_period");
870 if ($period->getStart() && $period->getEnd()) {
871 $survey->setActivationLimited(true);
872 $survey->setActivationVisibility((bool) $form->getInput("access_visiblity"));
873 $survey->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
874 $survey->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
875 } else {
876 $survey->setActivationLimited(false);
877 }
878
879 // tile image
880 $obj_service->commonSettings()->legacyForm($form, $survey)->saveTileImage();
881
882 $start = $form->getItemByPostVar("start_date");
883 if ($start->getDate()) {
884 $datetime = explode(" ", $start->getDate()->get(IL_CAL_DATETIME));
885 $survey->setStartDateAndTime($datetime[0], $datetime[1]);
886 } else {
887 $survey->setStartDate("");
888 }
889
890 $end = $form->getItemByPostVar("end_date");
891 if ($end->getDate()) {
892 $datetime = explode(" ", $end->getDate()->get(IL_CAL_DATETIME));
893 $survey->setEndDateAndTime($datetime[0], $datetime[1]);
894 } else {
895 $survey->setEndDate("");
896 }
897 $survey->setIntroduction($form->getInput("introduction"));
898 $survey->setOutro($form->getInput("outro"));
899 $survey->setShowQuestionTitles((bool) $form->getInput("show_question_titles"));
900 $survey->setPoolUsage((bool) $form->getInput("use_pool"));
901
902 // "separate mail for each participant finished"
903 $survey->setMailNotification((bool) $form->getInput('mailnotification'));
904 $survey->setMailAddresses($form->getInput('mailaddresses'));
905 $survey->setMailParticipantData($form->getInput('mailparticipantdata'));
906
908 $survey->set360SelfAppraisee((bool) $form->getInput("self_appr"));
909 $survey->set360SelfRaters((bool) $form->getInput("self_rate"));
910 }
911
913 $survey->setSkillService((bool) $form->getInput("skill_service"));
914 }
915
916 foreach ($this->modifier->getSurveySettingsResults(
917 $survey,
918 $this->ui_service
919 ) as $item) {
920 $this->modifier->setValuesFromForm($survey, $form);
921 }
922
923 $survey->saveToDb();
924
926 $survey->getId(),
927 $form,
928 array(
930 )
931 );
932 }
933}
withAfterEnd(\ilPropertyFormGUI $form, string $target_class)
add "after ending" section
withGeneral(\ilPropertyFormGUI $form)
add general section
withAccess(\ilPropertyFormGUI $form)
add access section
withReminders(\ilPropertyFormGUI $form)
add reminders section
withResults(\ilPropertyFormGUI $form)
add results section
withActivation(\ilPropertyFormGUI $form)
add activation section
withBeforeStart(\ilPropertyFormGUI $form)
add "before start" section
getTutorResIdsFromForm(\ilPropertyFormGUI $form)
__construct(InternalGUIService $ui_service, InternalDomainService $domain_service, \ilObjectServiceInterface $object_service, \ilObjSurvey $survey, UIModifier $modifier)
withPresentation(\ilPropertyFormGUI $form)
add presentation section
withOther(\ilPropertyFormGUI $form)
add "other" section
hasGroupCourseParent()
Check for group course parent.
ILIAS Survey Mode FeatureConfig $feature_config
withQuestionBehaviour(\ilPropertyFormGUI $form)
add question behaviour section
const IL_CAL_TIMESTAMP
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
const NOTIFICATION_INVITED_USERS
const NOTIFICATION_PARENT_COURSE
static _hasDatasets(int $survey_id)
static _lookupId($a_user_str)
static _lookupName(int $a_user_id)
lookup user name
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static _getAllReferences(int $id)
get all reference ids for object ID
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
$valid
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
usesAppraisees()
If raters rate single persons (appraisees) this mode is activated.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$results
$lng