ILIAS  release_8 Revision v8.24
class.ilObjExerciseGUI.php
Go to the documentation of this file.
1<?php
2
21
33{
35 protected ilTabsGUI $tabs;
36 protected ilHelpGUI $help;
37 protected ?ilExAssignment $ass = null;
41 protected ?int $requested_ass_id;
42 protected int $lp_user_id;
43 protected string $requested_sort_order;
44 protected string $requested_sort_by;
45 protected int $requested_offset;
46 protected int $requested_ref_id;
48
52 public function __construct($a_data, int $a_id, bool $a_call_by_reference)
53 {
54 global $DIC;
55
56 $this->lng = $DIC->language();
57 $this->user = $DIC->user();
58 $this->ctrl = $DIC->ctrl();
59 $this->tabs = $DIC->tabs();
60 $this->help = $DIC["ilHelp"];
61 $this->locator = $DIC["ilLocator"];
62 $this->tpl = $DIC["tpl"];
63 $this->toolbar = $DIC->toolbar();
64 $lng = $DIC->language();
65
66 $this->lng->loadLanguageModule('cert');
67
68 $this->type = "exc";
69 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
70
71 $lng->loadLanguageModule("exercise");
73 $this->ctrl->saveParameter($this, "ass_id");
74
75 $this->service = $DIC->exercise()->internal();
76 $this->exercise_request = $DIC->exercise()->internal()->gui()->request();
77 $this->exercise_ui = $DIC->exercise()->internal()->gui();
78 $this->requested_ass_id = $this->exercise_request->getAssId();
79
80 if ($this->requested_ass_id > 0 && is_object($this->object) && ilExAssignment::lookupExerciseId(
81 $this->requested_ass_id
82 ) === $this->object->getId()) {
83 $this->ass = $this->exercise_request->getAssignment();
84 } elseif ($this->requested_ass_id > 0) {
85 throw new ilExerciseException("Assignment ID does not match Exercise.");
86 }
87
88 $this->lp_user_id = ($this->exercise_request->getUserId() > 0)
89 ?: $this->user->getId();
90 $this->requested_sort_order = $this->exercise_request->getSortOrder();
91 $this->requested_sort_by = $this->exercise_request->getSortBy();
92 $this->requested_offset = $this->exercise_request->getOffset();
93 $this->requested_ref_id = $this->exercise_request->getRefId();
94 $this->requested_ass_id_goto = $this->exercise_request->getAssIdGoto();
95
96 $this->certificateDownloadValidator = new ilCertificateDownloadValidator();
97 }
98
103 public function executeCommand(): void
104 {
105 $ilCtrl = $this->ctrl;
106 $ilTabs = $this->tabs;
107
108 $next_class = $this->ctrl->getNextClass($this);
109 $cmd = $this->ctrl->getCmd();
110 $this->prepareOutput();
111
113 $exc = $this->object;
114
115 if (!$this->getCreationMode() && isset($this->object)) {
116 $this->tpl->setPermanentLink("exc", $this->object->getRefId());
117 }
118
119 //echo "-".$next_class."-".$cmd."-"; exit;
120 switch ($next_class) {
121 case "ilinfoscreengui":
122 $ilTabs->activateTab("info");
123 $this->infoScreen(); // forwards command
124 break;
125
126 case 'ilpermissiongui':
127 $ilTabs->activateTab("permissions");
128 $perm_gui = new ilPermissionGUI($this);
129 $this->ctrl->forwardCommand($perm_gui);
130 break;
131
132 case "illearningprogressgui":
133 $ilTabs->activateTab("learning_progress");
134 $new_gui = new ilLearningProgressGUI(
136 $this->object->getRefId(),
137 $this->lp_user_id
138 );
139 $this->ctrl->forwardCommand($new_gui);
140 $this->tabs_gui->setTabActive('learning_progress');
141 break;
142
143 case 'ilobjectcopygui':
144 $ilCtrl->saveParameter($this, 'new_type');
145 $ilCtrl->setReturnByClass(get_class($this), 'create');
146
147 $cp = new ilObjectCopyGUI($this);
148 $cp->setType('exc');
149 $this->ctrl->forwardCommand($cp);
150 break;
151
152 case "ilexportgui":
153 $ilTabs->activateTab("export");
154 $exp_gui = new ilExportGUI($this);
155 $exp_gui->addFormat("xml");
156 $this->ctrl->forwardCommand($exp_gui);
157 break;
158
159 case "ilcommonactiondispatchergui":
161 $this->ctrl->forwardCommand($gui);
162 break;
163
164 case "ilcertificategui":
165 $this->checkPermission("write");
166 $this->setSettingsSubTabs();
167 $this->tabs_gui->activateTab("settings");
168 $this->tabs_gui->activateSubTab("certificate");
169
170 $guiFactory = new ilCertificateGUIFactory();
171 $output_gui = $guiFactory->create($this->object);
172
173 $this->ctrl->forwardCommand($output_gui);
174 break;
175
176 case "ilexassignmenteditorgui":
177 $this->checkPermission("write");
178 $ilTabs->activateTab("content");
179 $this->addContentSubTabs("list_assignments");
180 $ass_gui = new ilExAssignmentEditorGUI(
181 $this->object->getId(),
182 $this->object->isCompletionBySubmissionEnabled(),
183 $this->ass
184 );
185 $this->ctrl->forwardCommand($ass_gui);
186 break;
187
188 case "ilexsubmissiongui":
189 $this->checkPermission("read");
190 $random_manager = $this->service->domain()->assignment()->randomAssignments($exc);
191 if (!$random_manager->isAssignmentVisible($this->requested_ass_id, $this->user->getId())) {
192 return;
193 }
194 $ilTabs->activateTab("content");
195 $this->addContentSubTabs("content");
196 $this->ctrl->setReturn($this, "showOverview");
197 $sub_gui = $this->exercise_ui->getSubmissionGUI();
198 $this->ctrl->forwardCommand($sub_gui);
199 break;
200
201 case "ilexercisemanagementgui":
202 // rbac or position access
203 if ($GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess(
204 'edit_submissions_grades',
205 'edit_submissions_grades',
206 $this->object->getRefId()
207 )) {
208 $ilTabs->activateTab("grades");
209 $mgmt_gui = new ilExerciseManagementGUI($this->getService(), $this->ass);
210 $this->ctrl->forwardCommand($mgmt_gui);
211 } else {
212 $this->checkPermission("edit_submissions_grades"); // throw error by standard procedure
213 }
214 break;
215
216 case "ilexccriteriacataloguegui":
217 $this->checkPermission("write");
218 $ilTabs->activateTab("settings");
219 $this->setSettingsSubTabs();
220 $ilTabs->activateSubTab("crit");
221 $crit_gui = new ilExcCriteriaCatalogueGUI($exc);
222 $this->ctrl->forwardCommand($crit_gui);
223 break;
224
225 /* seems to be unused, at least initSumbission is not known here...
226 case "ilportfolioexercisegui":
227 $this->ctrl->saveParameter($this, array("part_id"));
228 $gui = new ilPortfolioExerciseGUI($this->object, $this->initSubmission());
229 $ilCtrl->forwardCommand($gui);
230 break; */
231
232 case "ilexcrandomassignmentgui":
233 $gui = $this->exercise_ui->getRandomAssignmentGUI();
234 $this->ctrl->forwardCommand($gui);
235 break;
236
237 case 'ilobjectmetadatagui':
238 $this->checkPermissionBool("write", '', '', $this->object->getRefId());
239 $this->tabs_gui->setTabActive('meta_data');
240 $md_gui = new ilObjectMetaDataGUI($this->object);
241 $this->ctrl->forwardCommand($md_gui);
242 break;
243
244 default:
245 if (!$cmd) {
246 $cmd = "infoScreen";
247 }
248
249 $cmd .= "Object";
250 $this->$cmd();
251
252 break;
253 }
254
255 $this->addHeaderAction();
256 }
257
258 public function viewObject(): void
259 {
260 $this->infoScreenObject();
261 }
262
263 protected function afterSave(ilObject $a_new_object): void
264 {
265 $ilCtrl = $this->ctrl;
266
267 $a_new_object->saveData();
268
269 $this->tpl->setOnScreenMessage('success', $this->lng->txt("exc_added"), true);
270
271 $ilCtrl->setParameterByClass("ilExAssignmentEditorGUI", "ref_id", $a_new_object->getRefId());
272 $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "addAssignment");
273 }
274
275 protected function listAssignmentsObject(): void
276 {
277 $ilCtrl = $this->ctrl;
278
279 $this->checkPermissionBool("write");
280
281 // #16587
282 $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "listAssignments");
283 }
284
285 protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
286 {
287 $obj_service = $this->getObjectService();
288 $service = $this->getService();
290 $exc = $this->object;
291
292 $random_manager = $service->domain()->assignment()->randomAssignments($exc);
293
294 $a_form->setTitle($this->lng->txt("exc_edit_exercise"));
295
296 $pres = new ilFormSectionHeaderGUI();
297 $pres->setTitle($this->lng->txt('obj_presentation'));
298 $a_form->addItem($pres);
299
300 // tile image
301 $a_form = $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
302
303 $section = new ilFormSectionHeaderGUI();
304 $section->setTitle($this->lng->txt('exc_passing_exc'));
305 $a_form->addItem($section);
306
307 // pass mode
308 $radg = new ilRadioGroupInputGUI($this->lng->txt("exc_pass_mode"), "pass_mode");
309
310 $op1 = new ilRadioOption(
311 $this->lng->txt("exc_pass_all"),
313 $this->lng->txt("exc_pass_all_info")
314 );
315 $radg->addOption($op1);
316 $op2 = new ilRadioOption(
317 $this->lng->txt("exc_pass_minimum_nr"),
319 $this->lng->txt("exc_pass_minimum_nr_info")
320 );
321 $radg->addOption($op2);
322 $op3 = new ilRadioOption(
323 $this->lng->txt("exc_random_selection"),
325 $this->lng->txt("exc_random_selection_info")
326 );
327 if (!$random_manager->canBeActivated() && $this->object->getPassMode() != ilObjExercise::PASS_MODE_RANDOM) {
328 $op3->setDisabled(true);
329 $op3->setInfo(
330 $this->lng->txt("exc_random_selection_not_changeable_info") . " " .
331 implode(" ", $random_manager->getDeniedActivationReasons())
332 );
333 }
334 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM && !$random_manager->canBeDeactivated()) {
335 $radg->setDisabled(true);
336 $radg->setInfo(
337 $this->lng->txt("exc_pass_mode_not_changeable_info") . " " .
338 implode(" ", $random_manager->getDeniedDeactivationReasons())
339 );
340 }
341 // minimum number of assignments to pass
342 $rn = new ilNumberInputGUI($this->lng->txt("exc_nr_random_mand"), "nr_random_mand");
343 $rn->setSize(4);
344 $rn->setMaxLength(4);
345 $rn->setRequired(true);
346 $rn->setMinValue(1, false);
347 $cnt = ilExAssignment::count($this->object->getId());
348 $rn->setMaxValue($cnt, true);
349 $op3->addSubItem($rn);
350
351 $radg->addOption($op3);
352
353 // minimum number of assignments to pass
354 $ni = new ilNumberInputGUI($this->lng->txt("exc_min_nr"), "pass_nr");
355 $ni->setSize(4);
356 $ni->setMaxLength(4);
357 $ni->setRequired(true);
358 $mand = ilExAssignment::countMandatory($this->object->getId());
359 $min = max($mand, 1);
360 $ni->setMinValue($min, true);
361 $ni->setInfo($this->lng->txt("exc_min_nr_info"));
362 $op2->addSubItem($ni);
363
364 $a_form->addItem($radg);
365
366 // completion by submission
367 $subcompl = new ilRadioGroupInputGUI(
368 $this->lng->txt("exc_passed_status_determination"),
369 "completion_by_submission"
370 );
371 $op1 = new ilRadioOption($this->lng->txt("exc_completion_by_tutor"), 0, "");
372 $subcompl->addOption($op1);
373 $op2 = new ilRadioOption(
374 $this->lng->txt("exc_completion_by_submission"),
375 1,
376 $this->lng->txt("exc_completion_by_submission_info")
377 );
378 $subcompl->addOption($op2);
379 $a_form->addItem($subcompl);
380
381 /*$subcompl = new ilCheckboxInputGUI($this->lng->txt('exc_completion_by_submission'), 'completion_by_submission');
382 $subcompl->setInfo($this->lng->txt('exc_completion_by_submission_info'));
383 $subcompl->setValue(1);
384 $a_form->addItem($subcompl);*/
385
386 $section = new ilFormSectionHeaderGUI();
387 $section->setTitle($this->lng->txt('exc_publishing'));
388 $a_form->addItem($section);
389
390 // show submissions
391 $cb = new ilCheckboxInputGUI($this->lng->txt("exc_show_submissions"), "show_submissions");
392 $cb->setInfo($this->lng->txt("exc_show_submissions_info"));
393 $a_form->addItem($cb);
394
395 $section = new ilFormSectionHeaderGUI();
396 $section->setTitle($this->lng->txt('exc_notification'));
397 $a_form->addItem($section);
398
399 // submission notifications
400 $cbox = new ilCheckboxInputGUI($this->lng->txt("exc_submission_notification"), "notification");
401 $cbox->setInfo($this->lng->txt("exc_submission_notification_info"));
402 $a_form->addItem($cbox);
403
404 // feedback settings
405
406 $section = new ilFormSectionHeaderGUI();
407 $section->setTitle($this->lng->txt('exc_feedback'));
408 $a_form->addItem($section);
409
410 $fdb = new ilCheckboxGroupInputGUI($this->lng->txt("exc_settings_feedback"), "tfeedback");
411 $a_form->addItem($fdb);
412
413 $option = new ilCheckboxOption(
414 $this->lng->txt("exc_settings_feedback_mail"),
416 );
417 $option->setInfo($this->lng->txt("exc_settings_feedback_mail_info"));
418 $fdb->addOption($option);
419 $option = new ilCheckboxOption(
420 $this->lng->txt("exc_settings_feedback_file"),
422 );
423 $option->setInfo($this->lng->txt("exc_settings_feedback_file_info"));
424 $fdb->addOption($option);
425 $option = new ilCheckboxOption(
426 $this->lng->txt("exc_settings_feedback_text"),
428 );
429 $option->setInfo($this->lng->txt("exc_settings_feedback_text_info"));
430 $fdb->addOption($option);
431
432 // additional features
433 $section = new ilFormSectionHeaderGUI();
434 $section->setTitle($this->lng->txt('obj_features'));
435 $a_form->addItem($section);
436
438
439 $position_settings = ilOrgUnitGlobalSettings::getInstance()
440 ->getObjectPositionSettingsByType($this->object->getType());
441
442 if ($position_settings->isActive()) {
444 }
445
447 $this->object->getId(),
448 $a_form,
449 $features
450 );
451 }
452
453 protected function getEditFormCustomValues(array &$a_values): void
454 {
456
457 $a_values["desc"] = $this->object->getLongDescription();
458 $a_values["show_submissions"] = $this->object->getShowSubmissions();
459 $a_values["pass_mode"] = $this->object->getPassMode();
460 if ($a_values["pass_mode"] == "nr") {
461 $a_values["pass_nr"] = $this->object->getPassNr();
462 }
463
464 $a_values["nr_random_mand"] = $this->object->getNrMandatoryRandom();
465
466 $a_values["notification"] = ilNotification::hasNotification(
468 $ilUser->getId(),
469 $this->object->getId()
470 );
471
472 $a_values['completion_by_submission'] = (int) $this->object->isCompletionBySubmissionEnabled();
473
474 $tfeedback = array();
475 if ($this->object->hasTutorFeedbackMail()) {
477 }
478 if ($this->object->hasTutorFeedbackText()) {
480 }
481 if ($this->object->hasTutorFeedbackFile()) {
483 }
484 $a_values['tfeedback'] = $tfeedback;
485
486 // orgunit position setting enabled
487 $a_values['obj_orgunit_positions'] = ilOrgUnitGlobalSettings::getInstance()
488 ->isPositionAccessActiveForObject(
489 $this->object->getId()
490 );
491
492 $a_values['cont_custom_md'] = ilContainer::_lookupContainerSetting(
493 $this->object->getId(),
495 false
496 );
497 }
498
499 protected function updateCustom(ilPropertyFormGUI $a_form): void
500 {
501 $obj_service = $this->getObjectService();
502
504 $this->object->setShowSubmissions($a_form->getInput("show_submissions"));
505 $this->object->setPassMode($a_form->getInput("pass_mode"));
506 if ($this->object->getPassMode() == "nr") {
507 $this->object->setPassNr($a_form->getInput("pass_nr"));
508 }
509 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
510 $this->object->setNrMandatoryRandom($a_form->getInput("nr_random_mand"));
511 }
512
513 $this->object->setCompletionBySubmission($a_form->getInput('completion_by_submission') == 1);
514
515 $feedback = $a_form->getInput("tfeedback");
516 $this->object->setTutorFeedback(
517 is_array($feedback)
518 ? array_sum($feedback)
519 : null
520 );
521
524 $ilUser->getId(),
525 $this->object->getId(),
526 (bool) $a_form->getInput("notification")
527 );
528
529 // tile image
530 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
531
533 $this->object->getId(),
534 $a_form,
535 array(
538 )
539 );
540 }
541
542 public function addContentSubTabs(string $a_activate): void
543 {
544 $ilTabs = $this->tabs;
546 $ilCtrl = $this->ctrl;
547
548 $ilTabs->addSubTab(
549 "content",
550 $lng->txt("view"),
551 $ilCtrl->getLinkTarget($this, "showOverview")
552 );
553 if ($this->checkPermissionBool("write")) {
554 $ilTabs->addSubTab(
555 "list_assignments",
556 $lng->txt("edit"),
557 $ilCtrl->getLinkTargetByClass("ilExAssignmentEditorGUI", "listAssignments")
558 );
559 }
560 $ilTabs->activateSubTab($a_activate);
561 }
562
563 protected function getTabs(): void
564 {
566 $ilHelp = $this->help;
569 $ilHelp->setScreenIdComponent("exc");
570
571 if ($this->checkPermissionBool("read")) {
572 $this->tabs_gui->addTab(
573 "content",
574 $lng->txt("exc_assignments"),
575 $ctrl->getLinkTarget($this, "showOverview")
576 );
577 }
578
579 if ($this->checkPermissionBool("visible") || $this->checkPermissionBool("read")) {
580 $this->tabs_gui->addTab(
581 "info",
582 $lng->txt("info_short"),
583 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
584 );
585 }
586
587 // edit properties
588 if ($this->checkPermissionBool("write")) {
589 /*$tabs_gui->addTab("assignments",
590 $lng->txt("exc_edit_assignments"),
591 $this->ctrl->getLinkTarget($this, 'listAssignments'));*/
592
593 $this->tabs_gui->addTab(
594 "settings",
595 $lng->txt("settings"),
596 $this->ctrl->getLinkTarget($this, 'edit')
597 );
598 }
599 if ($this->access->checkRbacOrPositionPermissionAccess(
600 'edit_submissions_grades',
601 'edit_submissions_grades',
602 $this->object->getRefId()
603 )) {
604 $this->tabs_gui->addTab(
605 "grades",
606 $lng->txt("exc_submissions_and_grades"),
607 $this->ctrl->getLinkTargetByClass("ilexercisemanagementgui", "members")
608 );
609 }
610
611 // learning progress
612 $ctrl->clearParametersByClass('illearningprogressgui');
613
614 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
615 $this->tabs_gui->addTab(
616 'learning_progress',
617 $lng->txt('learning_progress'),
618 $this->ctrl->getLinkTargetByClass(array('ilobjexercisegui', 'illearningprogressgui'), '')
619 );
620 }
621
622 // meta data
623 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
624 $mdgui = new ilObjectMetaDataGUI($this->object);
625 $mdtab = $mdgui->getTab();
626 if ($mdtab) {
627 $this->tabs_gui->addTarget(
628 "meta_data",
629 $mdtab,
630 "",
631 "ilobjectmetadatagui"
632 );
633 }
634 }
635
636 // export
637 if ($this->checkPermissionBool("write")) {
638 $this->tabs_gui->addTab(
639 "export",
640 $lng->txt("export"),
641 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
642 );
643 }
644
645 // permissions
646 if ($this->checkPermissionBool("edit_permission")) {
647 $this->tabs_gui->addTab(
648 'permissions',
649 $lng->txt("perm_settings"),
650 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), "perm")
651 );
652 }
653 }
654
658 public function infoScreenObject(): void
659 {
660 $this->ctrl->setCmd("showSummary");
661 $this->ctrl->setCmdClass("ilinfoscreengui");
662 $this->infoScreen();
663 }
664
665 protected function getService(): InternalService
666 {
667 return $this->service;
668 }
669
673 public function infoScreen(): void
674 {
676 $ilTabs = $this->tabs;
678
679 $ilTabs->activateTab("info");
680
682 $exc = $this->object;
683
684 if (!$this->checkPermissionBool("read")) {
685 $this->checkPermission("visible");
686 }
687
688 $info = new ilInfoScreenGUI($this);
689
690 $info->enablePrivateNotes();
691
692 $info->enableNews();
693 if ($this->checkPermissionBool("write")) {
694 $info->enableNewsEditing();
695 $info->setBlockProperty("news", "settings", true);
696 }
697
698 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'exc', $this->object->getId());
699 $record_gui->setInfoObject($info);
700 $record_gui->parse();
701
702 // standard meta data
703 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
704
705 // instructions
706 $info->addSection($this->lng->txt("exc_overview"));
708 $cnt = 0;
709 $mcnt = 0;
710 foreach ($ass as $a) {
711 $cnt++;
712 if ($a["mandatory"]) {
713 $mcnt++;
714 }
715 }
716 $info->addProperty($lng->txt("exc_assignments"), $cnt);
717 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_ALL) {
718 $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
719 $info->addProperty(
720 $lng->txt("exc_pass_mode"),
721 $lng->txt("exc_msg_all_mandatory_ass")
722 );
723 } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_NR) {
724 $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
725 $info->addProperty(
726 $lng->txt("exc_pass_mode"),
727 sprintf($lng->txt("exc_msg_min_number_ass"), $this->object->getPassNr())
728 );
729 } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
730 $info->addProperty($lng->txt("exc_mandatory"), $exc->getNrMandatoryRandom());
731 $info->addProperty(
732 $lng->txt("exc_pass_mode"),
733 $lng->txt("exc_msg_all_mandatory_ass")
734 );
735 }
736
737 // feedback from tutor
738 if ($this->checkPermissionBool("read")) {
739 $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
740 $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
741 //$status = ilExerciseMembers::_lookupStatus($this->object->getId(), $ilUser->getId());
742 $st = $this->object->determinStatusOfUser($ilUser->getId());
743 $status = $st["overall_status"];
744 if ($lpcomment != "" || $mark != "" || $status != "notgraded") {
745 $info->addSection($this->lng->txt("exc_feedback_from_tutor"));
746 if ($lpcomment != "") {
747 $info->addProperty(
748 $this->lng->txt("exc_comment"),
749 $lpcomment
750 );
751 }
752 if ($mark != "") {
753 $info->addProperty(
754 $this->lng->txt("exc_mark"),
755 $mark
756 );
757 }
758
759 //if ($status == "")
760 //{
761 // $info->addProperty($this->lng->txt("status"),
762 // $this->lng->txt("message_no_delivered_files"));
763 //}
764 //else
765 if ($status != "notgraded") {
767
768 switch ($status) {
769 case "passed":
770 $path = $icons->getImagePathCompleted();
771 break;
772 case "failed":
773 $path = $icons->getImagePathFailed();
774 break;
775 default:
776 $path = ilUtil::getImagePath("scorm/" . $status . ".svg");
777 }
778
779 $img = $icons->renderIcon($path, $lng->txt("exc_" . $status));
780
781 $add = "";
782 if ($st["failed_a_mandatory"]) {
783 $add = " (" . $lng->txt("exc_msg_failed_mandatory") . ")";
784 } elseif ($status == "failed") {
785 $add = " (" . $lng->txt("exc_msg_missed_minimum_number") . ")";
786 }
787 $info->addProperty(
788 $this->lng->txt("status"),
789 $img . " " . $this->lng->txt("exc_" . $status) . $add
790 );
791 }
792 }
793 }
794
795 // forward the command
796 $this->ctrl->forwardCommand($info);
797 }
798
799 public function editObject(): void
800 {
801 $this->setSettingsSubTabs();
802 $this->tabs_gui->activateSubTab("edit");
803 parent::editObject();
804 }
805
806 protected function setSettingsSubTabs(): void
807 {
808 $this->tabs_gui->addSubTab(
809 "edit",
810 $this->lng->txt("general_settings"),
811 $this->ctrl->getLinkTarget($this, "edit")
812 );
813
814 $this->tabs_gui->addSubTab(
815 "crit",
816 $this->lng->txt("exc_criteria_catalogues"),
817 $this->ctrl->getLinkTargetByClass("ilexccriteriacataloguegui", "")
818 );
819
820 $validator = new ilCertificateActiveValidator();
821 if ($validator->validate()) {
822 $this->tabs_gui->addSubTab(
823 "certificate",
824 $this->lng->txt("certificate"),
825 $this->ctrl->getLinkTarget($this, "certificate")
826 );
827 }
828 }
829
830 public static function _goto(
831 string $a_target,
832 string $a_raw
833 ): void {
834 global $DIC;
835
836 $main_tpl = $DIC->ui()->mainTemplate();
837
838 $request = $DIC->exercise()->internal()->gui()->request();
839 $ass_id = $request->getAssId();
840
841 $lng = $DIC->language();
842 $ilAccess = $DIC->access();
843 $ilCtrl = $DIC->ctrl();
844
845 //we don't have baseClass here...
846 $ilCtrl->setTargetScript("ilias.php");
847
848 //ilExerciseMailNotification has links to:
849 // "Assignments", "Submission and Grades" and Downnoad the NEW files if the assignment type is "File Upload".
850 $parts = explode("_", $a_raw);
851 $action = null;
852 $member = null;
853 if (!$ass_id) {
854 $ass_id = null;
855
856 switch (end($parts)) {
857 case "download":
858 case "setdownload":
859 $action = $parts[3];
860 $member = $parts[2];
861 $ass_id = $parts[1];
862 break;
863
864 case "grades":
865 $action = $parts[2];
866 $ass_id = $parts[1];
867 break;
868 }
869 }
870
871 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ref_id", $a_target);
872
873 if ($ilAccess->checkAccess("read", "", $a_target)) {
874 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "target", $a_raw);
875
876 if ($ass_id) {
877 $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "ass_id", $ass_id);
878 }
879
880 switch ($action) {
881 case "grades":
882 $ilCtrl->redirectByClass(
883 array("ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI"),
884 "members"
885 );
886 break;
887
888 /*case "download":
889 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "member_id", $member);
890 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI", "ilExSubmissionFileGUI"),"downloadNewReturned");
891 break;*/
892
893 case "setdownload":
894 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "member_id", $member);
895 $ilCtrl->redirectByClass(
896 array("ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI"),
897 "waitingDownload"
898 );
899 break;
900
901 default:
902 if (($parts[1] ?? "") != "") {
903 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ass_id", $parts[1]);
904 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ass_id_goto", $parts[1]);
905 }
906 $ilCtrl->redirectByClass(
907 array("ilExerciseHandlerGUI", "ilObjExerciseGUI"),
908 "showOverview"
909 );
910 break;
911
912 }
913 } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
914 $ilCtrl->redirectByClass(
915 array("ilExerciseHandlerGUI", "ilObjExerciseGUI"),
916 "infoScreen"
917 );
918 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
919 $main_tpl->setOnScreenMessage('failure', sprintf(
920 $lng->txt("msg_no_perm_read_item"),
922 ), true);
924 }
925 }
926
930 protected function addLocatorItems(): void
931 {
932 $ilLocator = $this->locator;
933
934 if (is_object($this->object)) {
935 // #17955
936 $ilLocator->addItem(
937 $this->object->getTitle(),
938 $this->ctrl->getLinkTarget($this, "showOverview"),
939 "",
940 $this->requested_ref_id
941 );
942 }
943 }
944
945
949
958 public function showOverviewObject(): void
959 {
961 $ilTabs = $this->tabs;
962 $ilUser = $this->user;
963 $ilToolbar = $this->toolbar;
965 $exc = $this->object;
966
967 $this->checkPermission("read");
968
969 $ilTabs->activateTab("content");
970 $this->addContentSubTabs("content");
971
972 if ($this->handleRandomAssignmentEntryPage()) {
973 return;
974 }
975
976 $tpl->addJavaScript("./Modules/Exercise/js/ilExcPresentation.js");
977
979 $ilUser->getId(),
980 $this->object->getId(),
981 $this->object->getRefId(),
982 'exc'
983 );
984
985 if ($this->certificateDownloadValidator->isCertificateDownloadable(
986 $ilUser->getId(),
987 $this->object->getId()
988 )) {
989 $ilToolbar->addButton(
990 $this->lng->txt("certificate"),
991 $this->ctrl->getLinkTarget($this, "outCertificate")
992 );
993 }
994
995 $ass_gui = new ilExAssignmentGUI($exc, $this->getService());
996
997 $acc = new ilAccordionGUI();
998 $acc->setId("exc_ow_" . $this->object->getId());
999
1000 $ass_data = ilExAssignment::getInstancesByExercise($this->object->getId());
1001 $random_manager = $this->service->domain()->assignment()->randomAssignments($exc);
1002 foreach ($ass_data as $ass) {
1003 if (!$random_manager->isAssignmentVisible($ass->getId(), $this->user->getId())) {
1004 continue;
1005 }
1006
1007 // incoming assignment deeplink
1008 $force_open = false;
1009 if ($this->requested_ass_id_goto === $ass->getId()) {
1010 $force_open = true;
1011 }
1012
1013 $acc->addItem(
1014 $ass_gui->getOverviewHeader($ass),
1015 $ass_gui->getOverviewBody($ass),
1016 $force_open
1017 );
1018 }
1019
1020 if (count($ass_data) < 2) {
1021 $acc->setBehaviour("FirstOpen");
1022 } else {
1023 $acc->setUseSessionStorage(true);
1024 }
1025
1026 $mtpl = new ilTemplate("tpl.exc_ass_overview.html", true, true, "Modules/Exercise");
1027 $mtpl->setVariable("CONTENT", $acc->getHTML());
1028
1029 $tpl->setContent($mtpl->get());
1030 }
1031
1035 public function certificateObject(): void
1036 {
1037 $this->checkPermission("write");
1038 $this->setSettingsSubTabs();
1039 $this->tabs_gui->activateTab("settings");
1040 $this->tabs_gui->activateSubTab("certificate");
1041
1042 $guiFactory = new ilCertificateGUIFactory();
1043 $output_gui = $guiFactory->create($this->object);
1044
1045 $output_gui->certificateEditor();
1046 }
1047
1048 public function outCertificateObject(): void
1049 {
1050 global $DIC;
1051
1052 $database = $DIC->database();
1053 $logger = $DIC->logger()->root();
1054
1055 $ilUser = $this->user;
1056
1057 $objectId = $this->object->getId();
1058
1059 if (!$this->certificateDownloadValidator->isCertificateDownloadable($ilUser->getId(), $objectId)) {
1060 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
1061 $this->ctrl->redirect($this);
1062 }
1063
1064 $ilUserCertificateRepository = new ilUserCertificateRepository($database, $logger);
1065 $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $logger);
1066
1067 $pdfAction = new ilCertificatePdfAction(
1068 $logger,
1069 $pdfGenerator,
1071 $this->lng->txt('error_creating_certificate_pdf')
1072 );
1073
1074 $pdfAction->downloadPdf($ilUser->getId(), $objectId);
1075 }
1076
1080 public function startAssignmentObject(): void
1081 {
1082 $ctrl = $this->ctrl;
1083 $user = $this->user;
1084
1085 if ($this->ass !== null) {
1086 $state = ilExcAssMemberState::getInstanceByIds($this->ass->getId(), $user->getId());
1087 if (!$state->getCommonDeadline() && $state->getRelativeDeadline()) {
1088 $idl = $state->getIndividualDeadlineObject();
1089 $idl->setStartingTimestamp(time());
1090 $idl->save();
1091 }
1092 }
1093
1094 $ctrl->redirect($this, "showOverview");
1095 }
1096
1100 protected function handleRandomAssignmentEntryPage(): bool
1101 {
1103 $exc = $this->object;
1104
1105 $service = $this->getService();
1106 $random_manager = $service->domain()->assignment()->randomAssignments($exc);
1107 if ($random_manager->needsStart()) {
1108 $gui = $this->exercise_ui->getRandomAssignmentGUI();
1109 $gui->renderStartPage();
1110 return true;
1111 }
1112
1113 return false;
1114 }
1115}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Exercise gui request wrapper.
Exercise UI frontend presentation service class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
clearParametersByClass(string $a_class)
@inheritDoc
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
Class ilExAssignmentEditorGUI.
GUI class for exercise assignments.
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...
Class ilExerciseManagementGUI.
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...
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
static _goto(string $a_target, string $a_raw)
addContentSubTabs(string $a_activate)
ilCertificateDownloadValidator $certificateDownloadValidator
startAssignmentObject()
Start assignment with relative deadline.
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.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
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.
prepareOutput(bool $show_sub_objects=true)
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
ServerRequestInterface $request
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getLongDescription()
get object long description (stored in object_description)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
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 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...
special template class to simplify handling of ITX/PEAR
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$img
Definition: imgupload.php:83
$ilUser
Definition: imgupload.php:34
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$path
Definition: ltiservices.php:32
getService(string &$path)
$service
Definition: ltiservices.php:43
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
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
Class ilPdfGeneratorConstantsTest.