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