ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjExerciseGUI.php
Go to the documentation of this file.
1 <?php
2 
20 use ILIAS\Exercise;
21 
33 {
35  protected \ILIAS\DI\UIServices $ui;
36  protected Exercise\Assignment\AssignmentManager $ass_manager;
37  private Exercise\Assignment\ItemBuilderUI $item_builder;
38  protected Exercise\Notification\NotificationManager $notification;
39  protected Exercise\InternalGUIService $gui;
40  protected ilTabsGUI $tabs;
41  protected ilHelpGUI $help;
42  protected ?ilExAssignment $ass = null;
44  protected Exercise\GUIRequest $exercise_request;
45  protected Exercise\InternalGUIService $exercise_ui;
46  protected ?int $requested_ass_id;
47  protected int $lp_user_id;
48  protected string $requested_sort_order;
49  protected string $requested_sort_by;
50  protected int $requested_offset;
51  protected int $requested_ref_id;
52  protected int $requested_ass_id_goto;
53 
57  public function __construct($a_data, int $a_id, bool $a_call_by_reference)
58  {
59  global $DIC;
60 
61  $this->lng = $DIC->language();
62  $this->user = $DIC->user();
63  $this->ctrl = $DIC->ctrl();
64  $this->tabs = $DIC->tabs();
65  $this->help = $DIC["ilHelp"];
66  $this->locator = $DIC["ilLocator"];
67  $this->tpl = $DIC["tpl"];
68  $this->toolbar = $DIC->toolbar();
69  $lng = $DIC->language();
70 
71  $this->lng->loadLanguageModule('cert');
72 
73  $this->type = "exc";
74  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
75 
76  $lng->loadLanguageModule("exercise");
77  $lng->loadLanguageModule("exc");
78  $this->ctrl->saveParameter($this, ["ass_id", "mode", "from_overview"]);
79 
80  $this->service = $DIC->exercise()->internal();
81  $this->gui = $this->service->gui();
82  $this->exercise_request = $DIC->exercise()->internal()->gui()->request();
83  $this->exercise_ui = $DIC->exercise()->internal()->gui();
84  $this->requested_ass_id = $this->exercise_request->getAssId();
85 
86  if ($this->requested_ass_id > 0 && is_object($this->object) && ilExAssignment::lookupExerciseId(
87  $this->requested_ass_id
88  ) === $this->object->getId()) {
89  $this->ass = $this->exercise_request->getAssignment();
90  } elseif ($this->requested_ass_id > 0) {
91  throw new ilExerciseException("Assignment ID does not match Exercise.");
92  }
93  $this->lp_user_id = ($this->exercise_request->getUserId() > 0 && $this->access->checkAccess("read_learning_progress", "", $this->exercise_request->getRefId()))
94  ? $this->exercise_request->getUserId()
95  : $this->user->getId();
96  $this->requested_sort_order = $this->exercise_request->getSortOrder();
97  $this->requested_sort_by = $this->exercise_request->getSortBy();
98  $this->requested_offset = $this->exercise_request->getOffset();
99  $this->requested_ref_id = $this->exercise_request->getRefId();
100  $this->requested_ass_id_goto = $this->exercise_request->getAssIdGoto();
101  $this->ui = $this->service->gui()->ui();
102  $this->certificateDownloadValidator = new ilCertificateDownloadValidator();
103  $this->notification = $this->service->domain()->notification($this->requested_ref_id);
104 
105  if ($this->object) {
106  $this->ass_manager = $this->service->domain()->assignment()->assignments(
107  $this->object->getId(),
108  $this->user->getId()
109  );
110  $this->item_builder = $this->service->gui()->assignment()->itemBuilder(
111  $this->object,
112  $this->service->domain()->assignment()->mandatoryAssignments($this->object)
113  );
114  }
115  }
116 
121  public function executeCommand(): void
122  {
123  $ilCtrl = $this->ctrl;
124  $ilTabs = $this->tabs;
125 
126  $next_class = $this->ctrl->getNextClass($this);
127  $cmd = $this->ctrl->getCmd();
128  $this->prepareOutput();
129 
131  $exc = $this->object;
132 
133  if (!$this->getCreationMode() && isset($this->object)) {
134  $this->gui->permanentLink()->setPermanentLink();
135  }
136 
137  //echo "-".$next_class."-".$cmd."-"; exit;
138  switch ($next_class) {
139  case "ilinfoscreengui":
140  $ilTabs->activateTab("info");
141  $this->infoScreen(); // forwards command
142  break;
143 
144  case 'ilpermissiongui':
145  $ilTabs->activateTab("permissions");
146  $perm_gui = new ilPermissionGUI($this);
147  $this->ctrl->forwardCommand($perm_gui);
148  break;
149 
150  case "illearningprogressgui":
151  $ilTabs->activateTab("learning_progress");
152  $new_gui = new ilLearningProgressGUI(
154  $this->object->getRefId(),
156  );
157  $this->ctrl->forwardCommand($new_gui);
158  $this->tabs_gui->setTabActive('learning_progress');
159  break;
160 
161  case 'ilobjectcopygui':
162  $ilCtrl->saveParameter($this, 'new_type');
163  $ilCtrl->setReturnByClass(get_class($this), 'create');
164 
165  $cp = new ilObjectCopyGUI($this);
166  $cp->setType('exc');
167  $this->ctrl->forwardCommand($cp);
168  break;
169 
170  case "ilexportgui":
171  $ilTabs->activateTab("export");
172  $exp_gui = new ilExportGUI($this);
173  $exp_gui->addFormat("xml");
174  $this->ctrl->forwardCommand($exp_gui);
175  break;
176 
177  case "ilcommonactiondispatchergui":
179  $this->ctrl->forwardCommand($gui);
180  break;
181 
182  case "ilcertificategui":
183  $this->checkPermission("write");
184  $this->setSettingsSubTabs();
185  $this->tabs_gui->activateTab("settings");
186  $this->tabs_gui->activateSubTab("certificate");
187 
188  $guiFactory = new ilCertificateGUIFactory();
189  $output_gui = $guiFactory->create($this->object);
190 
191  $this->ctrl->forwardCommand($output_gui);
192  break;
193 
194  case "ilexassignmenteditorgui":
195  $this->checkPermission("write");
196  $ilTabs->activateTab("content");
197  $this->addContentSubTabs("list_assignments");
198  $ass_gui = new ilExAssignmentEditorGUI(
199  $this->object->getId(),
200  $this->object->isCompletionBySubmissionEnabled(),
201  $this->ass
202  );
203  $this->ctrl->forwardCommand($ass_gui);
204  break;
205 
206  case "ilexercisemanagementgui":
207  // rbac or position access
208  if ($GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess(
209  'edit_submissions_grades',
210  'edit_submissions_grades',
211  $this->object->getRefId()
212  )) {
213  $ilTabs->activateTab("grades");
214  $mgmt_gui = new ilExerciseManagementGUI($this->getService(), $this->ass);
215  $this->ctrl->forwardCommand($mgmt_gui);
216  } else {
217  $this->checkPermission("edit_submissions_grades"); // throw error by standard procedure
218  }
219  break;
220 
221  case "ilexccriteriacataloguegui":
222  $this->checkPermission("write");
223  $ilTabs->activateTab("settings");
224  $this->setSettingsSubTabs();
225  $ilTabs->activateSubTab("crit");
226  $crit_gui = new ilExcCriteriaCatalogueGUI($exc);
227  $this->ctrl->forwardCommand($crit_gui);
228  break;
229 
230  /* seems to be unused, at least initSumbission is not known here...
231  case "ilportfolioexercisegui":
232  $this->ctrl->saveParameter($this, array("part_id"));
233  $gui = new ilPortfolioExerciseGUI($this->object, $this->initSubmission());
234  $ilCtrl->forwardCommand($gui);
235  break; */
236 
237  case "ilexcrandomassignmentgui":
238  $gui = $this->exercise_ui->assignment()->getRandomAssignmentGUI();
239  $this->ctrl->forwardCommand($gui);
240  break;
241 
242  case 'ilobjectmetadatagui':
243  $this->checkPermissionBool("write", '', '', $this->object->getRefId());
244  $this->tabs_gui->setTabActive('meta_data');
245  $md_gui = new ilObjectMetaDataGUI($this->object);
246  $this->ctrl->forwardCommand($md_gui);
247  break;
248 
249  case strtolower(ilAssignmentPresentationGUI::class):
250  $this->checkPermission("read");
251  $gui = $this->exercise_ui->assignment()->assignmentPresentationGUI($this->object);
252  $this->ctrl->forwardCommand($gui);
253  break;
254 
255  default:
256  if (!$cmd) {
257  $cmd = "infoScreen";
258  }
259 
260  $cmd .= "Object";
261  $this->$cmd();
262 
263  break;
264  }
265 
266  $this->addHeaderAction();
267  }
268 
269  public function viewObject(): void
270  {
271  $this->infoScreenObject();
272  }
273 
274  protected function afterSave(ilObject $a_new_object): void
275  {
276  $ilCtrl = $this->ctrl;
277 
278  $a_new_object->saveData();
279 
280  $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_added"), true);
281 
282  $ilCtrl->setParameterByClass("ilExAssignmentEditorGUI", "ref_id", $a_new_object->getRefId());
283  $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "addAssignment");
284  }
285 
286  protected function listAssignmentsObject(): void
287  {
288  $ilCtrl = $this->ctrl;
289 
290  $this->checkPermissionBool("write");
291 
292  // #16587
293  $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "listAssignments");
294  }
295 
296  protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
297  {
298  $obj_service = $this->getObjectService();
299  $service = $this->getService();
301  $exc = $this->object;
302 
303  $random_manager = $service->domain()->assignment()->randomAssignments($exc);
304 
305  $a_form->setTitle($this->lng->txt("exc_edit_exercise"));
306 
307  $pres = new ilFormSectionHeaderGUI();
308  $pres->setTitle($this->lng->txt('obj_presentation'));
309  $a_form->addItem($pres);
310 
311  // tile image
312  $a_form = $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
313 
314  $section = new ilFormSectionHeaderGUI();
315  $section->setTitle($this->lng->txt('exc_passing_exc'));
316  $a_form->addItem($section);
317 
318  // pass mode
319  $radg = new ilRadioGroupInputGUI($this->lng->txt("exc_pass_mode"), "pass_mode");
320 
321  $op1 = new ilRadioOption(
322  $this->lng->txt("exc_pass_all"),
324  $this->lng->txt("exc_pass_all_info")
325  );
326  $radg->addOption($op1);
327  $op2 = new ilRadioOption(
328  $this->lng->txt("exc_pass_minimum_nr"),
330  $this->lng->txt("exc_pass_minimum_nr_info")
331  );
332  $radg->addOption($op2);
333  $op3 = new ilRadioOption(
334  $this->lng->txt("exc_random_selection"),
336  $this->lng->txt("exc_random_selection_info")
337  );
338  if (!$random_manager->canBeActivated() && $this->object->getPassMode() != ilObjExercise::PASS_MODE_RANDOM) {
339  $op3->setDisabled(true);
340  $op3->setInfo(
341  $this->lng->txt("exc_random_selection_not_changeable_info") . " " .
342  implode(" ", $random_manager->getDeniedActivationReasons())
343  );
344  }
345  if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM && !$random_manager->canBeDeactivated()) {
346  $radg->setDisabled(true);
347  $radg->setInfo(
348  $this->lng->txt("exc_pass_mode_not_changeable_info") . " " .
349  implode(" ", $random_manager->getDeniedDeactivationReasons())
350  );
351  }
352  // minimum number of assignments to pass
353  $rn = new ilNumberInputGUI($this->lng->txt("exc_nr_random_mand"), "nr_random_mand");
354  $rn->setSize(4);
355  $rn->setMaxLength(4);
356  $rn->setRequired(true);
357  $rn->setMinValue(1, false);
358  $cnt = ilExAssignment::count($this->object->getId());
359  $rn->setMaxValue($cnt, true);
360  $op3->addSubItem($rn);
361 
362  $radg->addOption($op3);
363 
364  // minimum number of assignments to pass
365  $ni = new ilNumberInputGUI($this->lng->txt("exc_min_nr"), "pass_nr");
366  $ni->setSize(4);
367  $ni->setMaxLength(4);
368  $ni->setRequired(true);
369  $mand = ilExAssignment::countMandatory($this->object->getId());
370  $min = max($mand, 1);
371  $ni->setMinValue($min, true);
372  $ni->setInfo($this->lng->txt("exc_min_nr_info"));
373  $op2->addSubItem($ni);
374 
375  $a_form->addItem($radg);
376 
377  // completion by submission
378  $subcompl = new ilRadioGroupInputGUI(
379  $this->lng->txt("exc_passed_status_determination"),
380  "completion_by_submission"
381  );
382  $op1 = new ilRadioOption($this->lng->txt("exc_completion_by_tutor"), 0, "");
383  $subcompl->addOption($op1);
384  $op2 = new ilRadioOption(
385  $this->lng->txt("exc_completion_by_submission"),
386  1,
387  $this->lng->txt("exc_completion_by_submission_info")
388  );
389  $subcompl->addOption($op2);
390  $a_form->addItem($subcompl);
391 
392  /*$subcompl = new ilCheckboxInputGUI($this->lng->txt('exc_completion_by_submission'), 'completion_by_submission');
393  $subcompl->setInfo($this->lng->txt('exc_completion_by_submission_info'));
394  $subcompl->setValue(1);
395  $a_form->addItem($subcompl);*/
396 
397  $section = new ilFormSectionHeaderGUI();
398  $section->setTitle($this->lng->txt('exc_publishing'));
399  $a_form->addItem($section);
400 
401  // show submissions
402  $cb = new ilCheckboxInputGUI($this->lng->txt("exc_show_submissions"), "show_submissions");
403  $cb->setInfo($this->lng->txt("exc_show_submissions_info"));
404  $a_form->addItem($cb);
405 
406  $section = new ilFormSectionHeaderGUI();
407  $section->setTitle($this->lng->txt('exc_notification'));
408  $a_form->addItem($section);
409 
410  // submission notifications
411  $cbox = new ilCheckboxInputGUI($this->lng->txt("exc_submission_notification"), "notification");
412  $cbox->setInfo($this->lng->txt("exc_submission_notification_info"));
413  $a_form->addItem($cbox);
414 
415  // feedback settings
416 
417  $section = new ilFormSectionHeaderGUI();
418  $section->setTitle($this->lng->txt('exc_feedback'));
419  $a_form->addItem($section);
420 
421  $fdb = new ilCheckboxGroupInputGUI($this->lng->txt("exc_settings_feedback"), "tfeedback");
422  $a_form->addItem($fdb);
423 
424  $option = new ilCheckboxOption(
425  $this->lng->txt("exc_settings_feedback_mail"),
427  );
428  $option->setInfo($this->lng->txt("exc_settings_feedback_mail_info"));
429  $fdb->addOption($option);
430  $option = new ilCheckboxOption(
431  $this->lng->txt("exc_settings_feedback_file"),
433  );
434  $option->setInfo($this->lng->txt("exc_settings_feedback_file_info"));
435  $fdb->addOption($option);
436  $option = new ilCheckboxOption(
437  $this->lng->txt("exc_settings_feedback_text"),
439  );
440  $option->setInfo($this->lng->txt("exc_settings_feedback_text_info"));
441  $fdb->addOption($option);
442 
443  // additional features
444  $section = new ilFormSectionHeaderGUI();
445  $section->setTitle($this->lng->txt('obj_features'));
446  $a_form->addItem($section);
447 
449 
450  $position_settings = ilOrgUnitGlobalSettings::getInstance()
451  ->getObjectPositionSettingsByType($this->object->getType());
452 
453  if ($position_settings->isActive()) {
455  }
456 
458  $this->object->getId(),
459  $a_form,
460  $features
461  );
462  }
463 
464  protected function getEditFormCustomValues(array &$a_values): void
465  {
466  $ilUser = $this->user;
467 
468  $a_values["desc"] = $this->object->getLongDescription();
469  $a_values["show_submissions"] = $this->object->getShowSubmissions();
470  $a_values["pass_mode"] = $this->object->getPassMode();
471  if ($a_values["pass_mode"] == "nr") {
472  $a_values["pass_nr"] = $this->object->getPassNr();
473  }
474 
475  $a_values["nr_random_mand"] = $this->object->getNrMandatoryRandom();
476 
477  $a_values["notification"] = ilNotification::hasNotification(
479  $ilUser->getId(),
480  $this->object->getId()
481  );
482 
483  $a_values['completion_by_submission'] = (int) $this->object->isCompletionBySubmissionEnabled();
484 
485  $tfeedback = array();
486  if ($this->object->hasTutorFeedbackMail()) {
487  $tfeedback[] = ilObjExercise::TUTOR_FEEDBACK_MAIL;
488  }
489  if ($this->object->hasTutorFeedbackText()) {
490  $tfeedback[] = ilObjExercise::TUTOR_FEEDBACK_TEXT;
491  }
492  if ($this->object->hasTutorFeedbackFile()) {
493  $tfeedback[] = ilObjExercise::TUTOR_FEEDBACK_FILE;
494  }
495  $a_values['tfeedback'] = $tfeedback;
496 
497  // orgunit position setting enabled
498  $a_values['obj_orgunit_positions'] = ilOrgUnitGlobalSettings::getInstance()
499  ->isPositionAccessActiveForObject(
500  $this->object->getId()
501  );
502 
503  $a_values['cont_custom_md'] = ilContainer::_lookupContainerSetting(
504  $this->object->getId(),
506  false
507  );
508  }
509 
510  protected function updateCustom(ilPropertyFormGUI $a_form): void
511  {
512  $obj_service = $this->getObjectService();
513 
514  $ilUser = $this->user;
515  $this->object->setShowSubmissions($a_form->getInput("show_submissions"));
516  $this->object->setPassMode($a_form->getInput("pass_mode"));
517  if ($this->object->getPassMode() == "nr") {
518  $this->object->setPassNr($a_form->getInput("pass_nr"));
519  }
520  if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
521  $this->object->setNrMandatoryRandom($a_form->getInput("nr_random_mand"));
522  }
523 
524  $this->object->setCompletionBySubmission($a_form->getInput('completion_by_submission') == 1);
525 
526  $feedback = $a_form->getInput("tfeedback");
527  $this->object->setTutorFeedback(
528  is_array($feedback)
529  ? array_sum($feedback)
530  : null
531  );
532 
535  $ilUser->getId(),
536  $this->object->getId(),
537  (bool) $a_form->getInput("notification")
538  );
539 
540  // tile image
541  $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
542 
544  $this->object->getId(),
545  $a_form,
546  array(
549  )
550  );
551  }
552 
553  public function addContentSubTabs(string $a_activate): void
554  {
555  $ilTabs = $this->tabs;
556  $lng = $this->lng;
557  $ilCtrl = $this->ctrl;
558 
559  $ilTabs->addSubTab(
560  "content",
561  $lng->txt("view"),
562  $ilCtrl->getLinkTarget($this, "showOverview")
563  );
564  if ($this->checkPermissionBool("write")) {
565  $ilTabs->addSubTab(
566  "list_assignments",
567  $lng->txt("edit"),
568  $ilCtrl->getLinkTargetByClass("ilExAssignmentEditorGUI", "listAssignments")
569  );
570  }
571  $ilTabs->activateSubTab($a_activate);
572  }
573 
574  protected function getTabs(): void
575  {
576  if ($this->ctrl->getNextClass() === strtolower(ilAssignmentPresentationGUI::class)) {
577  return;
578  }
579 
580 
581  $lng = $this->lng;
582  $ilHelp = $this->help;
584  $ctrl = $this->ctrl;
585  $ilHelp->setScreenIdComponent("exc");
586 
587  if ($this->checkPermissionBool("read")) {
588  $this->tabs_gui->addTab(
589  "content",
590  $lng->txt("exc_assignments"),
591  $ctrl->getLinkTarget($this, "showOverview")
592  );
593  }
594 
595  if ($this->checkPermissionBool("visible") || $this->checkPermissionBool("read")) {
596  $this->tabs_gui->addTab(
597  "info",
598  $lng->txt("info_short"),
599  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
600  );
601  }
602 
603  // edit properties
604  if ($this->checkPermissionBool("write")) {
605  /*$tabs_gui->addTab("assignments",
606  $lng->txt("exc_edit_assignments"),
607  $this->ctrl->getLinkTarget($this, 'listAssignments'));*/
608 
609  $this->tabs_gui->addTab(
610  "settings",
611  $lng->txt("settings"),
612  $this->ctrl->getLinkTarget($this, 'edit')
613  );
614  }
615  if ($this->access->checkRbacOrPositionPermissionAccess(
616  'edit_submissions_grades',
617  'edit_submissions_grades',
618  $this->object->getRefId()
619  )) {
620  $this->tabs_gui->addTab(
621  "grades",
622  $lng->txt("exc_submissions_and_grades"),
623  $this->ctrl->getLinkTargetByClass("ilexercisemanagementgui", "members")
624  );
625  }
626 
627  // learning progress
628  $ctrl->clearParametersByClass('illearningprogressgui');
629 
630  if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
631  $this->tabs_gui->addTab(
632  'learning_progress',
633  $lng->txt('learning_progress'),
634  $this->ctrl->getLinkTargetByClass(array('ilobjexercisegui', 'illearningprogressgui'), '')
635  );
636  }
637 
638  // meta data
639  if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
640  $mdgui = new ilObjectMetaDataGUI($this->object);
641  $mdtab = $mdgui->getTab();
642  if ($mdtab) {
643  $this->tabs_gui->addTarget(
644  "meta_data",
645  $mdtab,
646  "",
647  "ilobjectmetadatagui"
648  );
649  }
650  }
651 
652  // export
653  if ($this->checkPermissionBool("write")) {
654  $this->tabs_gui->addTab(
655  "export",
656  $lng->txt("export"),
657  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
658  );
659  }
660 
661  // permissions
662  if ($this->checkPermissionBool("edit_permission")) {
663  $this->tabs_gui->addTab(
664  'permissions',
665  $lng->txt("perm_settings"),
666  $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), "perm")
667  );
668  }
669  }
670 
674  public function infoScreenObject(): void
675  {
676  $this->ctrl->setCmd("showSummary");
677  $this->ctrl->setCmdClass("ilinfoscreengui");
678  $this->infoScreen();
679  }
680 
681  protected function getService(): InternalService
682  {
683  return $this->service;
684  }
685 
689  public function infoScreen(): void
690  {
691  $ilUser = $this->user;
692  $ilTabs = $this->tabs;
693  $lng = $this->lng;
694 
695  $ilTabs->activateTab("info");
696 
698  $exc = $this->object;
699 
700  if (!$this->checkPermissionBool("read")) {
701  $this->checkPermission("visible");
702  }
703 
704  $info = new ilInfoScreenGUI($this);
705 
706  $info->enablePrivateNotes();
707 
708  $info->enableNews();
709  if ($this->checkPermissionBool("write")) {
710  $info->enableNewsEditing();
711  $info->setBlockProperty("news", "settings", true);
712  }
713 
714  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'exc', $this->object->getId());
715  $record_gui->setInfoObject($info);
716  $record_gui->parse();
717 
718  // standard meta data
719  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
720 
721  // instructions
722  $info->addSection($this->lng->txt("exc_overview"));
723  $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
724  $cnt = 0;
725  $mcnt = 0;
726  foreach ($ass as $a) {
727  $cnt++;
728  if ($a["mandatory"]) {
729  $mcnt++;
730  }
731  }
732  $info->addProperty($lng->txt("exc_assignments"), $cnt);
733  if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_ALL) {
734  $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
735  $info->addProperty(
736  $lng->txt("exc_pass_mode"),
737  $lng->txt("exc_msg_all_mandatory_ass")
738  );
739  } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_NR) {
740  $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
741  $info->addProperty(
742  $lng->txt("exc_pass_mode"),
743  sprintf($lng->txt("exc_msg_min_number_ass"), $this->object->getPassNr())
744  );
745  } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
746  $info->addProperty($lng->txt("exc_mandatory"), $exc->getNrMandatoryRandom());
747  $info->addProperty(
748  $lng->txt("exc_pass_mode"),
749  $lng->txt("exc_msg_all_mandatory_ass")
750  );
751  }
752 
753  // feedback from tutor
754  if ($this->checkPermissionBool("read")) {
755  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
756  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
757  //$status = ilExerciseMembers::_lookupStatus($this->object->getId(), $ilUser->getId());
758  $st = $this->object->determinStatusOfUser($ilUser->getId());
759  $status = $st["overall_status"];
760  if ($lpcomment != "" || $mark != "" || $status != "notgraded") {
761  $info->addSection($this->lng->txt("exc_feedback_from_tutor"));
762  if ($lpcomment != "") {
763  $info->addProperty(
764  $this->lng->txt("exc_comment"),
765  $lpcomment
766  );
767  }
768  if ($mark != "") {
769  $info->addProperty(
770  $this->lng->txt("exc_mark"),
771  $mark
772  );
773  }
774 
775  //if ($status == "")
776  //{
777  // $info->addProperty($this->lng->txt("status"),
778  // $this->lng->txt("message_no_delivered_files"));
779  //}
780  //else
781  if ($status != "notgraded") {
783 
784  switch ($status) {
785  case "passed":
786  $path = $icons->getImagePathCompleted();
787  break;
788  case "failed":
789  $path = $icons->getImagePathFailed();
790  break;
791  default:
792  $path = ilUtil::getImagePath("scorm/" . $status . ".svg");
793  }
794 
795  $img = $icons->renderIcon($path, $lng->txt("exc_" . $status));
796 
797  $add = "";
798  if ($st["failed_a_mandatory"]) {
799  $add = " (" . $lng->txt("exc_msg_failed_mandatory") . ")";
800  } elseif ($status == "failed") {
801  $add = " (" . $lng->txt("exc_msg_missed_minimum_number") . ")";
802  }
803  $info->addProperty(
804  $this->lng->txt("status"),
805  $img . " " . $this->lng->txt("exc_" . $status) . $add
806  );
807  }
808  }
809  }
810 
811  // forward the command
812  $this->ctrl->forwardCommand($info);
813  }
814 
815  public function editObject(): void
816  {
817  $this->setSettingsSubTabs();
818  $this->tabs_gui->activateSubTab("edit");
819  parent::editObject();
820  }
821 
822  protected function setSettingsSubTabs(): void
823  {
824  $this->tabs_gui->addSubTab(
825  "edit",
826  $this->lng->txt("general_settings"),
827  $this->ctrl->getLinkTarget($this, "edit")
828  );
829 
830  $this->tabs_gui->addSubTab(
831  "crit",
832  $this->lng->txt("exc_criteria_catalogues"),
833  $this->ctrl->getLinkTargetByClass("ilexccriteriacataloguegui", "")
834  );
835 
836  $validator = new ilCertificateActiveValidator();
837  if ($validator->validate()) {
838  $this->tabs_gui->addSubTab(
839  "certificate",
840  $this->lng->txt("certificate"),
841  $this->ctrl->getLinkTarget($this, "certificate")
842  );
843  }
844  }
845 
846  public static function _goto(
847  string $a_target,
848  string $a_raw
849  ): void {
850  global $DIC;
851 
852  $DIC->exercise()->internal()->gui()->permanentLink()->goto($a_target, $a_raw);
853  }
854 
858  protected function addLocatorItems(): void
859  {
860  $ilLocator = $this->locator;
861 
862  if (is_object($this->object)) {
863  // #17955
864  $ilLocator->addItem(
865  $this->object->getTitle(),
866  $this->ctrl->getLinkTarget($this, "showOverview"),
867  "",
869  );
870  }
871  }
872 
873 
877 
886  public function showOverviewObject(): void
887  {
888  $this->ctrl->setParameterByClass(self::class, "from_overview", "1");
889  $user = $this->service->domain()->user();
890  $toolbar = $this->service->gui()->toolbar();
891  $tabs = $this->service->gui()->tabs();
892 
893  $this->checkPermission("read");
894 
895  $tabs->activateTab("content");
896  $this->addContentSubTabs("list");
897 
898  if ($this->handleRandomAssignmentEntryPage()) {
899  return;
900  }
901 
902  //$tpl->addJavaScript("./Modules/Exercise/js/ilExcPresentation.js");
903 
904  $exc = $this->object;
905 
907  $user->getId(),
908  $exc->getId(),
909  $exc->getRefId(),
910  'exc'
911  );
912 
913  if ($this->certificateDownloadValidator->isCertificateDownloadable(
914  $user->getId(),
915  $exc->getId()
916  )) {
918  $this->lng->txt("certificate"),
919  $this->ctrl->getLinkTarget($this, "outCertificate")
920  );
921  }
922 
923  $ass_gui = new ilExAssignmentGUI($exc, $this->getService());
924 
925  $f = $this->ui->factory();
926  $r = $this->ui->renderer();
927 
928  $ass_data = ilExAssignment::getInstancesByExercise($exc->getId());
929  $random_manager = $this->service->domain()->assignment()->randomAssignments($exc);
930  $am = $this->ass_manager;
931  if ($this->getCurrentMode() === $am::TYPE_ALL) {
932  $list_modes = [$am::TYPE_ONGOING,$am::TYPE_FUTURE,$am::TYPE_PAST];
933  } else {
934  $list_modes = [$this->getCurrentMode()];
935  }
936  foreach ($list_modes as $lm) {
937  $items[$lm] = [];
938  foreach ($this->ass_manager->getList($lm) as $ass) {
939  if (!$random_manager->isAssignmentVisible($ass->getId(), $this->user->getId())) {
940  continue;
941  }
942  $items[$lm][] = $this->item_builder->getItem($ass, $user->getId());
943  }
944  }
945 
946  // new
947  $groups = [];
948  foreach ($items as $lm => $it) {
949  if (count($it) > 0) {
950  $groups[] = $f->item()->group($this->lng->txt("exc_" . $lm), $it);
951  }
952  }
953  if (count($groups) > 0) {
954  $panel = $f->panel()->listing()->standard($this->lng->txt("exc_assignments"), $groups);
955  } else {
956  $panel = $f->panel()->standard($this->lng->txt("exc_assignments"), $f->messageBox()->info($this->lng->txt("exc_no_assignments")));
957  }
958 
959  $mode_options = [];
960  foreach ($am->getListModes() as $mode => $txt) {
961  $mode_options[$txt] = $this->getModeLink($mode);
962  }
963  $mode = $f->viewControl()->mode(
964  $mode_options,
965  $this->lng->txt("exc_mode_selection")
966  )->withActive($am->getListModeLabel($this->getCurrentMode()));
967 
968  $html = "";
969  $l = $f->legacy("<br><br>");
970  $html .= $r->render([$mode, $l, $panel]);
971 
972  $this->tpl->setContent(
973  $html
974  );
975  $this->ctrl->setParameterByClass(self::class, "from_overview", null);
976  }
977 
978  protected function getCurrentMode(): string
979  {
980  return $this->ass_manager->getValidListMode($this->exercise_request->getMode());
981  }
982 
983  protected function getModeLink(string $mode): string
984  {
985  $this->ctrl->setParameterByClass(self::class, "mode", $mode);
986  $link = $this->ctrl->getLinkTargetByClass(self::class, "showOverview");
987  $this->ctrl->setParameterByClass(self::class, "mode", null);
988  return $link;
989  }
990 
994  public function certificateObject(): void
995  {
996  $this->checkPermission("write");
997  $this->setSettingsSubTabs();
998  $this->tabs_gui->activateTab("settings");
999  $this->tabs_gui->activateSubTab("certificate");
1000 
1001  $guiFactory = new ilCertificateGUIFactory();
1002  $output_gui = $guiFactory->create($this->object);
1003 
1004  $output_gui->certificateEditor();
1005  }
1006 
1007  public function outCertificateObject(): void
1008  {
1009  global $DIC;
1010 
1011  $database = $DIC->database();
1012  $logger = $DIC->logger()->root();
1013 
1014  $ilUser = $this->user;
1015 
1016  $objectId = $this->object->getId();
1017 
1018  if (!$this->certificateDownloadValidator->isCertificateDownloadable($ilUser->getId(), $objectId)) {
1019  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
1020  $this->ctrl->redirect($this);
1021  }
1022 
1023  $ilUserCertificateRepository = new ilUserCertificateRepository($database, $logger);
1024  $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository);
1025 
1026  $pdfAction = new ilCertificatePdfAction(
1027  $pdfGenerator,
1029  $this->lng->txt('error_creating_certificate_pdf')
1030  );
1031 
1032  $pdfAction->downloadPdf($ilUser->getId(), $objectId);
1033  }
1034 
1038  public function startAssignmentObject(): void
1039  {
1040  $ctrl = $this->ctrl;
1041  $user = $this->user;
1042 
1043  if ($this->ass !== null) {
1044  $state = ilExcAssMemberState::getInstanceByIds($this->ass->getId(), $user->getId());
1045  if (!$state->getCommonDeadline() && $state->getRelativeDeadline()) {
1046  $idl = $state->getIndividualDeadlineObject();
1047  $idl->setStartingTimestamp(time());
1048  $idl->save();
1049  }
1050  }
1051 
1052  $ctrl->setParameterByClass(ilAssignmentPresentationGUI::class, "ass_id", $this->ass->getId());
1053  $ctrl->redirectByClass(ilAssignmentPresentationGUI::class, "");
1054  }
1055 
1059  public function requestDeadlineObject(): void
1060  {
1061  $ctrl = $this->ctrl;
1062  $user = $this->user;
1063 
1064  if ($this->ass !== null) {
1065  $state = ilExcAssMemberState::getInstanceByIds($this->ass->getId(), $user->getId());
1066  if ($state->needsIndividualDeadline() && !$state->hasRequestedIndividualDeadline()) {
1067  $idl = $state->getIndividualDeadlineObject();
1068  $idl->setRequested(true);
1069  $idl->save();
1070  $this->notification->sendDeadlineRequestNotification($this->ass->getId());
1072  $exc = $this->object;
1073  $exc->members_obj->assignMembers([$user->getId()]);
1074  }
1075  }
1076 
1077  $ctrl->setParameterByClass(ilAssignmentPresentationGUI::class, "ass_id", $this->ass->getId());
1078  $ctrl->redirectByClass(ilAssignmentPresentationGUI::class, "");
1079  }
1080 
1084  protected function handleRandomAssignmentEntryPage(): bool
1085  {
1087  $exc = $this->object;
1088 
1089  $service = $this->getService();
1090  $random_manager = $service->domain()->assignment()->randomAssignments($exc);
1091  if ($random_manager->needsStart()) {
1092  $gui = $this->exercise_ui->assignment()->getRandomAssignmentGUI();
1093  $gui->renderStartPage();
1094  return true;
1095  }
1096 
1097  return false;
1098  }
1099 }
Class ilExAssignmentEditorGUI.
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...
Class ilExcCriteriaCatalogueGUI.
Exercise Assignment ItemBuilderUI $item_builder
static _lookupComment(int $a_usr_id, int $a_obj_id)
Class ilInfoScreenGUI.
Exercise assignment.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
getTabs()
overwrite in derived GUI class of your object type
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...
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...
setDisabled(bool $a_disabled)
GUI class for the workflow of copying objects.
addContentSubTabs(string $a_activate)
static count(int $a_ex_id)
prepareOutput(bool $show_sub_objects=true)
setInfo(string $a_info)
Exercise Notification NotificationManager $notification
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Help GUI class.
static countMandatory(int $a_ex_id)
updateCustom(ilPropertyFormGUI $a_form)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
Exercise internal service.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
loadLanguageModule(string $a_module)
Load language module.
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
getEditFormCustomValues(array &$a_values)
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
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-...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:32
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
Exercise Assignment AssignmentManager $ass_manager
global $DIC
Definition: feed.php:28
GUI class for exercise assignments.
Export User Interface Class.
ilLanguage $lng
static getAssignmentDataOfExercise(int $a_exc_id)
static _goto(string $a_target, string $a_raw)
This class represents a property in a property form.
__construct(VocabulariesInterface $vocabularies)
addButton(string $a_txt, string $a_cmd, string $a_target="", ?int $a_acc_key=null, string $a_additional_attrs='', string $a_id="", string $a_class='submit')
Exercise GUIRequest $exercise_request
$GLOBALS["DIC"]
Definition: wac.php:31
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.
ILIAS DI UIServices $ui
Class ilObjectGUI Basic methods of all Output classes.
startAssignmentObject()
Start assignment with relative deadline.
Validates if an active certificate is stored in the database and can be downloaded by the user...
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
ilToolbarGUI $toolbar
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
clearParametersByClass(string $a_class)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
$txt
Definition: error.php:14
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilExerciseManagementGUI: ilFileSystemGUI, ilRepositorySearchGUI ilExerciseManagementGUI: ilExSubmiss...
static getInstancesByExercise(int $a_exc_id)
afterSave(ilObject $a_new_object)
static _lookupMark(int $a_usr_id, int $a_obj_id)
Just a wrapper class to create Unit Test for other classes.
activateTab(string $a_id)
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
ilCertificateDownloadValidator $certificateDownloadValidator
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
__construct($a_data, int $a_id, bool $a_call_by_reference)
getLongDescription()
get object long description (stored in object_description)
setInfoObject(ilInfoScreenGUI $info)
get info sections
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Exercise InternalGUIService $exercise_ui
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
InternalService $service
Exercise InternalGUIService $gui
addHeaderAction()
Add header action menu.
ilLocatorGUI $locator
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
static lookupExerciseId(int $a_ass_id)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
addLocatorItems()
Add locator item.
$r
downloadPdf(int $userId, int $objectId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...