ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.SettingsFormGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Survey\Settings;
22 
26 
32 {
34  protected \ilObjectService $object_service;
35  protected \ilObjSurvey $survey;
36  protected UIModifier $modifier;
38  protected \ILIAS\Survey\Mode\FeatureConfig $feature_config;
39  protected \ilRbacSystem $rbacsystem;
40  private \ilGlobalTemplateInterface $main_tpl;
41 
42  public function __construct(
43  InternalGUIService $ui_service,
44  InternalDomainService $domain_service,
45  \ilObjectService $object_service,
46  \ilObjSurvey $survey,
47  UIModifier $modifier
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  {
64  $feature_config = $this->feature_config;
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  {
110  $rbacsystem = $this->rbacsystem;
111  $survey = $this->survey;
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  {
130  $rbacsystem = $this->rbacsystem;
131  $survey = $this->survey;
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
150  ): \ilPropertyFormGUI {
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
181  ): \ilPropertyFormGUI {
182  $survey = $this->survey;
183  $lng = $this->ui_service->lng();
184  $feature_config = $this->feature_config;
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  $ne = new \ilNonEditableValueGUI($lng->txt("type"));
210  $ne->setValue(
211  $this->domain_service
212  ->modeProvider($survey->getMode())
213  ->getTitle()
214  );
215  $form->addItem($ne);
216 
217  if ($feature_config->usesAppraisees()) {
218  $self_rate = new \ilCheckboxInputGUI($lng->txt("survey_360_self_raters"), "self_rate");
219  $self_rate->setInfo($lng->txt("survey_360_self_raters_info"));
220  $self_rate->setChecked($survey->get360SelfRaters());
221  $form->addItem($self_rate);
222 
223  $self_appr = new \ilCheckboxInputGUI($lng->txt("survey_360_self_appraisee"), "self_appr");
224  $self_appr->setInfo($lng->txt("survey_360_self_appraisee_info"));
225  $self_appr->setChecked($survey->get360SelfAppraisee());
226  $form->addItem($self_appr);
227  }
228 
229  foreach ($this->modifier->getSurveySettingsGeneral($survey) as $item) {
230  $form->addItem($item);
231  }
232  return $form;
233  }
234 
239  public function withActivation(
240  \ilPropertyFormGUI $form
241  ): \ilPropertyFormGUI {
242  $lng = $this->ui_service->lng();
243  $survey = $this->survey;
244 
245  // activation
246  $lng->loadLanguageModule('rep');
247 
248  $section = new \ilFormSectionHeaderGUI();
249  $section->setTitle($lng->txt('rep_activation_availability'));
250  $form->addItem($section);
251 
252  // additional info only with multiple references
253  $act_obj_info = $act_ref_info = "";
254  if (count(\ilObject::_getAllReferences($survey->getId())) > 1) {
255  $act_obj_info = ' ' . $lng->txt('rep_activation_online_object_info');
256  $act_ref_info = $lng->txt('rep_activation_access_ref_info');
257  }
258 
259  $online = new \ilCheckboxInputGUI($lng->txt('rep_activation_online'), 'online');
260  $online->setInfo($lng->txt('svy_activation_online_info') . $act_obj_info);
261  $online->setChecked(!$survey->getOfflineStatus());
262  $form->addItem($online);
263 
264  $time_based_aval = new \ilCheckboxInputGUI($lng->txt('rep_time_based_availability'), 'time_based_avail');
265  $time_based_aval->setChecked(
266  (int) $survey->getActivationStartDate() > 0 ||
267  (int) $survey->getActivationEndDate() > 0
268  );
269  $form->addItem($time_based_aval);
270 
271  $dur = new \ilDateDurationInputGUI($lng->txt('rep_time_period'), "access_period");
272  $dur->setShowTime(true);
273  $date = $survey->getActivationStartDate();
274  $dur->setStart($date
275  ? new \ilDateTime($date, IL_CAL_UNIX)
276  : null);
277  $date = $survey->getActivationEndDate();
278  $dur->setEnd($date
279  ? new \ilDateTime($date, IL_CAL_UNIX)
280  : null);
281  $time_based_aval->addSubItem($dur);
282 
283  $visible = new \ilCheckboxInputGUI($lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
284  $visible->setInfo($lng->txt('svy_activation_limited_visibility_info'));
285  $visible->setChecked($survey->getActivationVisibility());
286  $time_based_aval->addSubItem($visible);
287 
288  return $form;
289  }
290 
294  public function withPresentation(
295  \ilPropertyFormGUI $form
296  ): \ilPropertyFormGUI {
297  $obj_service = $this->object_service;
298  $survey = $this->survey;
299  $lng = $this->ui_service->lng();
300 
301  // presentation
302  $section = new \ilFormSectionHeaderGUI();
303  $section->setTitle($lng->txt('obj_presentation'));
304  $form->addItem($section);
305 
306  // tile image
307  $obj_service->commonSettings()->legacyForm($form, $survey)->addTileImage();
308 
309  return $form;
310  }
311 
315  public function withBeforeStart(
316  \ilPropertyFormGUI $form
317  ): \ilPropertyFormGUI {
318  $survey = $this->survey;
319  $lng = $this->ui_service->lng();
320 
321  $section = new \ilFormSectionHeaderGUI();
322  $section->setTitle($lng->txt('svy_settings_section_before_start'));
323  $form->addItem($section);
324 
325  // introduction
326  $intro = new \ilTextAreaInputGUI($lng->txt("introduction"), "introduction");
327  $intro->setValue($survey->prepareTextareaOutput($survey->getIntroduction()));
328  $intro->setRows(10);
329  $intro->setCols(80);
330  $intro->setInfo($lng->txt("survey_introduction_info"));
331  if ((new \ilRTESettings($this->domain_service->lng(), $this->domain_service->user()))->getRichTextEditor() === "tinymce") {
332  $intro->setUseRte(true);
333  $intro->setRteTagSet("mini");
334  }
335  $form->addItem($intro);
336 
337  return $form;
338  }
339 
343  public function withAccess(
344  \ilPropertyFormGUI $form
345  ): \ilPropertyFormGUI {
346  $survey = $this->survey;
347  $lng = $this->ui_service->lng();
348  $feature_config = $this->feature_config;
349 
350  // access
351 
352  $section = new \ilFormSectionHeaderGUI();
353  $section->setTitle($lng->txt('svy_settings_section_access'));
354  $form->addItem($section);
355 
356  // enable start date
357  $start = $survey->getStartDate();
358  // start date
359  $startingtime = new \ilDateTimeInputGUI($lng->txt("start_date"), 'start_date');
360  $startingtime->setShowTime(true);
361  if ($start) {
362  $startingtime->setDate(new \ilDateTime($start, IL_CAL_TIMESTAMP));
363  }
364  $form->addItem($startingtime);
365 
366  // enable end date
367  $end = $survey->getEndDate();
368  // end date
369  $endingtime = new \ilDateTimeInputGUI($lng->txt("end_date"), 'end_date');
370  $endingtime->setShowTime(true);
371  if ($end) {
372  $endingtime->setDate(new \ilDateTime($end, IL_CAL_TIMESTAMP));
373  }
374  $form->addItem($endingtime);
375 
376  // anonymization
377  if ($feature_config->supportsAccessCodes()) {
378  $codes = new \ilCheckboxInputGUI($lng->txt("survey_access_codes"), "acc_codes");
379  $codes->setInfo($lng->txt("survey_access_codes_info"));
380  $codes->setChecked(!$survey->isAccessibleWithoutCode());
381  $form->addItem($codes);
382 
383  if (\ilObjSurvey::_hasDatasets($survey->getSurveyId())) {
384  $codes->setDisabled(true);
385  }
386  }
387 
388  return $form;
389  }
390 
394  public function withQuestionBehaviour(
395  \ilPropertyFormGUI $form
396  ): \ilPropertyFormGUI {
397  $survey = $this->survey;
398  $lng = $this->ui_service->lng();
399 
400  // question behaviour
401 
402  $section = new \ilFormSectionHeaderGUI();
403  $section->setTitle($lng->txt('svy_settings_section_question_behaviour'));
404  $form->addItem($section);
405 
406  // show question titles
407  $show_question_titles = new \ilCheckboxInputGUI($lng->txt("svy_show_questiontitles"), "show_question_titles");
408  $show_question_titles->setValue("1");
409  $show_question_titles->setChecked($survey->getShowQuestionTitles());
410  $form->addItem($show_question_titles);
411 
412  return $form;
413  }
414 
418  public function withAfterEnd(
419  \ilPropertyFormGUI $form,
420  string $target_class
421  ): \ilPropertyFormGUI {
422  $survey = $this->survey;
423  $lng = $this->ui_service->lng();
424  $feature_config = $this->feature_config;
425  $ctrl = $this->ui_service->ctrl();
426  $invitation_manager = $this->domain_service->participants()->invitations();
427 
428  // finishing
429 
430  $info = new \ilFormSectionHeaderGUI();
431  $info->setTitle($lng->txt("svy_settings_section_finishing"));
432  $form->addItem($info);
433 
434  $mail_confirm = new \ilCheckboxInputGUI($lng->txt("svy_results_mail_confirm"), "mail_confirm");
435  $mail_confirm->setInfo($lng->txt("svy_results_mail_confirm_info"));
436  $mail_confirm->setChecked($survey->hasMailConfirmation());
437  $form->addItem($mail_confirm);
438 
439  $mail_own = new \ilCheckboxInputGUI($lng->txt("svy_results_mail_own"), "mail_own");
440  $mail_own->setInfo($lng->txt("svy_results_mail_own_info"));
441  $mail_own->setChecked($survey->hasMailOwnResults());
442  $mail_confirm->addSubItem($mail_own);
443 
444  // final statement
445  $finalstatement = new \ilTextAreaInputGUI($lng->txt("outro"), "outro");
446  $finalstatement->setValue($survey->prepareTextareaOutput($survey->getOutro()));
447  $finalstatement->setRows(10);
448  $finalstatement->setCols(80);
449  if ((new \ilRTESettings($this->domain_service->lng(), $this->domain_service->user()))->getRichTextEditor() === "tinymce") {
450  $finalstatement->setUseRte(true);
451  $finalstatement->setRteTagSet("mini");
452  }
453  $form->addItem($finalstatement);
454 
455  // mail notification
456  $mailnotification = new \ilCheckboxInputGUI($lng->txt("mailnotification"), "mailnotification");
457  // $mailnotification->setOptionTitle($lng->txt("activate"));
458  $mailnotification->setInfo($lng->txt("svy_result_mail_notification_info")); // #11762
459  $mailnotification->setValue("1");
460  $mailnotification->setChecked($survey->getMailNotification());
461 
462  // addresses
463  $mailaddresses = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "mailaddresses");
464  $mailaddresses->setValue($survey->getMailAddresses());
465  $mailaddresses->setSize(80);
466  $mailaddresses->setInfo($lng->txt('mailaddresses_info'));
467  $mailaddresses->setRequired(true);
468 
469  // participant data
470  $participantdata = new \ilTextAreaInputGUI($lng->txt("mailparticipantdata"), "mailparticipantdata");
471  $participantdata->setValue($survey->getMailParticipantData());
472  $participantdata->setRows(6);
473  $participantdata->setCols(80);
474  $participantdata->setUseRte(false);
475  $participantdata->setInfo($lng->txt("mailparticipantdata_info"));
476 
477  // #12755 - because of privacy concerns we restrict user data to a minimum
478  $placeholders = array(
479  "FIRST_NAME" => "firstname",
480  "LAST_NAME" => "lastname",
481  "LOGIN" => "login"
482  );
483  $txt = array();
484  foreach ($placeholders as $placeholder => $caption) {
485  $txt[] = "[" . strtoupper($placeholder) . "]: " . $lng->txt($caption);
486  }
487  $txt = implode("<br />", $txt);
488  $participantdatainfo = new \ilNonEditableValueGUI($lng->txt("svy_placeholders_label"), "", true);
489  $participantdatainfo->setValue($lng->txt("mailparticipantdata_placeholder") . "<br />" . $txt);
490 
491  $mailnotification->addSubItem($mailaddresses);
492  $mailnotification->addSubItem($participantdata);
493  $mailnotification->addSubItem($participantdatainfo);
494  $form->addItem($mailnotification);
495 
496  // tutor notification - currently not available for 360°
497  if ($feature_config->supportsTutorNotification()) {
498  $num_inv = count($invitation_manager->getAllForSurvey($survey->getSurveyId()));
499 
500  // notification, if "all participants" have finished the survey
501  $tut = new \ilCheckboxInputGUI($lng->txt("survey_notification_tutor_setting"), "tut");
502  $tut->setChecked($survey->getTutorNotificationStatus());
503  $form->addItem($tut);
504 
505  $tut_logins = array();
506  $tuts = $survey->getTutorNotificationRecipients();
507  if ($tuts) {
508  foreach ($tuts as $tut_id) {
509  $tmp = \ilObjUser::_lookupName((int) $tut_id);
510  if ($tmp["login"]) {
511  $tut_logins[] = $tmp["login"];
512  }
513  }
514  }
515  $tut_ids = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "tut_ids");
516  $tut_ids->setDataSource($ctrl->getLinkTargetByClass($target_class, "doAutoComplete", "", true));
517  $tut_ids->setRequired(true);
518  $tut_ids->setMulti(true);
519  $tut_ids->setMultiValues($tut_logins);
520  $tut_ids->setValue(array_shift($tut_logins));
521  $tut->addSubItem($tut_ids);
522 
523  // radio to define who are "all participants"
524  $tut_grp = new \ilRadioGroupInputGUI($lng->txt("survey_notification_target_group"), "tut_grp");
525  $tut_grp->setRequired(true);
526  $tut_grp->setValue((string) $survey->getTutorNotificationTarget());
527  $tut->addSubItem($tut_grp);
528 
529  // (a) ... the member of the parent group or course
530  $tut_grp_crs = new \ilRadioOption(
531  $lng->txt("survey_notification_target_group_parent_course"),
533  );
534  if (!$this->hasGroupCourseParent()) {
535  $tut_grp_crs->setInfo($lng->txt("survey_notification_target_group_parent_course_inactive"));
536  } else {
537  $tut_grp_crs->setInfo(sprintf(
538  $lng->txt("survey_notification_target_group_invited_info"),
539  count($survey->getNotificationTargetUserIds(false))
540  ));
541  }
542  $tut_grp->addOption($tut_grp_crs);
543 
544  // (b) ... all invited users
545  $tut_grp_inv = new \ilRadioOption(
546  $lng->txt("survey_notification_target_group_invited"),
548  );
549  $tut_grp_inv->setInfo(sprintf($lng->txt("survey_notification_target_group_invited_info"), $num_inv));
550  $tut_grp->addOption($tut_grp_inv);
551 
552  /*
553  $tut_res = new \ilCheckboxInputGUI($lng->txt("svy_notification_tutor_results"), "tut_res");
554  $tut_res->setInfo($lng->txt("svy_notification_tutor_results_info"));
555  $tut_res->setChecked($survey->getTutorResultsStatus());
556  $form->addItem($tut_res);
557 
558  $tut_res_logins = array();
559  $tuts = $survey->getTutorResultsRecipients();
560  if ($tuts) {
561  foreach ($tuts as $tut_id) {
562  $tmp = \ilObjUser::_lookupName((int) $tut_id);
563  if ($tmp["login"]) {
564  $tut_res_logins[] = $tmp["login"];
565  }
566  }
567  }
568  $tut_res_ids = new \ilTextInputGUI($lng->txt("survey_notification_tutor_recipients"), "tut_res_ids");
569  $tut_res_ids->setDataSource(
570  $ctrl->getLinkTargetByClass(
571  $target_class,
572  "doAutoComplete",
573  "",
574  true
575  )
576  );
577  $tut_res_ids->setRequired(true);
578  $tut_res_ids->setMulti(true);
579  $tut_res_ids->setMultiValues($tut_res_logins);
580  $tut_res_ids->setValue(array_shift($tut_res_logins));
581  $tut_res->addSubItem($tut_res_ids);*/
582  }
583 
584  return $form;
585  }
586 
590  protected function hasGroupCourseParent(): bool
591  {
592  $survey = $this->survey;
593 
594  $tree = $this->domain_service->repositoryTree();
595  $has_parent = $tree->checkForParentType($survey->getRefId(), "grp");
596  if (!$has_parent) {
597  $has_parent = $tree->checkForParentType($survey->getRefId(), "crs");
598  }
599  return (bool) $has_parent;
600  }
601 
605  public function withReminders(
606  \ilPropertyFormGUI $form
607  ): \ilPropertyFormGUI {
608  $survey = $this->survey;
609  $lng = $this->ui_service->lng();
610  $feature_config = $this->feature_config;
611  $invitation_manager = $this->domain_service->participants()->invitations();
612 
613  // reminders
614 
615  $info = new \ilFormSectionHeaderGUI();
616  $info->setTitle($lng->txt("svy_settings_section_reminders"));
617  $form->addItem($info);
618 
619  $rmd = new \ilCheckboxInputGUI($lng->txt("survey_reminder_setting"), "rmd");
620  $rmd->setChecked($survey->getReminderStatus());
621  $form->addItem($rmd);
622 
623  $rmd_start = new \ilDateTimeInputGUI($lng->txt("survey_reminder_start"), "rmd_start");
624  $rmd_start->setRequired(true);
625  $start = $survey->getReminderStart();
626  if ($start) {
627  $rmd_start->setDate($start);
628  }
629  $rmd->addSubItem($rmd_start);
630 
631  $end = $survey->getReminderEnd();
632  $rmd_end = new \ilDateTimeInputGUI($lng->txt("survey_reminder_end"), "rmd_end");
633  if ($end) {
634  $rmd_end->setDate($end);
635  }
636  $rmd->addSubItem($rmd_end);
637 
638  $rmd_freq = new \ilNumberInputGUI($lng->txt("survey_reminder_frequency"), "rmd_freq");
639  $rmd_freq->setRequired(true);
640  $rmd_freq->setSize(3);
641  $rmd_freq->setSuffix($lng->txt("survey_reminder_frequency_days"));
642  $rmd_freq->setValue((string) $survey->getReminderFrequency());
643  $rmd_freq->setMinValue(1);
644  $rmd->addSubItem($rmd_freq);
645 
646  if ($feature_config->supportsMemberReminder()) {
647  $rmd_grp = new \ilRadioGroupInputGUI($lng->txt("survey_notification_target_group"), "rmd_grp");
648  $rmd_grp->setRequired(true);
649  $rmd_grp->setValue((string) $survey->getReminderTarget());
650  $rmd->addSubItem($rmd_grp);
651 
652  $rmd_grp_crs = new \ilRadioOption(
653  $lng->txt("survey_notification_target_group_parent_course"),
655  );
656  if (!$this->hasGroupCourseParent()) {
657  $rmd_grp_crs->setInfo($lng->txt("survey_notification_target_group_parent_course_inactive"));
658  } else {
659  $rmd_grp_crs->setInfo(sprintf(
660  $lng->txt("survey_notification_target_group_invited_info"),
661  count($survey->getNotificationTargetUserIds(false))
662  ));
663  }
664  $rmd_grp->addOption($rmd_grp_crs);
665 
666  $rmd_grp_inv = new \ilRadioOption(
667  $lng->txt("survey_notification_target_group_invited"),
669  );
670  $num_inv = count($invitation_manager->getAllForSurvey($survey->getSurveyId()));
671  $rmd_grp_inv->setInfo(sprintf($lng->txt("survey_notification_target_group_invited_info"), $num_inv));
672  $rmd_grp->addOption($rmd_grp_inv);
673 
674  $mtmpl = $survey->getReminderMailTemplates();
675  if ($mtmpl) {
676  $rmdt = new \ilRadioGroupInputGUI($lng->txt("svy_reminder_mail_template"), "rmdt");
677  $rmdt->setRequired(true);
678  $rmdt->addOption(new \ilRadioOption($lng->txt("svy_reminder_mail_template_none"), "-1"));
679  foreach ($mtmpl as $mtmpl_id => $mtmpl_caption) {
680  $option = new \ilRadioOption($mtmpl_caption, (string) $mtmpl_id);
681  $rmdt->addOption($option);
682  }
683 
684  $reminderTemplateValue = -1;
685  if ($survey->getReminderTemplate()) {
686  $reminderTemplateValue = $survey->getReminderTemplate();
687  }
688  $rmdt->setValue((string) $reminderTemplateValue);
689  $rmd->addSubItem($rmdt);
690  }
691  }
692 
693  foreach ($this->modifier->getSurveySettingsReminderTargets(
694  $survey,
695  $this->ui_service
696  ) as $item) {
697  $rmd->addSubItem($item);
698  }
699 
700  return $form;
701  }
702 
706  public function withResults(
707  \ilPropertyFormGUI $form
708  ): \ilPropertyFormGUI {
709  $lng = $this->ui_service->lng();
710  $survey = $this->survey;
711  $feature_config = $this->feature_config;
712 
713  // results
714 
715  $results = new \ilFormSectionHeaderGUI();
716  $results->setTitle($lng->txt("results"));
717  $form->addItem($results);
718 
719  if ($feature_config->supportsSumScore()) {
720  // calculate sum score
721  $sum_score = new \ilCheckboxInputGUI($lng->txt("survey_calculate_sum_score"), "calculate_sum_score");
722  $sum_score->setInfo($lng->txt("survey_calculate_sum_score_info"));
723  $sum_score->setValue("1");
724  $sum_score->setChecked($survey->getCalculateSumScore());
725  $form->addItem($sum_score);
726  }
727 
728  foreach ($this->modifier->getSurveySettingsResults(
729  $survey,
730  $this->ui_service
731  ) as $item) {
732  $form->addItem($item);
733  }
734 
735  return $form;
736  }
737 
741  public function withOther(
742  \ilPropertyFormGUI $form
743  ): \ilPropertyFormGUI {
744  $lng = $this->ui_service->lng();
745  $survey = $this->survey;
746  $feature_config = $this->feature_config;
747 
748  $other_items = [];
749 
750  // competence service activation for 360 mode
751 
752  $skmg_set = new \ilSkillManagementSettings();
753 
754  if ($feature_config->supportsCompetences() && $skmg_set->isActivated()) {
755  $skill_service = new \ilCheckboxInputGUI($lng->txt("survey_activate_skill_service"), "skill_service");
756  $skill_service->setInfo($lng->txt("survey_activate_skill_service_info"));
757  $skill_service->setChecked($survey->getSkillService());
758  $other_items[] = $skill_service;
759  }
760 
761  $position_settings = \ilOrgUnitGlobalSettings::getInstance()
762  ->getObjectPositionSettingsByType($survey->getType());
763 
764  if (count($other_items) > 0 ||
765  $position_settings->isActive()
766  ) {
767  $feat = new \ilFormSectionHeaderGUI();
768  $feat->setTitle($lng->txt('obj_features'));
769  $form->addItem($feat);
770 
771  foreach ($other_items as $item) {
772  $form->addItem($item);
773  }
774  }
775 
776  if ($position_settings->isActive()) {
777  // add orgunit settings
779  $survey->getId(),
780  $form,
781  array(
783  )
784  );
785  }
786 
787  return $form;
788  }
789 
790  public function saveForm(
791  \ilPropertyFormGUI $form
792  ): void {
793  $survey = $this->survey;
794  $feature_config = $this->feature_config;
795  $obj_service = $this->object_service;
796  $lng = $this->ui_service->lng();
797 
798  if ($form->getInput("rmd")) {
799  $rmd_start = $form->getItemByPostVar("rmd_start")->getDate();
800  $rmd_end = $form->getItemByPostVar("rmd_end")->getDate();
801  if ($rmd_end && $rmd_start->get(IL_CAL_UNIX) > $rmd_end->get(IL_CAL_UNIX)) {
802  $tmp = $rmd_start;
803  $rmd_start = $rmd_end;
804  $rmd_end = $tmp;
805  }
806  $survey->setReminderStatus(true);
807  $survey->setReminderStart($rmd_start);
808  $survey->setReminderEnd($rmd_end);
809  $survey->setReminderFrequency((int) $form->getInput("rmd_freq"));
810  if ($feature_config->supportsMemberReminder()) {
811  $survey->setReminderTarget((int) $form->getInput("rmd_grp"));
812  $survey->setReminderTemplate(($form->getInput("rmdt") > 0)
813  ? (int) $form->getInput("rmdt")
814  : null);
815  }
816  } else {
817  $survey->setReminderStatus(false);
818  }
819 
820  if ($feature_config->supportsTutorNotification()) {
821  // "one mail after all participants finished"
822  if ($form->getInput("tut")) {
823  $tut_ids = $this->getTutorIdsFromForm($form);
824  $survey->setTutorNotificationStatus(true);
825  $survey->setTutorNotificationRecipients($tut_ids); // see above
826  $survey->setTutorNotificationTarget((int) $form->getInput("tut_grp"));
827  } else {
828  $survey->setTutorNotificationStatus(false);
829  }
830 
831  /*
832  if ($form->getInput("tut_res")) {
833  $tut_res_ids = $this->getTutorResIdsFromForm($form);
834  $survey->setTutorResultsStatus(true);
835  $survey->setTutorResultsRecipients($tut_res_ids); // see above
836  } else {
837  $survey->setTutorResultsStatus(false);
838  }*/
839  }
840 
841  // #10055
842  if ($form->getInput('online') && count($survey->questions) === 0) {
843  $this->main_tpl->setOnScreenMessage('failure', $lng->txt("cannot_switch_to_online_no_questions"), true);
844  } else {
845  $survey->setOfflineStatus(!$form->getInput('online'));
846  }
847 
848  $survey->setMailOwnResults((bool) $form->getInput("mail_own"));
849  $survey->setMailConfirmation((bool) $form->getInput("mail_confirm"));
850 
851  // both are saved in object, too
852  $survey->setTitle($form->getInput('title'));
853  $survey->setDescription($form->getInput('description'));
854  $survey->update();
855 
856  // activation
857  $period = $form->getItemByPostVar("access_period");
858  $tb = $form->getInput("time_based_avail");
859  if ($tb && $period->getStart() && $period->getEnd()) {
860  $survey->setActivationLimited(true);
861  $survey->setActivationVisibility((bool) $form->getInput("access_visiblity"));
862  $survey->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
863  $survey->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
864  } else {
865  $survey->setActivationLimited(false);
866  }
867 
868  // tile image
869  $obj_service->commonSettings()->legacyForm($form, $survey)->saveTileImage();
870 
871  $start = $form->getItemByPostVar("start_date");
872  if ($start->getDate()) {
873  $datetime = explode(" ", $start->getDate()->get(IL_CAL_DATETIME));
874  $survey->setStartDateAndTime($datetime[0], $datetime[1]);
875  } else {
876  $survey->setStartDate("");
877  }
878 
879  $end = $form->getItemByPostVar("end_date");
880  if ($end->getDate()) {
881  $datetime = explode(" ", $end->getDate()->get(IL_CAL_DATETIME));
882  $survey->setEndDateAndTime($datetime[0], $datetime[1]);
883  } else {
884  $survey->setEndDate("");
885  }
886  $survey->setIntroduction($form->getInput("introduction"));
887  $survey->setOutro($form->getInput("outro"));
888  $survey->setShowQuestionTitles((bool) $form->getInput("show_question_titles"));
889 
890  // "separate mail for each participant finished"
891  $survey->setMailNotification((bool) $form->getInput('mailnotification'));
892  $survey->setMailAddresses($form->getInput('mailaddresses'));
893  $survey->setMailParticipantData($form->getInput('mailparticipantdata'));
894 
895  if ($feature_config->usesAppraisees()) {
896  $survey->set360SelfAppraisee((bool) $form->getInput("self_appr"));
897  $survey->set360SelfRaters((bool) $form->getInput("self_rate"));
898  }
899 
900  if ($feature_config->supportsCompetences()) {
901  $survey->setSkillService((bool) $form->getInput("skill_service"));
902  }
903 
904  foreach ($this->modifier->getSurveySettingsResults(
905  $survey,
906  $this->ui_service
907  ) as $item) {
908  $this->modifier->setValuesFromForm($survey, $form);
909  }
910 
911  $survey->saveToDb();
912 
914  $survey->getId(),
915  $form,
916  array(
918  )
919  );
920  }
921 }
hasGroupCourseParent()
Check for group course parent.
withOther(\ilPropertyFormGUI $form)
add "other" section
This class represents an option in a radio group.
withGeneral(\ilPropertyFormGUI $form)
add general section
const IL_CAL_DATETIME
static _hasDatasets(int $survey_id)
getItemByPostVar(string $a_post_var)
getTutorResIdsFromForm(\ilPropertyFormGUI $form)
static _getAllReferences(int $id)
get all reference ids for object ID
$valid
$datetime
static _lookupName(int $a_user_id)
lookup user name
static _lookupId($a_user_str)
withQuestionBehaviour(\ilPropertyFormGUI $form)
add question behaviour section
__construct(InternalGUIService $ui_service, InternalDomainService $domain_service, \ilObjectService $object_service, \ilObjSurvey $survey, UIModifier $modifier)
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
const IL_CAL_UNIX
withReminders(\ilPropertyFormGUI $form)
add reminders section
withPresentation(\ilPropertyFormGUI $form)
add presentation section
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-...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
withAccess(\ilPropertyFormGUI $form)
add access section
withBeforeStart(\ilPropertyFormGUI $form)
add "before start" section
const NOTIFICATION_PARENT_COURSE
global $DIC
Definition: shib_login.php:26
withResults(\ilPropertyFormGUI $form)
add results section
$results
const NOTIFICATION_INVITED_USERS
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
$txt
Definition: error.php:31
ILIAS Survey Mode FeatureConfig $feature_config
withActivation(\ilPropertyFormGUI $form)
add activation section
global $lng
Definition: privfeed.php:31
$info
Definition: entry_point.php:21
const IL_CAL_TIMESTAMP
withAfterEnd(\ilPropertyFormGUI $form, string $target_class)
add "after ending" section