ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.SettingsFormGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Survey\Settings;
22
27
33{
35 protected \ilObjectService $object_service;
36 protected \ilObjSurvey $survey;
39 protected \ILIAS\Survey\Mode\FeatureConfig $feature_config;
40 protected \ilRbacSystem $rbacsystem;
41 private \ilGlobalTemplateInterface $main_tpl;
42
43 public function __construct(
49 ) {
50 global $DIC;
51 $this->main_tpl = $DIC->ui()->mainTemplate();
52
53 $this->rbacsystem = $DIC->rbac()->system();
54
55 $this->survey = $survey;
56 $this->object_service = $object_service;
57 $this->ui_service = $ui_service;
58 $this->domain_service = $domain_service;
59 $this->modifier = $modifier;
60 $this->feature_config = $this->domain_service->modeFeatureConfig($survey->getMode());
61 }
62
63 public function checkForm(\ilPropertyFormGUI $form): bool
64 {
66 $lng = $this->ui_service->lng();
67
68 $valid = false;
69
70 if ($form->checkInput()) {
71 $valid = true;
72
73 if ($feature_config->supportsTutorNotification()) {
74 if ($form->getInput("tut")) {
75 $tut_ids = $this->getTutorIdsFromForm($form);
76 // check if given "tutors" have write permission
77 if (!$tut_ids) {
78 $tut_ids = $form->getItemByPostVar("tut_ids");
79 $tut_ids->setAlert($lng->txt("survey_notification_tutor_recipients_invalid"));
80 $valid = false;
81 }
82 }
83 if ($form->getInput("tut_res")) {
84 $end = $form->getItemByPostVar("end_date");
85 if (!$end->getDate()) {
86 $tut_res = $form->getItemByPostVar("tut_res");
87 $tut_res->setAlert($lng->txt("svy_notification_tutor_results_alert"));
88 $valid = false;
89 }
90
91 // check if given "tutors" have write permission
92 $tut_res_ids = $this->getTutorResIdsFromForm($form);
93 if (!$tut_res_ids) {
94 $tut_res_ids = $form->getItemByPostVar("tut_res_ids");
95 $tut_res_ids->setAlert($lng->txt("survey_notification_tutor_recipients_invalid"));
96 $valid = false;
97 }
98 }
99 }
100 }
101
102 return $valid;
103 }
104
109 protected function getTutorIdsFromForm(\ilPropertyFormGUI $form): array
110 {
113
114 $tut_ids = array();
115 $tut_logins = $form->getInput("tut_ids");
116 foreach ($tut_logins as $tut_login) {
117 $tut_id = \ilObjUser::_lookupId($tut_login);
118 if ($tut_id && $rbacsystem->checkAccessOfUser($tut_id, "write", $survey->getRefId())) {
119 $tut_ids[] = $tut_id;
120 }
121 }
122 return $tut_ids;
123 }
124
129 protected function getTutorResIdsFromForm(\ilPropertyFormGUI $form): array
130 {
133
134 $tut_res_ids = array();
135 $tut_logins = $form->getInput("tut_res_ids");
136 foreach ($tut_logins as $tut_login) {
137 $tut_id = \ilObjUser::_lookupId($tut_login);
138 if ($tut_id && $rbacsystem->checkAccessOfUser($tut_id, "write", $survey->getRefId())) {
139 $tut_res_ids[] = $tut_id;
140 }
141 }
142 return $tut_res_ids;
143 }
144
149 public function getForm(
150 string $target_class
152 $ctrl = $this->ui_service->ctrl();
153 $lng = $this->ui_service->lng();
154
155 $form = new \ilPropertyFormGUI();
156 $form->setFormAction($ctrl->getFormActionByClass(
157 $target_class
158 ));
159 $form->setId("survey_properties");
160
161 $form = $this->withGeneral($form);
162 $form = $this->withActivation($form);
163 $form = $this->withPresentation($form);
164 $form = $this->withBeforeStart($form);
165 $form = $this->withAccess($form);
166 $form = $this->withQuestionBehaviour($form);
167 $form = $this->withAfterEnd($form, $target_class);
168 $form = $this->withReminders($form);
169 $form = $this->withResults($form);
170 $form = $this->withOther($form);
171
172 $form->addCommandButton("saveProperties", $lng->txt("save"));
173
174 return $form;
175 }
176
180 public function withGeneral(
181 \ilPropertyFormGUI $form
183 $survey = $this->survey;
184 $lng = $this->ui_service->lng();
186
187 // general properties
188 $header = new \ilFormSectionHeaderGUI();
189 $header->setTitle($lng->txt("settings"));
190 $form->addItem($header);
191
192 // title & description (meta data)
193 //$md_obj = new ilMD($this->object->getId(), 0, "svy");
194 //$md_section = $md_obj->getGeneral();
195
196 $title = new \ilTextInputGUI($lng->txt("title"), "title");
197 $title->setRequired(true);
198 $title->setValue($survey->getTitle());
199 $form->addItem($title);
200
201 //$ids = $md_section->getDescriptionIds();
202 //if ($ids) {
203 // $desc_obj = $md_section->getDescription(array_pop($ids));
204
205 $desc = new \ilTextAreaInputGUI($lng->txt("description"), "description");
206 $desc->setRows(4);
207 $desc->setValue($survey->getLongDescription());
208 $form->addItem($desc);
209
210 $ne = new \ilNonEditableValueGUI($lng->txt("type"));
211 $ne->setValue(
212 $this->domain_service
213 ->modeProvider($survey->getMode())
214 ->getTitle()
215 );
216 $form->addItem($ne);
217
219 $self_rate = new \ilCheckboxInputGUI($lng->txt("survey_360_self_raters"), "self_rate");
220 $self_rate->setInfo($lng->txt("survey_360_self_raters_info"));
221 $self_rate->setChecked($survey->get360SelfRaters());
222 $form->addItem($self_rate);
223
224 $self_appr = new \ilCheckboxInputGUI($lng->txt("survey_360_self_appraisee"), "self_appr");
225 $self_appr->setInfo($lng->txt("survey_360_self_appraisee_info"));
226 $self_appr->setChecked($survey->get360SelfAppraisee());
227 $form->addItem($self_appr);
228 }
229
230 foreach ($this->modifier->getSurveySettingsGeneral($survey) as $item) {
231 $form->addItem($item);
232 }
233 return $form;
234 }
235
240 public function withActivation(
241 \ilPropertyFormGUI $form
243 $lng = $this->ui_service->lng();
244 $survey = $this->survey;
245
246 // activation
247 $lng->loadLanguageModule('rep');
248
249 $section = new \ilFormSectionHeaderGUI();
250 $section->setTitle($lng->txt('rep_activation_availability'));
251 $form->addItem($section);
252
253 // additional info only with multiple references
254 $act_obj_info = $act_ref_info = "";
255 if (count(\ilObject::_getAllReferences($survey->getId())) > 1) {
256 $act_obj_info = ' ' . $lng->txt('rep_activation_online_object_info');
257 $act_ref_info = $lng->txt('rep_activation_access_ref_info');
258 }
259
260 $online = new \ilCheckboxInputGUI($lng->txt('rep_activation_online'), 'online');
261 $online->setInfo($lng->txt('svy_activation_online_info') . $act_obj_info);
262 $online->setChecked(!$survey->getOfflineStatus());
263 $form->addItem($online);
264
265 $time_based_aval = new \ilCheckboxInputGUI($lng->txt('rep_time_based_availability'), 'time_based_avail');
266 $time_based_aval->setChecked(
267 (int) $survey->getActivationStartDate() > 0 ||
268 (int) $survey->getActivationEndDate() > 0
269 );
270 $form->addItem($time_based_aval);
271
272 $dur = new \ilDateDurationInputGUI($lng->txt('rep_time_period'), "access_period");
273 $dur->setShowTime(true);
274 $date = $survey->getActivationStartDate();
275 $dur->setStart($date
276 ? new \ilDateTime($date, IL_CAL_UNIX)
277 : null);
278 $date = $survey->getActivationEndDate();
279 $dur->setEnd($date
280 ? new \ilDateTime($date, IL_CAL_UNIX)
281 : null);
282 $time_based_aval->addSubItem($dur);
283
284 $visible = new \ilCheckboxInputGUI($lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
285 $visible->setInfo($lng->txt('svy_activation_limited_visibility_info'));
286 $visible->setChecked($survey->getActivationVisibility());
287 $time_based_aval->addSubItem($visible);
288
289 return $form;
290 }
291
295 public function withPresentation(
296 \ilPropertyFormGUI $form
298 $obj_service = $this->object_service;
299 $survey = $this->survey;
300 $lng = $this->ui_service->lng();
301
302 // presentation
303 $section = new \ilFormSectionHeaderGUI();
304 $section->setTitle($lng->txt('obj_presentation'));
305 $form->addItem($section);
306
307 // tile image
308 $obj_service->commonSettings()->legacyForm($form, $survey)->addTileImage();
309
310 return $form;
311 }
312
316 public function withBeforeStart(
317 \ilPropertyFormGUI $form
319 $survey = $this->survey;
320 $lng = $this->ui_service->lng();
321
322 $section = new \ilFormSectionHeaderGUI();
323 $section->setTitle($lng->txt('svy_settings_section_before_start'));
324 $form->addItem($section);
325
326 // introduction
327 $intro = new \ilTextAreaInputGUI($lng->txt("introduction"), "introduction");
328 $intro->setValue($survey->prepareTextareaOutput($survey->getIntroduction()));
329 $intro->setRows(10);
330 $intro->setCols(80);
331 $intro->setInfo($lng->txt("survey_introduction_info"));
332 if ((new \ilRTESettings($this->domain_service->lng(), $this->domain_service->user()))->getRichTextEditor() === "tinymce") {
333 $intro->setUseRte(true);
334 $intro->setRteTagSet("mini");
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_code"), "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 $mail_confirm = new \ilCheckboxInputGUI($lng->txt("svy_results_mail_confirm"), "mail_confirm");
436 $mail_confirm->setInfo($lng->txt("svy_results_mail_confirm_info"));
437 $mail_confirm->setChecked($survey->hasMailConfirmation());
438 $form->addItem($mail_confirm);
439
440 $mail_own = new \ilCheckboxInputGUI($lng->txt("svy_results_mail_own"), "mail_own");
441 $mail_own->setInfo($lng->txt("svy_results_mail_own_info"));
442 $mail_own->setChecked($survey->hasMailOwnResults());
443 $mail_confirm->addSubItem($mail_own);
444
445 // final statement
446 $finalstatement = new \ilTextAreaInputGUI($lng->txt("outro"), "outro");
447 $finalstatement->setValue($survey->prepareTextareaOutput($survey->getOutro()));
448 $finalstatement->setRows(10);
449 $finalstatement->setCols(80);
450 if ((new \ilRTESettings($this->domain_service->lng(), $this->domain_service->user()))->getRichTextEditor() === "tinymce") {
451 $finalstatement->setUseRte(true);
452 $finalstatement->setRteTagSet("mini");
453 }
454 $form->addItem($finalstatement);
455
456 // mail notification
457 $mailnotification = new \ilCheckboxInputGUI($lng->txt("mailnotification"), "mailnotification");
458 // $mailnotification->setOptionTitle($lng->txt("activate"));
459 $mailnotification->setInfo($lng->txt("svy_result_mail_notification_info")); // #11762
460 $mailnotification->setValue("1");
461 $mailnotification->setChecked($survey->getMailNotification());
462
463 // addresses
464 $mailaddresses = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "mailaddresses");
465 $mailaddresses->setValue($survey->getMailAddresses());
466 $mailaddresses->setSize(80);
467 $mailaddresses->setInfo($lng->txt('mailaddresses_info'));
468 $mailaddresses->setRequired(true);
469
470 // participant data
471 $participantdata = new \ilTextAreaInputGUI($lng->txt("mailparticipantdata"), "mailparticipantdata");
472 $participantdata->setValue($survey->getMailParticipantData());
473 $participantdata->setRows(6);
474 $participantdata->setCols(80);
475 $participantdata->setUseRte(false);
476 $participantdata->setInfo($lng->txt("mailparticipantdata_info"));
477
478 // #12755 - because of privacy concerns we restrict user data to a minimum
479 $placeholders = array(
480 "FIRST_NAME" => "firstname",
481 "LAST_NAME" => "lastname",
482 "LOGIN" => "login"
483 );
484 $txt = array();
485 foreach ($placeholders as $placeholder => $caption) {
486 $txt[] = "[" . strtoupper($placeholder) . "]: " . $lng->txt($caption);
487 }
488 $txt = implode("<br />", $txt);
489 $participantdatainfo = new \ilNonEditableValueGUI($lng->txt("svy_placeholders_label"), "", true);
490 $participantdatainfo->setValue($lng->txt("mailparticipantdata_placeholder") . "<br />" . $txt);
491
492 $mailnotification->addSubItem($mailaddresses);
493 $mailnotification->addSubItem($participantdata);
494 $mailnotification->addSubItem($participantdatainfo);
495 $form->addItem($mailnotification);
496
497 // tutor notification - currently not available for 360°
499 $num_inv = count($invitation_manager->getAllForSurvey($survey->getSurveyId()));
500
501 // notification, if "all participants" have finished the survey
502 $tut = new \ilCheckboxInputGUI($lng->txt("survey_notification_tutor_setting"), "tut");
503 $tut->setChecked($survey->getTutorNotificationStatus());
504 $form->addItem($tut);
505
506 $tut_logins = array();
507 $tuts = $survey->getTutorNotificationRecipients();
508 if ($tuts) {
509 foreach ($tuts as $tut_id) {
510 $tmp = \ilObjUser::_lookupName((int) $tut_id);
511 if ($tmp["login"]) {
512 $tut_logins[] = $tmp["login"];
513 }
514 }
515 }
516 $tut_ids = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "tut_ids");
517 $tut_ids->setDataSource($ctrl->getLinkTargetByClass($target_class, "doAutoComplete", "", true));
518 $tut_ids->setRequired(true);
519 $tut_ids->setMulti(true);
520 $tut_ids->setMultiValues($tut_logins);
521 $tut_ids->setValue(array_shift($tut_logins));
522 $tut->addSubItem($tut_ids);
523
524 // radio to define who are "all participants"
525 $tut_grp = new \ilRadioGroupInputGUI($lng->txt("survey_notification_target_group"), "tut_grp");
526 $tut_grp->setRequired(true);
527 $tut_grp->setValue((string) $survey->getTutorNotificationTarget());
528 $tut->addSubItem($tut_grp);
529
530 // (a) ... the member of the parent group or course
531 $tut_grp_crs = new \ilRadioOption(
532 $lng->txt("survey_notification_target_group_parent_course"),
534 );
535 if (!$this->hasGroupCourseParent()) {
536 $tut_grp_crs->setInfo($lng->txt("survey_notification_target_group_parent_course_inactive"));
537 } else {
538 $tut_grp_crs->setInfo(sprintf(
539 $lng->txt("survey_notification_target_group_invited_info"),
540 count($survey->getNotificationTargetUserIds(false))
541 ));
542 }
543 $tut_grp->addOption($tut_grp_crs);
544
545 // (b) ... all invited users
546 $tut_grp_inv = new \ilRadioOption(
547 $lng->txt("survey_notification_target_group_invited"),
549 );
550 $tut_grp_inv->setInfo(sprintf($lng->txt("survey_notification_target_group_invited_info"), $num_inv));
551 $tut_grp->addOption($tut_grp_inv);
552
553 /*
554 $tut_res = new \ilCheckboxInputGUI($lng->txt("svy_notification_tutor_results"), "tut_res");
555 $tut_res->setInfo($lng->txt("svy_notification_tutor_results_info"));
556 $tut_res->setChecked($survey->getTutorResultsStatus());
557 $form->addItem($tut_res);
558
559 $tut_res_logins = array();
560 $tuts = $survey->getTutorResultsRecipients();
561 if ($tuts) {
562 foreach ($tuts as $tut_id) {
563 $tmp = \ilObjUser::_lookupName((int) $tut_id);
564 if ($tmp["login"]) {
565 $tut_res_logins[] = $tmp["login"];
566 }
567 }
568 }
569 $tut_res_ids = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "tut_res_ids");
570 $tut_res_ids->setDataSource(
571 $ctrl->getLinkTargetByClass(
572 $target_class,
573 "doAutoComplete",
574 "",
575 true
576 )
577 );
578 $tut_res_ids->setRequired(true);
579 $tut_res_ids->setMulti(true);
580 $tut_res_ids->setMultiValues($tut_res_logins);
581 $tut_res_ids->setValue(array_shift($tut_res_logins));
582 $tut_res->addSubItem($tut_res_ids);*/
583 }
584
585 return $form;
586 }
587
591 protected function hasGroupCourseParent(): bool
592 {
593 $survey = $this->survey;
594
595 $tree = $this->domain_service->repositoryTree();
596 $has_parent = $tree->checkForParentType($survey->getRefId(), "grp");
597 if (!$has_parent) {
598 $has_parent = $tree->checkForParentType($survey->getRefId(), "crs");
599 }
600 return (bool) $has_parent;
601 }
602
606 public function withReminders(
607 \ilPropertyFormGUI $form
609 $survey = $this->survey;
610 $lng = $this->ui_service->lng();
612 $invitation_manager = $this->domain_service->participants()->invitations();
613
614 // reminders
615
616 $info = new \ilFormSectionHeaderGUI();
617 $info->setTitle($lng->txt("svy_settings_section_reminders"));
618 $form->addItem($info);
619
620 $rmd = new \ilCheckboxInputGUI($lng->txt("survey_reminder_setting"), "rmd");
621 $rmd->setChecked($survey->getReminderStatus());
622 $form->addItem($rmd);
623
624 $rmd_start = new \ilDateTimeInputGUI($lng->txt("survey_reminder_start"), "rmd_start");
625 $rmd_start->setRequired(true);
626 $start = $survey->getReminderStart();
627 if ($start) {
628 $rmd_start->setDate($start);
629 }
630 $rmd->addSubItem($rmd_start);
631
632 $end = $survey->getReminderEnd();
633 $rmd_end = new \ilDateTimeInputGUI($lng->txt("survey_reminder_end"), "rmd_end");
634 if ($end) {
635 $rmd_end->setDate($end);
636 }
637 $rmd->addSubItem($rmd_end);
638
639 $rmd_freq = new \ilNumberInputGUI($lng->txt("survey_reminder_frequency"), "rmd_freq");
640 $rmd_freq->setRequired(true);
641 $rmd_freq->setSize(3);
642 $rmd_freq->setSuffix($lng->txt("survey_reminder_frequency_days"));
643 $rmd_freq->setValue((string) $survey->getReminderFrequency());
644 $rmd_freq->setMinValue(1);
645 $rmd->addSubItem($rmd_freq);
646
648 $rmd_grp = new \ilRadioGroupInputGUI($lng->txt("survey_notification_target_group"), "rmd_grp");
649 $rmd_grp->setRequired(true);
650 $rmd_grp->setValue((string) $survey->getReminderTarget());
651 $rmd->addSubItem($rmd_grp);
652
653 $rmd_grp_crs = new \ilRadioOption(
654 $lng->txt("survey_notification_target_group_parent_course"),
656 );
657 if (!$this->hasGroupCourseParent()) {
658 $rmd_grp_crs->setInfo($lng->txt("survey_notification_target_group_parent_course_inactive"));
659 } else {
660 $rmd_grp_crs->setInfo(sprintf(
661 $lng->txt("survey_notification_target_group_invited_info"),
662 count($survey->getNotificationTargetUserIds(false))
663 ));
664 }
665 $rmd_grp->addOption($rmd_grp_crs);
666
667 $rmd_grp_inv = new \ilRadioOption(
668 $lng->txt("survey_notification_target_group_invited"),
670 );
671 $num_inv = count($invitation_manager->getAllForSurvey($survey->getSurveyId()));
672 $rmd_grp_inv->setInfo(sprintf($lng->txt("survey_notification_target_group_invited_info"), $num_inv));
673 $rmd_grp->addOption($rmd_grp_inv);
674
675 $mtmpl = $survey->getReminderMailTemplates();
676 if ($mtmpl) {
677 $rmdt = new \ilRadioGroupInputGUI($lng->txt("svy_reminder_mail_template"), "rmdt");
678 $rmdt->setRequired(true);
679 $rmdt->addOption(new \ilRadioOption($lng->txt("svy_reminder_mail_template_none"), "-1"));
680 foreach ($mtmpl as $mtmpl_id => $mtmpl_caption) {
681 $option = new \ilRadioOption($mtmpl_caption, (string) $mtmpl_id);
682 $rmdt->addOption($option);
683 }
684
685 $reminderTemplateValue = -1;
686 if ($survey->getReminderTemplate()) {
687 $reminderTemplateValue = $survey->getReminderTemplate();
688 }
689 $rmdt->setValue((string) $reminderTemplateValue);
690 $rmd->addSubItem($rmdt);
691 }
692 }
693
694 foreach ($this->modifier->getSurveySettingsReminderTargets(
695 $survey,
696 $this->ui_service
697 ) as $item) {
698 $rmd->addSubItem($item);
699 }
700
701 return $form;
702 }
703
707 public function withResults(
708 \ilPropertyFormGUI $form
710 $lng = $this->ui_service->lng();
711 $survey = $this->survey;
713
714 // results
715
716 $results = new \ilFormSectionHeaderGUI();
717 $results->setTitle($lng->txt("results"));
718 $form->addItem($results);
719
721 // calculate sum score
722 $sum_score = new \ilCheckboxInputGUI($lng->txt("survey_calculate_sum_score"), "calculate_sum_score");
723 $sum_score->setInfo($lng->txt("survey_calculate_sum_score_info"));
724 $sum_score->setValue("1");
725 $sum_score->setChecked($survey->getCalculateSumScore());
726 $form->addItem($sum_score);
727 }
728
729 foreach ($this->modifier->getSurveySettingsResults(
730 $survey,
731 $this->ui_service
732 ) as $item) {
733 $form->addItem($item);
734 }
735
736 return $form;
737 }
738
742 public function withOther(
743 \ilPropertyFormGUI $form
745 $lng = $this->ui_service->lng();
746 $survey = $this->survey;
748
749 $other_items = [];
750
751 // competence service activation for 360 mode
752
753 $skmg_set = new \ilSkillManagementSettings();
754
755 if ($feature_config->supportsCompetences() && $skmg_set->isActivated()) {
756 $skill_service = new \ilCheckboxInputGUI($lng->txt("survey_activate_skill_service"), "skill_service");
757 $skill_service->setInfo($lng->txt("survey_activate_skill_service_info"));
758 $skill_service->setChecked($survey->getSkillService());
759 $other_items[] = $skill_service;
760 }
761
762 $position_settings = \ilOrgUnitGlobalSettings::getInstance()
763 ->getObjectPositionSettingsByType($survey->getType());
764
765 if (count($other_items) > 0 ||
766 $position_settings->isActive()
767 ) {
768 $feat = new \ilFormSectionHeaderGUI();
769 $feat->setTitle($lng->txt('obj_features'));
770 $form->addItem($feat);
771
772 foreach ($other_items as $item) {
773 $form->addItem($item);
774 }
775 }
776
777 if ($position_settings->isActive()) {
778 // add orgunit settings
780 $survey->getId(),
781 $form,
782 array(
784 )
785 );
786 }
787
788 return $form;
789 }
790
791 public function saveForm(
792 \ilPropertyFormGUI $form
793 ): void {
794 $survey = $this->survey;
796 $obj_service = $this->object_service;
797 $lng = $this->ui_service->lng();
798
799 if ($form->getInput("rmd")) {
800 $rmd_start = $form->getItemByPostVar("rmd_start")->getDate();
801 $rmd_end = $form->getItemByPostVar("rmd_end")->getDate();
802 if ($rmd_end && $rmd_start->get(IL_CAL_UNIX) > $rmd_end->get(IL_CAL_UNIX)) {
803 $tmp = $rmd_start;
804 $rmd_start = $rmd_end;
805 $rmd_end = $tmp;
806 }
807 $survey->setReminderStatus(true);
808 $survey->setReminderStart($rmd_start);
809 $survey->setReminderEnd($rmd_end);
810 $survey->setReminderFrequency((int) $form->getInput("rmd_freq"));
812 $survey->setReminderTarget((int) $form->getInput("rmd_grp"));
813 $survey->setReminderTemplate(($form->getInput("rmdt") > 0)
814 ? (int) $form->getInput("rmdt")
815 : null);
816 }
817 } else {
818 $survey->setReminderStatus(false);
819 }
820
822 // "one mail after all participants finished"
823 if ($form->getInput("tut")) {
824 $tut_ids = $this->getTutorIdsFromForm($form);
825 $survey->setTutorNotificationStatus(true);
826 $survey->setTutorNotificationRecipients($tut_ids); // see above
827 $survey->setTutorNotificationTarget((int) $form->getInput("tut_grp"));
828 } else {
829 $survey->setTutorNotificationStatus(false);
830 }
831
832 /*
833 if ($form->getInput("tut_res")) {
834 $tut_res_ids = $this->getTutorResIdsFromForm($form);
835 $survey->setTutorResultsStatus(true);
836 $survey->setTutorResultsRecipients($tut_res_ids); // see above
837 } else {
838 $survey->setTutorResultsStatus(false);
839 }*/
840 }
841
842 // #10055
843 if ($form->getInput('online') && count($survey->questions) === 0) {
844 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("cannot_switch_to_online_no_questions"), true);
845 } else {
846 $survey->setOfflineStatus(!$form->getInput('online'));
847 }
848
849 $survey->setMailOwnResults((bool) $form->getInput("mail_own"));
850 $survey->setMailConfirmation((bool) $form->getInput("mail_confirm"));
851
852 // both are saved in object, too
853 $survey->setTitle($form->getInput('title'));
854 $survey->setDescription($form->getInput('description'));
855 $survey->update();
856
857 // activation
858 $period = $form->getItemByPostVar("access_period");
859 $tb = $form->getInput("time_based_avail");
860 if ($tb && $period->getStart() && $period->getEnd()) {
861 $survey->setActivationLimited(true);
862 $survey->setActivationVisibility((bool) $form->getInput("access_visiblity"));
863 $survey->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
864 $survey->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
865 } else {
866 $survey->setActivationLimited(false);
867 }
868
869 // tile image
870 $obj_service->commonSettings()->legacyForm($form, $survey)->saveTileImage();
871
872 $start = $form->getItemByPostVar("start_date");
873 if ($start->getDate()) {
874 $datetime = explode(" ", $start->getDate()->get(IL_CAL_DATETIME));
875 $survey->setStartDateAndTime($datetime[0], $datetime[1]);
876 } else {
877 $survey->setStartDate("");
878 }
879
880 $end = $form->getItemByPostVar("end_date");
881 if ($end->getDate()) {
882 $datetime = explode(" ", $end->getDate()->get(IL_CAL_DATETIME));
883 $survey->setEndDateAndTime($datetime[0], $datetime[1]);
884 } else {
885 $survey->setEndDate("");
886 }
887
888 $purifier = new ilSvyStandardPurifier();
889
890 $introduction = $form->getInput("introduction");
891 $introduction = $purifier->purify($introduction);
892 $survey->setIntroduction($introduction);
893 $outro = $form->getInput("outro");
894 $outro = $purifier->purify($outro);
895 $survey->setOutro($outro);
896 $survey->setShowQuestionTitles((bool) $form->getInput("show_question_titles"));
897
898 // "separate mail for each participant finished"
899 $survey->setMailNotification((bool) $form->getInput('mailnotification'));
900 $survey->setMailAddresses($form->getInput('mailaddresses'));
901 $survey->setMailParticipantData($form->getInput('mailparticipantdata'));
902
904 $survey->set360SelfAppraisee((bool) $form->getInput("self_appr"));
905 $survey->set360SelfRaters((bool) $form->getInput("self_rate"));
906 }
907
909 $survey->setSkillService((bool) $form->getInput("skill_service"));
910 }
911
912 foreach ($this->modifier->getSurveySettingsResults(
913 $survey,
914 $this->ui_service
915 ) as $item) {
916 $this->modifier->setValuesFromForm($survey, $form);
917 }
918
919 $survey->saveToDb();
920
922 $survey->getId(),
923 $form,
924 array(
926 )
927 );
928 }
929}
$datetime
withAfterEnd(\ilPropertyFormGUI $form, string $target_class)
add "after ending" section
withGeneral(\ilPropertyFormGUI $form)
add general section
withAccess(\ilPropertyFormGUI $form)
add access section
__construct(InternalGUIService $ui_service, InternalDomainService $domain_service, \ilObjectService $object_service, \ilObjSurvey $survey, UIModifier $modifier)
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)
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
const NOTIFICATION_INVITED_USERS
const NOTIFICATION_PARENT_COURSE
static _hasDatasets(int $survey_id)
static _lookupName(int $a_user_id)
static _lookupId(string|array $a_user_str)
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 class represents an option in a radio group.
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
$valid
$info
Definition: entry_point.php:21
usesAppraisees()
If raters rate single persons (appraisees) this mode is activated.
global $lng
Definition: privfeed.php:31
$results
global $DIC
Definition: shib_login.php:26