ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilExAssignmentEditorGUI.php
Go to the documentation of this file.
1 <?php
2 
23 
33 {
34  protected \ILIAS\Exercise\InternalDomainService $domain;
35  protected \ILIAS\Exercise\InstructionFile\InstructionFileManager $instruction_files;
36  protected ?int $ref_id = null;
38  protected \ILIAS\Exercise\InternalGUIService $gui;
39  protected ilCtrl $ctrl;
40  protected ilTabsGUI $tabs;
41  protected ilLanguage $lng;
44  protected ilSetting $settings;
45  protected ilHelpGUI $help;
46  protected int $exercise_id;
51  protected ?ilObjExercise $exc;
53  protected string $requested_ass_type;
54  protected int $requested_type;
58  protected array $requested_ass_ids;
62  protected array $requested_order;
63  private \ILIAS\ResourceStorage\Services $irss;
64  private \ILIAS\FileUpload\FileUpload $upload;
65 
66  public function __construct(
67  int $a_exercise_id,
68  bool $a_enable_peer_review_completion_settings,
69  ilExAssignment $a_ass = null
70  ) {
72  global $DIC;
73 
74  $this->ctrl = $DIC->ctrl();
75  $this->tabs = $DIC->tabs();
76  $this->lng = $DIC->language();
77  $this->tpl = $DIC["tpl"];
78  $this->toolbar = $DIC->toolbar();
79  $this->settings = $DIC->settings();
80  $this->help = $DIC["ilHelp"];
81  $this->exercise_id = $a_exercise_id;
82  $this->assignment = $a_ass;
83  $this->gui = $DIC->exercise()
84  ->internal()
85  ->gui();
86  $this->enable_peer_review_completion = $a_enable_peer_review_completion_settings;
87  $this->types = ilExAssignmentTypes::getInstance();
88  $this->type_guis = $this->gui->assignment()->types();
89  $request = $DIC->exercise()->internal()->gui()->request();
90  $this->exc = $request->getExercise();
91  $this->requested_ass_type = $request->getAssType();
92  $this->requested_type = $request->getType();
93  $this->random_manager = $DIC->exercise()->internal()->domain()->assignment()->randomAssignments(
94  $request->getExercise()
95  );
96  $this->domain = $DIC->exercise()->internal()->domain();
97  $this->requested_ass_ids = $request->getAssignmentIds();
98  $this->requested_order = $request->getOrder();
99  $this->irss = $DIC->resourceStorage();
100  $this->access = $DIC->access();
101  $this->ref_id = $DIC->http()->wrapper()->query()->has('ref_id')
102  ? $DIC->http()->wrapper()->query()->retrieve(
103  'ref_id',
104  $DIC->refinery()->kindlyTo()->int()
105  ) : null;
106  }
107 
111  public function executeCommand(): void
112  {
113  $ilCtrl = $this->ctrl;
114  $ilTabs = $this->tabs;
115  $lng = $this->lng;
116 
117  $class = $ilCtrl->getNextClass($this);
118  $cmd = $ilCtrl->getCmd("listAssignments");
119 
120  switch ($class) {
121  case "ilpropertyformgui":
122  $form = $this->initAssignmentForm($this->requested_ass_type);
123  $ilCtrl->forwardCommand($form);
124  break;
125 
126  case strtolower(ilResourceCollectionGUI::class):
127  $this->setAssignmentHeader();
128  $ilTabs->activateTab("ass_files");
129  $irss = $this->domain->assignment()->instructionFiles($this->assignment->getId());
130  if ($irss->getCollectionIdString() === "") {
131  $this->tpl->setOnScreenMessage(
132  "info",
133  $this->lng->txt("exc_instruction_migration_not_run")
134  );
135  } else {
136  $gui = $this->gui->assignment()->getInstructionFileResourceCollectionGUI(
137  (int) $this->ref_id,
138  $this->assignment->getId()
139  );
140  $this->ctrl->forwardCommand($gui);
141  }
142  break;
143 
144  case "ilexpeerreviewgui":
145  $ilTabs->clearTargets();
146  $ilTabs->setBackTarget(
147  $lng->txt("back"),
148  $ilCtrl->getLinkTarget($this, "listAssignments")
149  );
150 
151  $peer_gui = new ilExPeerReviewGUI($this->assignment);
152  $ilCtrl->forwardCommand($peer_gui);
153  break;
154 
155  default:
156  $this->{$cmd . "Object"}();
157  break;
158  }
159  }
160 
164  public function listAssignmentsObject(): void
165  {
166  $tpl = $this->tpl;
167  $ilToolbar = $this->toolbar;
168  $ilCtrl = $this->ctrl;
169 
170  $ilCtrl->setParameter($this, "ass_id", null);
171 
172  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "addAssignment"));
173 
174  $ilToolbar->addStickyItem($this->getTypeDropdown(), true);
175 
176  $this->gui->button(
177  $this->lng->txt("exc_add_assignment"),
178  "addAssignment"
179  )->submit()->toToolbar(true);
180 
181  $t = new ilAssignmentsTableGUI($this, "listAssignments", $this->exercise_id);
182  $tpl->setContent($t->getHTML());
183  }
184 
189  public function addAssignmentObject(): void
190  {
191  $tpl = $this->tpl;
192  $ilCtrl = $this->ctrl;
193 
194  // #16163 - ignore ass id from request
195  $this->assignment = null;
196 
197  if ($this->requested_type == 0) {
198  $ilCtrl->redirect($this, "listAssignments");
199  }
200 
201  $form = $this->initAssignmentForm($this->requested_type, "create");
202  $tpl->setContent($form->getHTML());
203  }
204 
208  protected function getTypeDropdown(): ilSelectInputGUI
209  {
210  $lng = $this->lng;
211 
212  $types = [];
213  foreach ($this->types->getAllAllowed($this->exc) as $k => $t) {
214  $types[$k] = $t->getTitle();
215  }
216 
217  $ty = new ilSelectInputGUI($lng->txt("exc_assignment_type"), "type");
218  $ty->setOptions($types);
219  $ty->setRequired(true);
220  return $ty;
221  }
222 
226  protected function initAssignmentForm(
227  int $a_type,
228  string $a_mode = "create"
229  ): ilPropertyFormGUI {
230  $lng = $this->lng;
231  $ilCtrl = $this->ctrl;
232 
233  $ass_type = $this->types->getById($a_type);
234  $ass_type_gui = $this->type_guis->getById($a_type);
235  $ilCtrl->setParameter($this, "ass_type", $a_type);
236 
237  $lng->loadLanguageModule("form");
238  $form = new ilPropertyFormGUI();
239  if ($a_mode == "edit") {
240  $form->setTitle($lng->txt("exc_edit_assignment"));
241  } else {
242  $form->setTitle($lng->txt("exc_new_assignment"));
243  }
244  $form->setFormAction($ilCtrl->getFormAction($this));
245 
246  // title
247  $ti = new ilTextInputGUI($lng->txt("title"), "title");
248  $ti->setMaxLength(200);
249  $ti->setRequired(true);
250  $form->addItem($ti);
251 
252  // type
253  $ty = $this->getTypeDropdown();
254  $ty->setValue($a_type);
255  $ty->setDisabled(true);
256  $form->addItem($ty);
257 
258  //
259  // type specific start
260  //
261 
262  $ass_type_gui->addEditFormCustomProperties($form);
263 
264  //
265  // type specific end
266  //
267 
268  if ($ass_type->usesTeams()) {
269  if ($a_mode == "edit") {
270  $has_teams = (bool) count(ilExAssignmentTeam::getAssignmentTeamMap($this->assignment->getId()));
271  } else {
272  $has_teams = false;
273  }
274 
275  // Radio for creators
276  $rd_team = new ilRadioGroupInputGUI($lng->txt("exc_team_formation"), "team_creator");
277 
278  $radio_participants = new ilRadioOption(
279  $lng->txt("exc_team_by_participants"),
281  $lng->txt("exc_team_by_participants_info")
282  );
283 
284  $radio_tutors = new ilRadioOption(
285  $lng->txt("exc_team_by_tutors"),
287  $lng->txt("exc_team_by_tutors_info")
288  );
289 
290  #23679
291  if (!$has_teams) {
292  // Creation options
293  $rd_creation_method = new ilRadioGroupInputGUI($lng->txt("exc_team_creation"), "team_creation");
294  $rd_creation_method->setRequired(true);
295  $rd_creation_method->setValue("0");
296 
297  //manual
298  $rd_creation_manual = new ilRadioOption(
299  $lng->txt("exc_team_by_tutors_manual"),
300  "0",
301  $lng->txt("exc_team_by_tutors_manual_info")
302  );
303  $rd_creation_method->addOption($rd_creation_manual);
304 
305  //random options
306  $add_info = "";
307  if ($this->getExerciseTotalMembers() < 4) {
308  $add_info = " <strong>" . $lng->txt("exc_team_by_random_add_info") . "</strong>";
309  }
310  $rd_creation_random = new ilRadioOption(
311  $lng->txt("exc_team_by_random"),
313  $lng->txt("exc_team_by_random_info") . "<br>" . $lng->txt("exc_total_members") . ": " . $this->getExerciseTotalMembers() . $add_info
314  );
315  $rd_creation_method->addOption($rd_creation_random);
316 
317  $number_teams = new ilNumberInputGUI($lng->txt("exc_num_teams"), "number_teams");
318  $number_teams->setSize(3);
319  $number_teams->setMinValue(1);
320  $number_teams->setMaxValue($this->getExerciseTotalMembers());
321  $number_teams->setRequired(true);
322  $number_teams->setSuffix($lng->txt("exc_team_assignment_adopt_teams"));
323  $rd_creation_random->addSubItem($number_teams);
324 
325  $min_team_participants = new ilNumberInputGUI($lng->txt("exc_min_team_participants"), "min_participants_team");
326  $min_team_participants->setSize(3);
327  $min_team_participants->setMinValue(1);
328  $min_team_participants->setMaxValue($this->getExerciseTotalMembers());
329  $min_team_participants->setRequired(true);
330  $min_team_participants->setSuffix($lng->txt("exc_participants"));
331  $rd_creation_random->addSubItem($min_team_participants);
332 
333  $max_team_participants = new ilNumberInputGUI($lng->txt("exc_max_team_participants"), "max_participants_team");
334  $max_team_participants->setSize(3);
335  $max_team_participants->setMinValue(1);
336  $max_team_participants->setMaxValue($this->getExerciseTotalMembers());
337  $max_team_participants->setRequired(true);
338  $max_team_participants->setSuffix($lng->txt("exc_participants"));
339  $rd_creation_random->addSubItem($max_team_participants);
340 
341  $options = ilExAssignmentTeam::getAdoptableTeamAssignments($this->exercise_id);
342  if (count($options)) {
343  $radio_assignment = new ilRadioOption(
344  $lng->txt("exc_team_by_assignment"),
346  $lng->txt("exc_team_by_assignment_info")
347  );
348 
349  $radio_assignment_adopt = new ilRadioGroupInputGUI($lng->txt("exc_assignment"), "ass_adpt");
350  $radio_assignment_adopt->setRequired(true);
351  $radio_assignment_adopt->addOption(new ilRadioOption($lng->txt("exc_team_assignment_adopt_none"), -1));
352 
353  foreach ($options as $id => $item) {
354  $option = new ilRadioOption($item["title"], $id);
355  $option->setInfo($lng->txt("exc_team_assignment_adopt_teams") . ": " . $item["teams"]);
356  $radio_assignment_adopt->addOption($option);
357  }
358  $radio_assignment->addSubItem($radio_assignment_adopt);
359  $rd_creation_method->addOption($radio_assignment);
360  }
361 
362  $radio_tutors->addSubItem($rd_creation_method);
363  }
364  $rd_team->addOption($radio_participants);
365  $rd_team->addOption($radio_tutors);
366  /*if(!$has_teams) {
367  $rd_team->addOption($radio_assignment);
368  }*/
369  $form->addItem($rd_team);
370 
371  if ($has_teams) {
372  $rd_team->setDisabled(true);
373  }
374  }
375 
376  // mandatory
377  if (!$this->random_manager->isActivated()) {
378  $cb = new ilCheckboxInputGUI($lng->txt("exc_mandatory"), "mandatory");
379  $cb->setInfo($lng->txt("exc_mandatory_info"));
380  $cb->setChecked(true);
381  $form->addItem($cb);
382  } else {
383  //
384  $ne = new ilNonEditableValueGUI($lng->txt("exc_mandatory"), "");
385  $ne->setValue($lng->txt("exc_mandatory_rand_determined"));
386  $form->addItem($ne);
387  }
388 
389  // Work Instructions
390  $sub_header = new ilFormSectionHeaderGUI();
391  $sub_header->setTitle($lng->txt("exc_work_instructions"));
392  $form->addItem($sub_header);
393 
394  $desc_input = new ilTextAreaInputGUI($lng->txt("exc_instruction"), "instruction");
395  $desc_input->setRows(20);
396  if (ilObjAdvancedEditing::_getRichTextEditor() === "tinymce") {
397  $desc_input->setUseRte(true);
398  $desc_input->setRteTagSet("mini");
399  }
400  $form->addItem($desc_input);
401 
402  // files
403  if ($a_mode == "create") {
404  $files = new ilFileWizardInputGUI($lng->txt('objs_file'), 'files');
405  $files->setFilenames(array(0 => ''));
406  $form->addItem($files);
407  }
408 
409  // Schedule
410  $sub_header = new ilFormSectionHeaderGUI();
411  $sub_header->setTitle($lng->txt("exc_schedule"));
412  $form->addItem($sub_header);
413 
414  // start time
415  $start_date = new ilDateTimeInputGUI($lng->txt("exc_start_time"), "start_time");
416  $start_date->setShowTime(true);
417  $form->addItem($start_date);
418 
419  // Deadline Mode
420  $radg = new ilRadioGroupInputGUI($lng->txt("exc_deadline"), "deadline_mode");
421  $radg->setValue(0);
422  $op0 = new ilRadioOption($lng->txt("exc_no_deadline"), -1, $lng->txt("exc_no_deadline_info"));
423  $radg->addOption($op0);
424  $op1 = new ilRadioOption($lng->txt("exc_fixed_date"), 0, $lng->txt("exc_fixed_date_info"));
425  $radg->addOption($op1);
426  if (!$ass_type->usesTeams()) {
427  $op3 = new ilRadioOption($lng->txt("exc_fixed_date_individual"), 2, $lng->txt("exc_fixed_date_individual_info"));
428  $radg->addOption($op3);
429  }
430  $op2 = new ilRadioOption($lng->txt("exc_relative_date"), 1, $lng->txt("exc_relative_date_info"));
431  $radg->addOption($op2);
432  $form->addItem($radg);
433 
434  // Deadline fixed date
435  $deadline = new ilDateTimeInputGUI($lng->txt("date"), "deadline");
436  $deadline->setRequired(true);
437  $deadline->setShowTime(true);
438  $op1->addSubItem($deadline);
439 
440  // extended Deadline
441  $deadline2 = new ilDateTimeInputGUI($lng->txt("exc_deadline_extended"), "deadline2");
442  $deadline2->setInfo($lng->txt("exc_deadline_extended_info"));
443  $deadline2->setShowTime(true);
444  $op1->addSubItem($deadline2);
445 
446 
447  // submit reminder
448  $rmd_submit = new ilCheckboxInputGUI($this->lng->txt("exc_reminder_submit_setting"), "rmd_submit_status");
449 
450  $rmd_submit_start = new ilNumberInputGUI($this->lng->txt("exc_reminder_start"), "rmd_submit_start");
451  $rmd_submit_start->setSize(3);
452  $rmd_submit_start->setMaxLength(3);
453  $rmd_submit_start->setSuffix($lng->txt('days'));
454  $rmd_submit_start->setInfo($this->lng->txt("exc_reminder_start_info"));
455  $rmd_submit_start->setRequired(true);
456  $rmd_submit_start->setMinValue(1);
457  $rmd_submit->addSubItem($rmd_submit_start);
458 
459  $rmd_submit_frequency = new ilNumberInputGUI($this->lng->txt("exc_reminder_frequency"), "rmd_submit_freq");
460  $rmd_submit_frequency->setSize(3);
461  $rmd_submit_frequency->setMaxLength(3);
462  $rmd_submit_frequency->setSuffix($lng->txt('days'));
463  $rmd_submit_frequency->setRequired(true);
464  $rmd_submit_frequency->setMinValue(1);
465  $rmd_submit->addSubItem($rmd_submit_frequency);
466 
467  $rmd_submit_end = new ilDateTimeInputGUI($lng->txt("exc_reminder_end"), "rmd_submit_end");
468  $rmd_submit_end->setRequired(true);
469  $rmd_submit->addSubItem($rmd_submit_end);
470 
471  $rmd_submit->addSubItem($this->addMailTemplatesRadio(ilExAssignmentReminder::SUBMIT_REMINDER));
472 
473  // grade reminder
474  $rmd_grade = new ilCheckboxInputGUI($this->lng->txt("exc_reminder_grade_setting"), "rmd_grade_status");
475 
476  $rmd_grade_frequency = new ilNumberInputGUI($this->lng->txt("exc_reminder_frequency"), "rmd_grade_freq");
477  $rmd_grade_frequency->setSize(3);
478  $rmd_grade_frequency->setMaxLength(3);
479  $rmd_grade_frequency->setSuffix($lng->txt('days'));
480  $rmd_grade_frequency->setRequired(true);
481  $rmd_grade_frequency->setMinValue(1);
482  $rmd_grade->addSubItem($rmd_grade_frequency);
483 
484  $rmd_grade_end = new ilDateTimeInputGUI($lng->txt("exc_reminder_end"), "rmd_grade_end");
485  $rmd_grade_end->setRequired(true);
486  $rmd_grade->addSubItem($rmd_grade_end);
487 
488  $rmd_grade->addSubItem($this->addMailTemplatesRadio(ilExAssignmentReminder::GRADE_REMINDER));
489 
490  $form->addItem($rmd_submit);
491  $form->addItem($rmd_grade);
492 
493  // relative deadline
494  $ti = new ilNumberInputGUI($lng->txt("exc_relative_date_period"), "relative_deadline");
495  $ti->setSuffix($lng->txt("days"));
496  $ti->setMaxLength(3);
497  $ti->setSize(3);
498  $ti->setMinValue(1);
499  $ti->setRequired(true);
500  $op2->addSubItem($ti);
501 
502  // last submission for relative deadline
503  $last_submission = new ilDateTimeInputGUI($lng->txt("exc_rel_last_submission"), "rel_deadline_last_subm");
504  $last_submission->setInfo($lng->txt("exc_rel_last_submission_info"));
505  $last_submission->setShowTime(true);
506  $op2->addSubItem($last_submission);
507 
508 
509 
510  // max number of files
511  if ($ass_type->usesFileUpload()) {
512  $sub_header = new ilFormSectionHeaderGUI();
513  $sub_header->setTitle($ass_type->getTitle());
514  $form->addItem($sub_header);
515  $max_file_tgl = new ilCheckboxInputGUI($lng->txt("exc_max_file_tgl"), "max_file_tgl");
516  $form->addItem($max_file_tgl);
517 
518  $max_file = new ilNumberInputGUI($lng->txt("exc_max_file"), "max_file");
519  $max_file->setInfo($lng->txt("exc_max_file_info"));
520  $max_file->setRequired(true);
521  $max_file->setSize(3);
522  $max_file->setMinValue(1);
523  $max_file_tgl->addSubItem($max_file);
524  }
525 
526  // after submission
527  $sub_header = new ilFormSectionHeaderGUI();
528  $sub_header->setTitle($lng->txt("exc_after_submission"));
529  $form->addItem($sub_header);
530 
531  if (!$ass_type->usesTeams() && !$this->random_manager->isActivated()) {
532  // peer review
533  $peer = new ilCheckboxInputGUI($lng->txt("exc_peer_review"), "peer");
534  $peer->setInfo($lng->txt("exc_peer_review_ass_setting_info"));
535  $form->addItem($peer);
536  }
537 
538 
539  // global feedback
540 
541  $fb = new ilCheckboxInputGUI($lng->txt("exc_global_feedback_file"), "fb");
542  $form->addItem($fb);
543 
544  $fb_file = new ilFileInputGUI($lng->txt("file"), "fb_file");
545  $fb_file->setRequired(true); // will be disabled on update if file exists - see getAssignmentValues()
546  // $fb_file->setAllowDeletion(true); makes no sense if required (overwrite or keep)
547  $fb->addSubItem($fb_file);
548 
549  $fb_date = new ilRadioGroupInputGUI($lng->txt("exc_global_feedback_file_date"), "fb_date");
550  $fb_date->setRequired(true);
551  $fb_date->setValue(ilExAssignment::FEEDBACK_DATE_DEADLINE);
552  $fb_date->addOption(new ilRadioOption($lng->txt("exc_global_feedback_file_date_deadline"), ilExAssignment::FEEDBACK_DATE_DEADLINE));
553  $fb_date->addOption(new ilRadioOption($lng->txt("exc_global_feedback_file_date_upload"), ilExAssignment::FEEDBACK_DATE_SUBMISSION));
554 
555  //Extra radio option with date selection
556  $fb_date_custom_date = new ilDateTimeInputGUI($lng->txt("date"), "fb_date_custom");
557  $fb_date_custom_date->setRequired(true);
558  $fb_date_custom_date->setShowTime(true);
559  $fb_date_custom_option = new ilRadioOption($lng->txt("exc_global_feedback_file_after_date"), ilExAssignment::FEEDBACK_DATE_CUSTOM);
560  $fb_date_custom_option->addSubItem($fb_date_custom_date);
561  $fb_date->addOption($fb_date_custom_option);
562 
563 
564  $fb->addSubItem($fb_date);
565 
566  $fb_cron = new ilCheckboxInputGUI($lng->txt("exc_global_feedback_file_cron"), "fb_cron");
567  $fb_cron->setInfo($lng->txt("exc_global_feedback_file_cron_info"));
568  $fb->addSubItem($fb_cron);
569 
570 
571  if ($a_mode == "create") {
572  $form->addCommandButton("saveAssignment", $lng->txt("save"));
573  } else {
574  $form->addCommandButton("updateAssignment", $lng->txt("save"));
575  }
576  $form->addCommandButton("listAssignments", $lng->txt("cancel"));
577 
578  return $form;
579  }
580 
581  public function addMailTemplatesRadio(string $a_reminder_type): ilRadioGroupInputGUI
582  {
583  global $DIC;
584 
585  $post_var = "rmd_" . $a_reminder_type . "_template_id";
586 
587  $r_group = new ilRadioGroupInputGUI($this->lng->txt("exc_reminder_mail_template"), $post_var);
588  $r_group->setRequired(true);
589  $r_group->addOption(new ilRadioOption($this->lng->txt("exc_reminder_mail_no_tpl"), 0));
590  $r_group->setValue(0);
591 
592  switch ($a_reminder_type) {
595  break;
598  break;
601  break;
602  default:
603  exit();
604  }
605 
606  $templateService = $DIC->mail()->textTemplates();
607  foreach ($templateService->loadTemplatesForContextId($context->getId()) as $template) {
608  $r_group->addOption(new ilRadioOption($template->getTitle(), $template->getTplId()));
609  if ($template->isDefault()) {
610  $r_group->setValue($template->getTplId());
611  }
612  }
613 
614  return $r_group;
615  }
616 
623  protected function processForm(ilPropertyFormGUI $a_form): ?array
624  {
625  $lng = $this->lng;
626 
627  $protected_peer_review_groups = false;
628 
629  if ($this->assignment) {
630  if ($this->assignment->getPeerReview()) {
631  $peer_review = new ilExPeerReview($this->assignment);
632  if ($peer_review->hasPeerReviewGroups()) {
633  $protected_peer_review_groups = true;
634  }
635  }
636 
637  if ($this->assignment->getFeedbackFile()) {
638  $a_form->getItemByPostVar("fb_file")->setRequired(false); // #15467
639  }
640  }
641 
642  $valid = $a_form->checkInput();
643  if ($protected_peer_review_groups) {
644  // checkInput() will add alert to disabled fields
645  $a_form->getItemByPostVar("deadline")->setAlert("");
646  $a_form->getItemByPostVar("deadline2")->setAlert("");
647  }
648 
649  if ($valid) {
650  $type = $a_form->getInput("type");
651  $ass_type = $this->types->getById($type);
652 
653  // dates
654 
655  $time_start = $a_form->getItemByPostVar("start_time")->getDate();
656  $time_start = $time_start
657  ? $time_start->get(IL_CAL_UNIX)
658  : null;
659 
660  $time_fb_custom_date = $a_form->getItemByPostVar("fb_date_custom")->getDate();
661  $time_fb_custom_date = $time_fb_custom_date
662  ? $time_fb_custom_date->get(IL_CAL_UNIX)
663  : null;
664 
665  $reminder_submit_end_date = $a_form->getItemByPostVar("rmd_submit_end")->getDate();
666  $reminder_submit_end_date = $reminder_submit_end_date
667  ? $reminder_submit_end_date->get(IL_CAL_UNIX)
668  : null;
669 
670  $reminder_grade_end_date = $a_form->getItemByPostVar("rmd_grade_end")->getDate();
671  $reminder_grade_end_date = $reminder_grade_end_date
672  ? $reminder_grade_end_date->get(IL_CAL_UNIX)
673  : null;
674 
675  $time_deadline = null;
676  $time_deadline_ext = null;
677 
678  $deadline_mode = (int) $a_form->getInput("deadline_mode");
679  if ($deadline_mode === -1) {
680  $deadline_mode = 0;
681  }
682 
683  if ($deadline_mode === ilExAssignment::DEADLINE_ABSOLUTE) {
684  $time_deadline = $a_form->getItemByPostVar("deadline")->getDate();
685  $time_deadline = $time_deadline
686  ? $time_deadline->get(IL_CAL_UNIX)
687  : null;
688  $time_deadline_ext = $a_form->getItemByPostVar("deadline2")->getDate();
689  $time_deadline_ext = $time_deadline_ext
690  ? $time_deadline_ext->get(IL_CAL_UNIX)
691  : null;
692  }
693 
694 
695  // handle disabled elements
696  if ($protected_peer_review_groups) {
697  $time_deadline = $this->assignment->getDeadline();
698  $time_deadline_ext = $this->assignment->getExtendedDeadline();
699  }
700 
701  // no deadline?
702  if (!$time_deadline) {
703  // peer review
704  if (!$protected_peer_review_groups &&
705  $a_form->getInput("peer")) {
706  $a_form->getItemByPostVar("peer")
707  ->setAlert($lng->txt("exc_needs_fixed_deadline"));
708  $valid = false;
709  }
710  // global feedback
711  if ($a_form->getInput("fb") &&
712  $a_form->getInput("fb_date") == ilExAssignment::FEEDBACK_DATE_DEADLINE) {
713  $a_form->getItemByPostVar("fb")
714  ->setAlert($lng->txt("exc_needs_deadline"));
715  $valid = false;
716  }
717  } else {
718  // #18269
719  if ($a_form->getInput("peer")) {
720  $time_deadline_max = max($time_deadline, $time_deadline_ext);
721  $peer_dl = $this->assignment // #18380
722  ? $this->assignment->getPeerReviewDeadline()
723  : null;
724  if ($peer_dl && $peer_dl < $time_deadline_max) {
725  $a_form->getItemByPostVar($peer_dl < $time_deadline_ext
726  ? "deadline2"
727  : "deadline")
728  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
729  $valid = false;
730  }
731  }
732 
733  if ($time_deadline_ext && $time_deadline_ext < $time_deadline) {
734  $a_form->getItemByPostVar("deadline2")
735  ->setAlert($lng->txt("exc_deadline_ext_mismatch"));
736  $valid = false;
737  }
738 
739  $time_deadline_min = $time_deadline_ext
740  ? min($time_deadline, $time_deadline_ext)
741  : $time_deadline;
742 
743  // start > any deadline ?
744  if ($time_start && $time_deadline_min && $time_start > $time_deadline_min) {
745  $a_form->getItemByPostVar("start_time")
746  ->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
747  $valid = false;
748  }
749  }
750 
751  if ($ass_type->usesTeams()) {
752  if ($a_form->getInput("team_creation") == ilExAssignment::TEAMS_FORMED_BY_RANDOM &&
753  $a_form->getInput("team_creator") == ilExAssignment::TEAMS_FORMED_BY_TUTOR) {
754  $team_validation = $this->validationTeamsFormation(
755  $a_form->getInput("number_teams"),
756  $a_form->getInput("min_participants_team"),
757  $a_form->getInput("max_participants_team")
758  );
759  if ($team_validation['status'] == 'error') {
760  $a_form->getItemByPostVar("team_creation")
761  ->setAlert($team_validation['msg']);
762  $a_form->getItemByPostVar($team_validation["field"])
763  ->setAlert($lng->txt("exc_value_can_not_set"));
764  $valid = false;
765  }
766  }
767  }
768  if ($valid) {
769  $res = array(
770  // core
771  "type" => $a_form->getInput("type")
772  ,"title" => trim($a_form->getInput("title"))
773  ,"instruction" => trim($a_form->getInput("instruction"))
774  // dates
775  ,"start" => $time_start
776  ,"deadline" => $time_deadline
777  ,"deadline_ext" => $time_deadline_ext
778  ,"max_file" => $a_form->getInput("max_file_tgl")
779  ? $a_form->getInput("max_file")
780  : null
781  );
782  if (!$this->random_manager->isActivated()) {
783  $res["mandatory"] = $a_form->getInput("mandatory");
784  }
785 
786  $res['team_creator'] = $a_form->getInput("team_creator");
787  $res["team_creation"] = $a_form->getInput("team_creation");
788  if ($a_form->getInput("team_creator") == ilExAssignment::TEAMS_FORMED_BY_TUTOR) {
789  if ($a_form->getInput("team_creation") == ilExAssignment::TEAMS_FORMED_BY_RANDOM) {
790  $res["number_teams"] = $a_form->getInput("number_teams");
791  $res["min_participants_team"] = $a_form->getInput("min_participants_team");
792  $res["max_participants_team"] = $a_form->getInput("max_participants_team");
793  } elseif ($a_form->getInput("team_creation") == ilExAssignment::TEAMS_FORMED_BY_ASSIGNMENT) {
794  $res['ass_adpt'] = $a_form->getInput("ass_adpt");
795  }
796  }
797 
798  $res["deadline_mode"] = $deadline_mode;
799 
800  if ($res["deadline_mode"] == ilExAssignment::DEADLINE_RELATIVE) {
801  $res["relative_deadline"] = $a_form->getInput("relative_deadline");
802  $rel_deadline_last_subm = $a_form->getItemByPostVar("rel_deadline_last_subm")->getDate();
803  $rel_deadline_last_subm = $rel_deadline_last_subm
804  ? $rel_deadline_last_subm->get(IL_CAL_UNIX)
805  : null;
806  $res["rel_deadline_last_subm"] = $rel_deadline_last_subm;
807  }
808 
809  // peer
810  if ($a_form->getInput("peer") ||
811  $protected_peer_review_groups) {
812  $res["peer"] = true;
813  }
814 
815  // files
816  if (isset($_FILES["files"])) {
817  // #15994 - we are keeping the upload files array structure
818  $res["files"] = $_FILES["files"];
819  }
820 
821  // global feedback
822  if ($a_form->getInput("fb")) {
823  $res["fb"] = true;
824  $res["fb_cron"] = $a_form->getInput("fb_cron");
825  $res["fb_date"] = $a_form->getInput("fb_date");
826  $res["fb_date_custom"] = $time_fb_custom_date;
827 
828  if ($_FILES["fb_file"]["tmp_name"]) {
829  $res["fb_file"] = $_FILES["fb_file"];
830  }
831  }
832  if ($a_form->getInput("rmd_submit_status")) {
833  $res["rmd_submit_status"] = true;
834  $res["rmd_submit_start"] = $a_form->getInput("rmd_submit_start");
835  $res["rmd_submit_freq"] = $a_form->getInput("rmd_submit_freq");
836  $res["rmd_submit_end"] = $reminder_submit_end_date;
837  $res["rmd_submit_template_id"] = $a_form->getInput("rmd_submit_template_id");
838  }
839  if ($a_form->getInput("rmd_grade_status")) {
840  $res["rmd_grade_status"] = true;
841  $res["rmd_grade_freq"] = $a_form->getInput("rmd_grade_freq");
842  $res["rmd_grade_end"] = $reminder_grade_end_date;
843  $res["rmd_grade_template_id"] = $a_form->getInput("rmd_grade_template_id");
844  }
845 
846  return $res;
847  } else {
848  $this->tpl->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
849  }
850  }
851 
852  return null;
853  }
854 
860  protected function importFormToAssignment(
861  ilExAssignment $a_ass,
862  array $a_input
863  ): void {
864  $is_create = !(bool) $a_ass->getId();
865 
866  $a_ass->setTitle($a_input["title"]);
867  $a_ass->setInstruction($a_input["instruction"]);
868  if (!$this->random_manager->isActivated()) {
869  $a_ass->setMandatory($a_input["mandatory"]);
870  }
871 
872  $a_ass->setStartTime($a_input["start"]);
873  $a_ass->setDeadline($a_input["deadline"]);
874  $a_ass->setExtendedDeadline($a_input["deadline_ext"]);
875  $a_ass->setDeadlineMode($a_input["deadline_mode"]);
876  $a_ass->setRelativeDeadline((int) ($a_input["relative_deadline"] ?? 0));
877  $a_ass->setRelDeadlineLastSubmission((int) ($a_input["rel_deadline_last_subm"] ?? 0));
878 
879  $a_ass->setMaxFile($a_input["max_file"]);
880  $a_ass->setTeamTutor((bool) ($a_input["team_creator"] ?? false));
881 
882  //$a_ass->setPortfolioTemplateId($a_input['template_id']);
883 
884  //$a_ass->setMinCharLimit($a_input['min_char_limit']);
885  //$a_ass->setMaxCharLimit($a_input['max_char_limit']);
886 
887  if (!$this->random_manager->isActivated()) {
888  $a_ass->setPeerReview((bool) ($a_input["peer"] ?? false));
889  }
890 
891  // peer review default values (on separate form)
892  if ($is_create) {
893  $a_ass->setPeerReviewMin(2);
894  $a_ass->setPeerReviewSimpleUnlock(0);
896  $a_ass->setPeerReviewPersonalized(false);
897  $a_ass->setPeerReviewFileUpload(false);
898  $a_ass->setPeerReviewText(true);
899  $a_ass->setPeerReviewRating(true);
900  }
901 
902  if (isset($a_input["fb"])) {
903  $a_ass->setFeedbackCron((bool) $a_input["fb_cron"]); // #13380
904  $a_ass->setFeedbackDate((int) $a_input["fb_date"]);
905  $a_ass->setFeedbackDateCustom((int) $a_input["fb_date_custom"]);
906  }
907 
908  // id needed for file handling
909  if ($is_create) {
910  $a_ass->save();
911 
912  // #15994 - assignment files
913  if (is_array($a_input["files"])) {
914  $this->domain->assignment()->instructionFiles($a_ass->getId())->importFromLegacyUpload($a_input["files"]);
915  }
916  } else {
917  // remove global feedback file?
918  if (!isset($a_input["fb"])) {
919  $a_ass->setFeedbackFile(null);
920  }
921 
922  $a_ass->update();
923  }
924 
925  // add global feedback file?
926  if (isset($a_input["fb"], $a_input["fb_file"])) {
927  $a_ass->handleGlobalFeedbackFileUpload($a_ass->getId(), $a_input["fb_file"]);
928  $a_ass->update();
929  }
930  $this->importFormToAssignmentReminders($a_input, $a_ass->getId());
931  }
932 
934  array $a_input,
935  int $a_ass_id
936  ): void {
937  $reminder = new ilExAssignmentReminder($this->exercise_id, $a_ass_id, ilExAssignmentReminder::SUBMIT_REMINDER);
938  $this->saveReminderData($reminder, $a_input);
939 
940  $reminder = new ilExAssignmentReminder($this->exercise_id, $a_ass_id, ilExAssignmentReminder::GRADE_REMINDER);
941  $this->saveReminderData($reminder, $a_input);
942  }
943 
944  //todo maybe we can refactor this method to use only one importFormToReminders
946  array $a_input,
947  int $a_ass_id
948  ): void {
949  $reminder = new ilExAssignmentReminder($this->exercise_id, $a_ass_id, ilExAssignmentReminder::FEEDBACK_REMINDER);
950  $this->saveReminderData($reminder, $a_input);
951  }
952 
953  protected function saveReminderData(
954  ilExAssignmentReminder $reminder,
955  array $a_input
956  ): void {
957  if ($reminder->getReminderStatus() === null) {
958  $action = "save";
959  } else {
960  $action = "update";
961  }
962  $type = $reminder->getReminderType();
963  $reminder->setReminderStatus((bool) ($a_input["rmd_" . $type . "_status"] ?? false));
964  $reminder->setReminderStart((int) ($a_input["rmd_" . $type . "_start"] ?? 0));
965  $reminder->setReminderEnd((int) ($a_input["rmd_" . $type . "_end"] ?? 0));
966  $reminder->setReminderFrequency((int) ($a_input["rmd_" . $type . "_freq"] ?? 0));
967  $reminder->setReminderMailTemplate((int) ($a_input["rmd_" . $type . "_template_id"] ?? 0));
968  $reminder->{$action}();
969  }
970 
976  public function saveAssignmentObject(): void
977  {
978  $tpl = $this->tpl;
979  $lng = $this->lng;
980  $ilCtrl = $this->ctrl;
981 
982  // #16163 - ignore ass id from request
983  $this->assignment = null;
984 
985  $form = $this->initAssignmentForm($this->requested_type, "create");
986  $input = $this->processForm($form);
987  if (is_array($input)) {
988  $ass = new ilExAssignment();
989  $ass->setExerciseId($this->exercise_id);
990  $ass->setType($input["type"]);
991  $ass_type_gui = $this->type_guis->getById($ass->getType());
992 
993  $this->importFormToAssignment($ass, $input);
994 
995  $this->generateTeams($ass, $input);
996  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
997 
998  $ass_type_gui->importFormToAssignment($ass, $form);
999  $ass->update();
1000 
1001  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1002 
1003  // because of sub-tabs we stay on settings screen
1004  $ilCtrl->setParameter($this, "ass_id", $ass->getId());
1005  $ilCtrl->redirect($this, "editAssignment");
1006  } else {
1007  $form->setValuesByPost();
1008  $tpl->setContent($form->getHTML());
1009  }
1010  }
1011 
1016  public function editAssignmentObject(): void
1017  {
1018  $ilTabs = $this->tabs;
1019  $tpl = $this->tpl;
1020 
1021  $this->setAssignmentHeader();
1022  $ilTabs->activateTab("ass_settings");
1023 
1024  $form = $this->initAssignmentForm($this->assignment->getType(), "edit");
1025  $this->getAssignmentValues($form);
1026  $tpl->setContent($form->getHTML());
1027  }
1028 
1033  public function getAssignmentValues(ilPropertyFormGUI $a_form): void
1034  {
1035  $lng = $this->lng;
1036  $ilCtrl = $this->ctrl;
1037  $ass_type_gui = $this->type_guis->getById($this->assignment->getType());
1038 
1039  $values = array();
1040  $values["type"] = $this->assignment->getType();
1041  $values["title"] = $this->assignment->getTitle();
1042  $values["mandatory"] = $this->assignment->getMandatory();
1043  $values["instruction"] = $this->assignment->getInstruction();
1044  if ($this->assignment->getStartTime()) {
1045  $values["start_time"] = new ilDateTime($this->assignment->getStartTime(), IL_CAL_UNIX);
1046  }
1047 
1048  if ($this->assignment->getAssignmentType()->usesFileUpload()) {
1049  if ($this->assignment->getMaxFile()) {
1050  $values["max_file_tgl"] = true;
1051  $values["max_file"] = $this->assignment->getMaxFile();
1052  }
1053  }
1054 
1055  if ($this->assignment->getAssignmentType()->usesTeams()) {
1056  $values["team_creator"] = (string) (int) $this->assignment->getTeamTutor();
1057  $values["team_creation"] = "0";
1058  }
1059 
1060  if ($this->assignment->getFeedbackDateCustom()) {
1061  $values["fb_date_custom"] = new ilDateTime($this->assignment->getFeedbackDateCustom(), IL_CAL_UNIX);
1062  }
1063 
1064  //Reminders
1065  $rmd_sub = new ilExAssignmentReminder($this->exercise_id, $this->assignment->getId(), ilExAssignmentReminder::SUBMIT_REMINDER);
1066  if ($rmd_sub->getReminderStatus()) {
1067  $values["rmd_submit_status"] = $rmd_sub->getReminderStatus();
1068  $values["rmd_submit_start"] = $rmd_sub->getReminderStart();
1069  $values["rmd_submit_end"] = new ilDateTime($rmd_sub->getReminderEnd(), IL_CAL_UNIX);
1070  $values["rmd_submit_freq"] = $rmd_sub->getReminderFrequency();
1071  $values["rmd_submit_template_id"] = $rmd_sub->getReminderMailTemplate();
1072  }
1073 
1074  $rmd_grade = new ilExAssignmentReminder($this->exercise_id, $this->assignment->getId(), ilExAssignmentReminder::GRADE_REMINDER);
1075  if ($rmd_grade->getReminderStatus()) {
1076  $values["rmd_grade_status"] = $rmd_grade->getReminderStatus();
1077  $values["rmd_grade_end"] = new ilDateTime($rmd_grade->getReminderEnd(), IL_CAL_UNIX);
1078  $values["rmd_grade_freq"] = $rmd_grade->getReminderFrequency();
1079  $values["rmd_grade_template_id"] = $rmd_grade->getReminderMailTemplate();
1080  }
1081 
1082  $type_values = $ass_type_gui->getFormValuesArray($this->assignment);
1083  $values = array_merge($values, $type_values);
1084 
1085 
1086  $values["deadline_mode"] = $this->assignment->getDeadlineMode();
1087  if ($values["deadline_mode"] === 0 && !$this->assignment->getDeadline()) {
1088  $values["deadline_mode"] = -1;
1089  }
1090  $values["relative_deadline"] = $this->assignment->getRelativeDeadline();
1091  $dt = new ilDateTime($this->assignment->getRelDeadlineLastSubmission(), IL_CAL_UNIX);
1092  $values["rel_deadline_last_subm"] = $dt->get(IL_CAL_DATETIME);
1093 
1094 
1095  $a_form->setValuesByArray($values);
1096 
1097  // global feedback
1098  if ($this->assignment->getFeedbackFile()) {
1099  $sample_solution = $this->domain->assignment()->sampleSolution($this->assignment->getId());
1100  $a_form->getItemByPostVar("fb")->setChecked(true);
1101 
1102  $a_form->getItemByPostVar("fb_file")->setValue($sample_solution->getFilename());
1103  $a_form->getItemByPostVar("fb_file")->setRequired(false); // #15467
1104  $a_form->getItemByPostVar("fb_file")->setInfo(
1105  // #16400
1106  '<a href="' . $ilCtrl->getLinkTarget($this, "downloadGlobalFeedbackFile") . '">' .
1107  $lng->txt("download") . '</a>'
1108  );
1109  }
1110  $a_form->getItemByPostVar("fb_cron")->setChecked($this->assignment->hasFeedbackCron());
1111  $a_form->getItemByPostVar("fb_date")->setValue($this->assignment->getFeedbackDate());
1112 
1113  $this->handleDisabledFields($a_form, true);
1114  }
1115 
1119  protected function setDisabledFieldValues(ilPropertyFormGUI $a_form): void
1120  {
1121  // dates
1122  if ($this->assignment->getDeadline() > 0) {
1123  $edit_date = new ilDateTime($this->assignment->getDeadline(), IL_CAL_UNIX);
1124  $ed_item = $a_form->getItemByPostVar("deadline");
1125  $ed_item->setDate($edit_date);
1126 
1127  if ($this->assignment->getExtendedDeadline() > 0) {
1128  $edit_date = new ilDateTime($this->assignment->getExtendedDeadline(), IL_CAL_UNIX);
1129  $ed_item = $a_form->getItemByPostVar("deadline2");
1130  $ed_item->setDate($edit_date);
1131  }
1132  }
1133 
1134  if ($this->assignment->getPeerReview()) {
1135  $a_form->getItemByPostVar("peer")->setChecked($this->assignment->getPeerReview());
1136  }
1137  }
1138 
1142  protected function handleDisabledFields(
1143  ilPropertyFormGUI $a_form,
1144  bool $a_force_set_values = false
1145  ): void {
1146  // potentially disabled elements are initialized here to re-use this
1147  // method after setValuesByPost() - see updateAssignmentObject()
1148 
1149  // team assignments do not support peer review
1150  // with no active peer review there is nothing to protect
1151  $peer_review = null;
1152  if (!$this->assignment->getAssignmentType()->usesTeams() &&
1153  $this->assignment->getPeerReview()) {
1154  // #14450
1155  $peer_review = new ilExPeerReview($this->assignment);
1156  if ($peer_review->hasPeerReviewGroups()) {
1157  // deadline(s) are past and must not change
1158  $a_form->getItemByPostVar("deadline")->setDisabled(true);
1159  $a_form->getItemByPostVar("deadline2")->setDisabled(true);
1160 
1161  $a_form->getItemByPostVar("peer")->setDisabled(true);
1162 
1163  $a_form->getItemByPostVar("deadline_mode")->setDisabled(true);
1164  }
1165  }
1166 
1167  if ($a_force_set_values ||
1168  ($peer_review && $peer_review->hasPeerReviewGroups())) {
1169  $this->setDisabledFieldValues($a_form);
1170  }
1171  }
1172 
1178  public function updateAssignmentObject(): void
1179  {
1180  $tpl = $this->tpl;
1181  $lng = $this->lng;
1182  $ilCtrl = $this->ctrl;
1183  $ilTabs = $this->tabs;
1184 
1185  $form = $this->initAssignmentForm($this->assignment->getType(), "edit");
1186  $input = $this->processForm($form);
1187 
1188  $ass_type = $this->assignment->getType();
1189  $ass_type_gui = $this->type_guis->getById($ass_type);
1190 
1191  if (is_array($input)) {
1192  $old_deadline = $this->assignment->getDeadline();
1193  $old_ext_deadline = $this->assignment->getExtendedDeadline();
1194 
1195  $this->importFormToAssignment($this->assignment, $input);
1196  $this->generateTeams($this->assignment, $input);
1197 
1198  $ass_type_gui->importFormToAssignment($this->assignment, $form);
1199  $this->assignment->update();
1200 
1201  $new_deadline = $this->assignment->getDeadline();
1202  $new_ext_deadline = $this->assignment->getExtendedDeadline();
1203 
1204  // if deadlines were changed
1205  if ($old_deadline != $new_deadline ||
1206  $old_ext_deadline != $new_ext_deadline) {
1207  $subm = $this->domain->submission($this->assignment->getId());
1208  $subm->recalculateLateSubmissions();
1209  }
1210 
1211  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1212  $ilCtrl->redirect($this, "editAssignment");
1213  } else {
1214  $this->setAssignmentHeader();
1215  $ilTabs->activateTab("ass_settings");
1216 
1217  $form->setValuesByPost();
1218  $this->handleDisabledFields($form);
1219  $tpl->setContent($form->getHTML());
1220  }
1221  }
1222 
1223  public function confirmAssignmentsDeletionObject(): void
1224  {
1225  $ilCtrl = $this->ctrl;
1226  $tpl = $this->tpl;
1227  $lng = $this->lng;
1228 
1229  $ilCtrl->setParameterByClass(ilObjExerciseGUI::class, "ass_id", null);
1230  if (count($this->requested_ass_ids) == 0) {
1231  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
1232  $ilCtrl->redirect($this, "listAssignments");
1233  } else {
1234  $cgui = new ilConfirmationGUI();
1235  $cgui->setFormAction($ilCtrl->getFormAction($this));
1236  $cgui->setHeaderText($lng->txt("exc_conf_del_assignments"));
1237  $cgui->setCancel($lng->txt("cancel"), "listAssignments");
1238  $cgui->setConfirm($lng->txt("delete"), "deleteAssignments");
1239 
1240  foreach ($this->requested_ass_ids as $i) {
1241  $cgui->addItem("id[]", $i, ilExAssignment::lookupTitle($i));
1242  }
1243 
1244  $tpl->setContent($cgui->getHTML());
1245  }
1246  }
1247 
1252  public function deleteAssignmentsObject(): void
1253  {
1254  $ilCtrl = $this->ctrl;
1255  $lng = $this->lng;
1256  $delete = false;
1257  foreach ($this->requested_ass_ids as $id) {
1258  $ass = new ilExAssignment(ilUtil::stripSlashes($id));
1259  $ass->delete($this->exc);
1260  $delete = true;
1261  }
1262 
1263  if ($delete) {
1264  $this->tpl->setOnScreenMessage('success', $lng->txt("exc_assignments_deleted"), true);
1265  }
1266  $ilCtrl->setParameter($this, "ass_id", "");
1267  $ilCtrl->redirect($this, "listAssignments");
1268  }
1269 
1270  public function saveAssignmentOrderObject(): void
1271  {
1272  $lng = $this->lng;
1273  $ilCtrl = $this->ctrl;
1274 
1276  $this->exercise_id,
1277  $this->requested_order
1278  );
1279 
1280  $this->tpl->setOnScreenMessage('success', $lng->txt("exc_saved_order"), true);
1281  $ilCtrl->redirect($this, "listAssignments");
1282  }
1283 
1284  public function orderAssignmentsByDeadlineObject(): void
1285  {
1286  $lng = $this->lng;
1287  $ilCtrl = $this->ctrl;
1288 
1289  ilExAssignment::orderAssByDeadline($this->exercise_id);
1290 
1291  $this->tpl->setOnScreenMessage('success', $lng->txt("exc_saved_order"), true);
1292  $ilCtrl->redirect($this, "listAssignments");
1293  }
1294 
1295  public function setAssignmentHeader(): void
1296  {
1297  $ilTabs = $this->tabs;
1298  $lng = $this->lng;
1299  $ilCtrl = $this->ctrl;
1300  $tpl = $this->tpl;
1301  $ilHelp = $this->help;
1302 
1303  $tpl->setTitle($this->assignment->getTitle());
1304  $tpl->setDescription("");
1305 
1306  $ilTabs->clearTargets();
1307  $ilHelp->setScreenIdComponent("exc");
1308 
1309  $ilTabs->setBackTarget(
1310  $lng->txt("back"),
1311  $ilCtrl->getLinkTarget($this, "listAssignments")
1312  );
1313 
1314  $ilTabs->addTab(
1315  "ass_settings",
1316  $lng->txt("settings"),
1317  $ilCtrl->getLinkTarget($this, "editAssignment")
1318  );
1319 
1320  if (!$this->assignment->getAssignmentType()->usesTeams() &&
1321  $this->assignment->getPeerReview()) {
1322  $ilTabs->addTab(
1323  "peer_settings",
1324  $lng->txt("exc_peer_review"),
1325  $ilCtrl->getLinkTarget($this, "editPeerReview")
1326  );
1327  }
1328  $ilCtrl->setParameterByClass(ilObjExerciseGUI::class, "mode", null);
1329  $ilTabs->addTab(
1330  "ass_files",
1331  $lng->txt("exc_instruction_files"),
1332  $ilCtrl->getLinkTargetByClass(array("ilexassignmenteditorgui", ilResourceCollectionGUI::class))
1333  );
1334  }
1335 
1336  public function downloadGlobalFeedbackFileObject(): void
1337  {
1338  $ilCtrl = $this->ctrl;
1339 
1340  if (!$this->assignment ||
1341  !$this->assignment->getFeedbackFile()) {
1342  $ilCtrl->redirect($this, "returnToParent");
1343  }
1344  $this->domain->assignment()->sampleSolution($this->assignment->getId())->deliver();
1345  }
1346 
1347 
1348  //
1349  // PEER REVIEW
1350  //
1351 
1353  {
1354  $ilCtrl = $this->ctrl;
1355  $lng = $this->lng;
1356 
1357  $form = new ilPropertyFormGUI();
1358  $form->setTitle($lng->txt("exc_peer_review"));
1359  $form->setFormAction($ilCtrl->getFormAction($this));
1360 
1361  $peer_min = new ilNumberInputGUI($lng->txt("exc_peer_review_min_number"), "peer_min");
1362  $peer_min->setInfo($lng->txt("exc_peer_review_min_number_info")); // #16161
1363  $peer_min->setRequired(true);
1364  $peer_min->setSize(3);
1365  $peer_min->setValue(2);
1366  $form->addItem($peer_min);
1367 
1368  $peer_unlock = new ilRadioGroupInputGUI($lng->txt("exc_peer_review_simple_unlock"), "peer_unlock");
1369  $peer_unlock->addOption(new ilRadioOption($lng->txt("exc_peer_review_simple_unlock_immed"), 2));
1370  $peer_unlock->addOption(new ilRadioOption($lng->txt("exc_peer_review_simple_unlock_active"), 1));
1371  $peer_unlock->addOption(new ilRadioOption($lng->txt("exc_peer_review_simple_unlock_inactive"), 0));
1372  $peer_unlock->setRequired(true);
1373  $peer_unlock->setValue(0);
1374  $form->addItem($peer_unlock);
1375 
1376  if ($this->enable_peer_review_completion) {
1377  $peer_cmpl = new ilRadioGroupInputGUI($lng->txt("exc_peer_review_completion"), "peer_valid");
1378  $option = new ilRadioOption($lng->txt("exc_peer_review_completion_none"), ilExAssignment::PEER_REVIEW_VALID_NONE);
1379  $option->setInfo($lng->txt("exc_peer_review_completion_none_info"));
1380  $peer_cmpl->addOption($option);
1381  $option = new ilRadioOption($lng->txt("exc_peer_review_completion_one"), ilExAssignment::PEER_REVIEW_VALID_ONE);
1382  $option->setInfo($lng->txt("exc_peer_review_completion_one_info"));
1383  $peer_cmpl->addOption($option);
1384  $option = new ilRadioOption($lng->txt("exc_peer_review_completion_all"), ilExAssignment::PEER_REVIEW_VALID_ALL);
1385  $option->setInfo($lng->txt("exc_peer_review_completion_all_info"));
1386  $peer_cmpl->addOption($option);
1387  $peer_cmpl->setRequired(true);
1388  $peer_cmpl->setValue(ilExAssignment::PEER_REVIEW_VALID_NONE);
1389  $form->addItem($peer_cmpl);
1390  }
1391 
1392  $peer_dl = new ilDateTimeInputGUI($lng->txt("exc_peer_review_deadline"), "peer_dl");
1393  $peer_dl->setInfo($lng->txt("exc_peer_review_deadline_info"));
1394  $peer_dl->setShowTime(true);
1395  $form->addItem($peer_dl);
1396 
1397  $peer_prsl = new ilCheckboxInputGUI($lng->txt("exc_peer_review_personal"), "peer_prsl");
1398  $peer_prsl->setInfo($lng->txt("exc_peer_review_personal_info"));
1399  $form->addItem($peer_prsl);
1400 
1401  //feedback reminders
1402  $rmd_feedback = new ilCheckboxInputGUI($this->lng->txt("exc_reminder_feedback_setting"), "rmd_peer_status");
1403 
1404  $rmd_submit_start = new ilNumberInputGUI($this->lng->txt("exc_reminder_feedback_start"), "rmd_peer_start");
1405  $rmd_submit_start->setSize(3);
1406  $rmd_submit_start->setMaxLength(3);
1407  $rmd_submit_start->setSuffix($lng->txt('days'));
1408  $rmd_submit_start->setRequired(true);
1409  $rmd_submit_start->setMinValue(1);
1410  $rmd_feedback->addSubItem($rmd_submit_start);
1411 
1412  $rmd_submit_frequency = new ilNumberInputGUI($this->lng->txt("exc_reminder_frequency"), "rmd_peer_freq");
1413  $rmd_submit_frequency->setSize(3);
1414  $rmd_submit_frequency->setMaxLength(3);
1415  $rmd_submit_frequency->setSuffix($lng->txt('days'));
1416  $rmd_submit_frequency->setRequired(true);
1417  $rmd_submit_frequency->setMinValue(1);
1418  $rmd_feedback->addSubItem($rmd_submit_frequency);
1419 
1420  $rmd_submit_end = new ilDateTimeInputGUI($lng->txt("exc_reminder_end"), "rmd_peer_end");
1421  $rmd_submit_end->setRequired(true);
1422  $rmd_feedback->addSubItem($rmd_submit_end);
1423 
1424  $rmd_feedback->addSubItem($this->addMailTemplatesRadio(ilExAssignmentReminder::FEEDBACK_REMINDER));
1425 
1426  $form->addItem($rmd_feedback);
1427 
1428  // criteria
1429 
1430  $cats = new ilRadioGroupInputGUI($lng->txt("exc_criteria_catalogues"), "crit_cat");
1431  $form->addItem($cats);
1432 
1433  // default (no catalogue)
1434 
1435  $def = new ilRadioOption($lng->txt("exc_criteria_catalogue_default"), -1);
1436  $cats->addOption($def);
1437 
1438  $peer_text = new ilCheckboxInputGUI($lng->txt("exc_peer_review_text"), "peer_text");
1439  $def->addSubItem($peer_text);
1440 
1441  $peer_char = new ilNumberInputGUI($lng->txt("exc_peer_review_min_chars"), "peer_char");
1442  $peer_char->setInfo($lng->txt("exc_peer_review_min_chars_info"));
1443  $peer_char->setSize(3);
1444  $peer_text->addSubItem($peer_char);
1445 
1446  $peer_rating = new ilCheckboxInputGUI($lng->txt("exc_peer_review_rating"), "peer_rating");
1447  $def->addSubItem($peer_rating);
1448 
1449  $peer_file = new ilCheckboxInputGUI($lng->txt("exc_peer_review_file"), "peer_file");
1450  $peer_file->setInfo($lng->txt("exc_peer_review_file_info"));
1451  $def->addSubItem($peer_file);
1452 
1453  // catalogues
1454 
1455  $cat_objs = ilExcCriteriaCatalogue::getInstancesByParentId($this->exercise_id);
1456  if (sizeof($cat_objs)) {
1457  foreach ($cat_objs as $cat_obj) {
1458  $crits = ilExcCriteria::getInstancesByParentId($cat_obj->getId());
1459 
1460  // only non-empty catalogues
1461  if (sizeof($crits)) {
1462  $titles = array();
1463  foreach ($crits as $crit) {
1464  $titles[] = $crit->getTitle();
1465  }
1466  $opt = new ilRadioOption($cat_obj->getTitle(), $cat_obj->getId());
1467  $opt->setInfo(implode(", ", $titles));
1468  $cats->addOption($opt);
1469  }
1470  }
1471  } else {
1472  // see ilExcCriteriaCatalogueGUI::view()
1473  $url = $ilCtrl->getLinkTargetByClass("ilexccriteriacataloguegui", "");
1474  $def->setInfo('<a href="' . $url . '">[+] ' .
1475  $lng->txt("exc_add_criteria_catalogue") .
1476  '</a>');
1477  }
1478 
1479 
1480  $form->addCommandButton("updatePeerReview", $lng->txt("save"));
1481  $form->addCommandButton("editAssignment", $lng->txt("cancel"));
1482 
1483  return $form;
1484  }
1485 
1489  public function editPeerReviewObject(ilPropertyFormGUI $a_form = null): void
1490  {
1491  $ilTabs = $this->tabs;
1492  $tpl = $this->tpl;
1493 
1494  $this->setAssignmentHeader();
1495  $ilTabs->activateTab("peer_settings");
1496 
1497  if ($a_form === null) {
1498  $a_form = $this->initPeerReviewForm();
1499  $this->getPeerReviewValues($a_form);
1500  }
1501  $tpl->setContent($a_form->getHTML());
1502  }
1503 
1507  protected function getPeerReviewValues(\ilPropertyFormGUI $a_form): void
1508  {
1509  $values = array();
1510 
1511  if ($this->assignment->getPeerReviewDeadline() > 0) {
1512  $values["peer_dl"] = new ilDateTime($this->assignment->getPeerReviewDeadline(), IL_CAL_UNIX);
1513  }
1514 
1515  $reminder = new ilExAssignmentReminder($this->exercise_id, $this->assignment->getId(), ilExAssignmentReminder::FEEDBACK_REMINDER);
1516  if ($reminder->getReminderStatus()) {
1517  $values["rmd_peer_status"] = $reminder->getReminderStatus();
1518  $values["rmd_peer_start"] = $reminder->getReminderStart();
1519  $values["rmd_peer_end"] = new ilDateTime($reminder->getReminderEnd(), IL_CAL_UNIX);
1520  $values["rmd_peer_freq"] = $reminder->getReminderFrequency();
1521  $values["rmd_peer_template_id"] = $reminder->getReminderMailTemplate();
1522  }
1523 
1524  $a_form->setValuesByArray($values);
1525 
1526  $this->handleDisabledPeerFields($a_form, true);
1527  }
1528 
1529  protected function setDisabledPeerReviewFieldValues(ilPropertyFormGUI $a_form): void
1530  {
1531  $a_form->getItemByPostVar("peer_min")->setValue($this->assignment->getPeerReviewMin());
1532  $a_form->getItemByPostVar("peer_prsl")->setChecked($this->assignment->hasPeerReviewPersonalized());
1533  $a_form->getItemByPostVar("peer_unlock")->setValue($this->assignment->getPeerReviewSimpleUnlock());
1534 
1535  if ($this->enable_peer_review_completion) {
1536  $a_form->getItemByPostVar("peer_valid")->setValue($this->assignment->getPeerReviewValid());
1537  }
1538 
1539  $cat = $this->assignment->getPeerReviewCriteriaCatalogue();
1540  if ($cat < 1) {
1541  $cat = -1;
1542 
1543  // default / no catalogue
1544  $a_form->getItemByPostVar("peer_text")->setChecked($this->assignment->hasPeerReviewText());
1545  $a_form->getItemByPostVar("peer_rating")->setChecked($this->assignment->hasPeerReviewRating());
1546  $a_form->getItemByPostVar("peer_file")->setChecked($this->assignment->hasPeerReviewFileUpload());
1547  if ($this->assignment->getPeerReviewChars() > 0) {
1548  $a_form->getItemByPostVar("peer_char")->setValue($this->assignment->getPeerReviewChars());
1549  }
1550  }
1551  $a_form->getItemByPostVar("crit_cat")->setValue($cat);
1552  }
1553 
1554  protected function handleDisabledPeerFields(
1555  ilPropertyFormGUI $a_form,
1556  bool $a_force_set_values = false
1557  ): void {
1558  // #14450
1559  $peer_review = new ilExPeerReview($this->assignment);
1560  if ($peer_review->hasPeerReviewGroups()) {
1561  // JourFixe, 2015-05-11 - editable again
1562  // $a_form->getItemByPostVar("peer_dl")->setDisabled(true);
1563 
1564  $a_form->getItemByPostVar("peer_min")->setDisabled(true);
1565  $a_form->getItemByPostVar("peer_prsl")->setDisabled(true);
1566  $a_form->getItemByPostVar("peer_unlock")->setDisabled(true);
1567 
1568  if ($this->enable_peer_review_completion) {
1569  $a_form->getItemByPostVar("peer_valid")->setDisabled(true);
1570  }
1571 
1572  $a_form->getItemByPostVar("crit_cat")->setDisabled(true);
1573  $a_form->getItemByPostVar("peer_text")->setDisabled(true);
1574  $a_form->getItemByPostVar("peer_char")->setDisabled(true);
1575  $a_form->getItemByPostVar("peer_rating")->setDisabled(true);
1576  $a_form->getItemByPostVar("peer_file")->setDisabled(true);
1577 
1578  // required number input is a problem
1579  $min = new ilHiddenInputGUI("peer_min");
1580  $min->setValue($this->assignment->getPeerReviewMin());
1581  $a_form->addItem($min);
1582  }
1583 
1584  if ($a_force_set_values ||
1585  $peer_review->hasPeerReviewGroups()) {
1586  $this->setDisabledPeerReviewFieldValues($a_form);
1587  }
1588  }
1589 
1594  protected function processPeerReviewForm(
1595  ilPropertyFormGUI $a_form
1596  ): ?array {
1597  $lng = $this->lng;
1598 
1599  $protected_peer_review_groups = false;
1600  $peer_review = new ilExPeerReview($this->assignment);
1601  if ($peer_review->hasPeerReviewGroups()) {
1602  $protected_peer_review_groups = true;
1603  }
1604 
1605  $valid = $a_form->checkInput();
1606  if ($valid) {
1607  // dates
1608  $time_deadline = $this->assignment->getDeadline();
1609  $time_deadline_ext = $this->assignment->getExtendedDeadline();
1610  $time_deadline_max = max($time_deadline, $time_deadline_ext);
1611 
1612  $date = $a_form->getItemByPostVar("peer_dl")->getDate();
1613  $time_peer = $date
1614  ? $date->get(IL_CAL_UNIX)
1615  : null;
1616 
1617  $reminder_date = $a_form->getItemByPostVar("rmd_peer_end")->getDate();
1618  $reminder_date = $reminder_date
1619  ? $reminder_date->get(IL_CAL_UNIX)
1620  : null;
1621 
1622  // peer < any deadline?
1623  if ($time_peer && $time_deadline_max && $time_peer < $time_deadline_max) {
1624  $a_form->getItemByPostVar("peer_dl")
1625  ->setAlert($lng->txt("exc_peer_deadline_mismatch"));
1626  $valid = false;
1627  }
1628 
1629  if (!$protected_peer_review_groups) {
1630  if ($a_form->getInput("crit_cat") < 0 &&
1631  !$a_form->getInput("peer_text") &&
1632  !$a_form->getInput("peer_rating") &&
1633  !$a_form->getInput("peer_file")) {
1634  $a_form->getItemByPostVar("peer_file")
1635  ->setAlert($lng->txt("select_one"));
1636  $valid = false;
1637  }
1638  }
1639 
1640  if ($valid) {
1641  $res = array();
1642  $res["peer_dl"] = $time_peer;
1643 
1644  if ($protected_peer_review_groups) {
1645  $res["peer_min"] = $this->assignment->getPeerReviewMin();
1646  $res["peer_unlock"] = $this->assignment->getPeerReviewSimpleUnlock();
1647  $res["peer_prsl"] = $this->assignment->hasPeerReviewPersonalized();
1648  $res["peer_valid"] = $this->assignment->getPeerReviewValid();
1649 
1650  $res["peer_text"] = $this->assignment->hasPeerReviewText();
1651  $res["peer_rating"] = $this->assignment->hasPeerReviewRating();
1652  $res["peer_file"] = $this->assignment->hasPeerReviewFileUpload();
1653  $res["peer_char"] = $this->assignment->getPeerReviewChars();
1654  $res["crit_cat"] = $this->assignment->getPeerReviewCriteriaCatalogue();
1655 
1656  $res["peer_valid"] = $this->enable_peer_review_completion
1657  ? $res["peer_valid"]
1658  : null;
1659  } else {
1660  $res["peer_min"] = $a_form->getInput("peer_min");
1661  $res["peer_unlock"] = $a_form->getInput("peer_unlock");
1662  $res["peer_prsl"] = $a_form->getInput("peer_prsl");
1663  $res["peer_valid"] = $a_form->getInput("peer_valid");
1664 
1665  $res["peer_text"] = $a_form->getInput("peer_text");
1666  $res["peer_rating"] = $a_form->getInput("peer_rating");
1667  $res["peer_file"] = $a_form->getInput("peer_file");
1668  $res["peer_char"] = $a_form->getInput("peer_char");
1669  $res["crit_cat"] = $a_form->getInput("crit_cat");
1670  }
1671  if ($a_form->getInput("rmd_peer_status")) {
1672  $res["rmd_peer_status"] = $a_form->getInput("rmd_peer_status");
1673  $res["rmd_peer_start"] = $a_form->getInput("rmd_peer_start");
1674  $res["rmd_peer_end"] = $reminder_date;
1675  $res["rmd_peer_freq"] = $a_form->getInput("rmd_peer_freq");
1676  $res["rmd_peer_template_id"] = $a_form->getInput("rmd_peer_template_id");
1677  }
1678 
1679  return $res;
1680  } else {
1681  $this->tpl->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
1682  }
1683  }
1684  return null;
1685  }
1686 
1691  ilExAssignment $a_ass,
1692  array $a_input
1693  ): void {
1694  $a_ass->setPeerReviewMin((int) $a_input["peer_min"]);
1695  $a_ass->setPeerReviewDeadline((int) $a_input["peer_dl"]);
1696  $a_ass->setPeerReviewSimpleUnlock((int) $a_input["peer_unlock"]);
1697  $a_ass->setPeerReviewPersonalized((bool) $a_input["peer_prsl"]);
1698 
1699  // #18964
1700  $a_ass->setPeerReviewValid($a_input["peer_valid"]
1702 
1703  $a_ass->setPeerReviewFileUpload((bool) $a_input["peer_file"]);
1704  $a_ass->setPeerReviewChars((int) $a_input["peer_char"]);
1705  $a_ass->setPeerReviewText((bool) $a_input["peer_text"]);
1706  $a_ass->setPeerReviewRating((bool) $a_input["peer_rating"]);
1707  $a_ass->setPeerReviewCriteriaCatalogue($a_input["crit_cat"] > 0
1708  ? (int) $a_input["crit_cat"]
1709  : null);
1710 
1711  $a_ass->update();
1712 
1713  $this->importPeerReviewFormToAssignmentReminders($a_input, $a_ass->getId());
1714  }
1715 
1719  protected function updatePeerReviewObject(): void
1720  {
1721  $tpl = $this->tpl;
1722  $lng = $this->lng;
1723  $ilCtrl = $this->ctrl;
1724  $ilTabs = $this->tabs;
1725 
1726  $form = $this->initPeerReviewForm();
1727  $input = $this->processPeerReviewForm($form);
1728  if (is_array($input)) {
1729  $this->importPeerReviewFormToAssignment($this->assignment, $input);
1730  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1731  $ilCtrl->redirect($this, "editPeerReview");
1732  } else {
1733  $this->setAssignmentHeader();
1734  $ilTabs->activateTab("peer_settings");
1735 
1736  $form->setValuesByPost();
1737  $this->handleDisabledPeerFields($form);
1738  $tpl->setContent($form->getHTML());
1739  }
1740  }
1741 
1742 
1743  //
1744  // TEAM
1745  //
1746 
1747  public function validationTeamsFormation(
1748  int $a_num_teams,
1749  int $a_min_participants,
1750  int $a_max_participants
1751  ): array {
1752  $total_members = $this->getExerciseTotalMembers();
1753  $number_of_teams = $a_num_teams;
1754 
1755  if ($number_of_teams) {
1756  $members_per_team = round($total_members / $a_num_teams);
1757  } else {
1758  if ($a_min_participants) {
1759  $number_of_teams = round($total_members / $a_min_participants);
1760  $participants_extra_team = $total_members % $a_min_participants;
1761  if ($participants_extra_team > $number_of_teams) {
1762  //Can't create teams with this minimum of participants.
1763  $message = sprintf($this->lng->txt("exc_team_minimal_too_big"), $a_min_participants);
1764  return array("status" => "error", "msg" => $message, "field" => "min_participants_team");
1765  }
1766  }
1767  $members_per_team = 0;
1768  }
1769 
1770  if ($a_min_participants > $a_max_participants) {
1771  $message = $this->lng->txt("exc_team_min_big_than_max");
1772  return array("status" => "error", "msg" => $message, "field" => "max_participants_team");
1773  }
1774 
1775  if ($a_max_participants > 0 && $members_per_team > $a_max_participants) {
1776  $message = sprintf($this->lng->txt("exc_team_max_small_than_members"), $a_max_participants, $members_per_team);
1777  return array("status" => "error", "msg" => $message, "field" => "max_participants_team");
1778  }
1779 
1780  if ($members_per_team > 0 && $members_per_team < $a_min_participants) {
1781  $message = sprintf($this->lng->txt("exc_team_min_small_than_members"), $a_min_participants, $members_per_team);
1782  return array("status" => "error", "msg" => $message, "field" => "min_participants_team");
1783  }
1784 
1785  return array("status" => "success", "msg" => "");
1786  }
1787 
1788  // Get the total number of exercise members
1789  public function getExerciseTotalMembers(): int
1790  {
1791  $exercise = new ilObjExercise($this->exercise_id, false);
1792  $exc_members = new ilExerciseMembers($exercise);
1793 
1794  return count($exc_members->getMembers());
1795  }
1796 
1797  public function generateTeams(
1798  ilExAssignment $a_assignment,
1799  array $a_input
1800  ): void {
1801  $ass_type = $a_assignment->getAssignmentType();
1802  if ($ass_type->usesTeams() &&
1803  $a_input['team_creator'] == ilExAssignment::TEAMS_FORMED_BY_TUTOR) {
1804  if ($a_input['team_creation'] == ilExAssignment::TEAMS_FORMED_BY_RANDOM) {
1805  $number_teams = $a_input['number_teams'];
1806  if (count(ilExAssignmentTeam::getAssignmentTeamMap($a_assignment->getId())) == 0) {
1807  $ass_team = new ilExAssignmentTeam();
1808  $ass_team->createRandomTeams($this->exercise_id, $a_assignment->getId(), $number_teams, $a_input['min_participants_team']);
1809  }
1810  } elseif ($a_input['team_creation'] == ilExAssignment::TEAMS_FORMED_BY_ASSIGNMENT) {
1811  ilExAssignmentTeam::adoptTeams($a_input["ass_adpt"], $a_assignment->getId());
1812  $this->tpl->setOnScreenMessage('info', $this->lng->txt("exc_teams_assignment_adopted"), true);
1813  }
1814  }
1815  }
1816 }
getPeerReviewValues(\ilPropertyFormGUI $a_form)
setStartTime(?int $a_val)
setRelativeDeadline(int $a_val)
importPeerReviewFormToAssignmentReminders(array $a_input, int $a_ass_id)
setFilenames(array $a_filenames)
Class ilExAssignmentEditorGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
initAssignmentForm(int $a_type, string $a_mode="create")
handleDisabledFields(ilPropertyFormGUI $a_form, bool $a_force_set_values=false)
ILIAS Exercise InternalDomainService $domain
Exercise assignment.
$context
Definition: webdav.php:31
const IL_CAL_DATETIME
ILIAS ResourceStorage Services $irss
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
editPeerReviewObject(ilPropertyFormGUI $a_form=null)
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
setFeedbackFile(?string $a_value)
getItemByPostVar(string $a_post_var)
setPeerReviewValid(int $a_value)
Set peer review validation.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setFeedbackDateCustom(int $a_value)
Set (global) feedback file availability using a custom date.
static getInstancesByParentId(int $a_parent_id)
handleGlobalFeedbackFileUpload(int $ass_id, array $a_file)
This class represents a file property in a property form.
setInfo(string $a_info)
processForm(ilPropertyFormGUI $a_form)
Custom form validation.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setPeerReviewMin(int $a_value)
Help GUI class.
setPeerReviewFileUpload(bool $a_val)
$valid
static lookupTitle(int $a_id)
Handles exercise Grade reminder mail placeholders If all contexts are using the same placeholders...
This class represents a file wizard property in a property form.
setDate($a_date, int $a_format)
Set date.
static saveAssOrderOfExercise(int $a_ex_id, array $a_order)
setDeadlineMode(int $a_val)
Set deadline mode.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAdoptableTeamAssignments(int $a_exercise_id, int $a_exclude_ass_id=null, int $a_user_id=null)
validationTeamsFormation(int $a_num_teams, int $a_min_participants, int $a_max_participants)
Mandatory RandomAssignmentsManager $random_manager
setShowTime(bool $a_showtime)
static getInstancesByParentId(int $a_parent_id)
addOption(ilRadioOption $a_option)
loadLanguageModule(string $a_module)
Load language module.
$url
Definition: shib_logout.php:63
setOptions(array $a_options)
setFeedbackCron(bool $a_value)
Toggle (global) feedback file cron.
static orderAssByDeadline(int $a_ex_id)
generateTeams(ilExAssignment $a_assignment, array $a_input)
Handles exercise Peer reminder mail placeholders If all contexts are using the same placeholders...
const IL_CAL_UNIX
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-...
setInstruction(string $a_val)
This class represents a date/time property in a property form.
getAssignmentValues(ilPropertyFormGUI $a_form)
setTeamTutor(bool $a_value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Exercise peer review.
ILIAS Exercise InternalGUIService $gui
Class ilObjExercise.
This class represents a property in a property form.
setPeerReviewRating(bool $a_val)
setExtendedDeadline(?int $a_val)
Manages random mandatory assignments of an exercise (business logic)
processPeerReviewForm(ilPropertyFormGUI $a_form)
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...
global $DIC
Definition: shib_login.php:25
setMandatory(bool $a_val)
setFeedbackDate(int $a_value)
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
setPeerReviewDeadline(int $a_val)
setRequired(bool $a_required)
setRelDeadlineLastSubmission(int $a_val)
static getAssignmentTeamMap(int $a_ass_id)
importFormToAssignmentReminders(array $a_input, int $a_ass_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setPeerReviewPersonalized(bool $a_val)
saveReminderData(ilExAssignmentReminder $reminder, array $a_input)
importFormToAssignment(ilExAssignment $a_ass, array $a_input)
Import form values to assignment.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
setDescription(string $a_descr)
Sets description below title in standard template.
setPeerReviewSimpleUnlock(int $a_value)
setPeerReviewChars(?int $a_value)
handleDisabledPeerFields(ilPropertyFormGUI $a_form, bool $a_force_set_values=false)
setPeerReviewText(bool $a_val)
static adoptTeams(int $a_source_ass_id, int $a_target_ass_id, int $a_user_id=null, int $a_exc_ref_id=null)
ILIAS Exercise InstructionFile InstructionFileManager $instruction_files
importPeerReviewFormToAssignment(ilExAssignment $a_ass, array $a_input)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
setMaxFile(?int $a_value)
setDisabledPeerReviewFieldValues(ilPropertyFormGUI $a_form)
setTitle(string $a_val)
setPeerReview(bool $a_value)
setReminderStatus(?bool $a_status)
Set reminder for users without submission.
addMailTemplatesRadio(string $a_reminder_type)
setPeerReviewCriteriaCatalogue(?int $a_value)
setDeadline(?int $a_val)
Handles exercise Submit reminder mail placeholders If all contexts are using the same placeholders...
setContent(string $a_html)
Sets content for standard template.
ILIAS FileUpload FileUpload $upload
setDisabledFieldValues(ilPropertyFormGUI $a_form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...