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