ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjExerciseGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
22{
27
31 protected $tabs;
32
36 protected $help;
37
41 protected $ass = null;
42
46 protected $service;
47
52
56 protected $exercise_ui;
57
62
67 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
68 {
69 global $DIC;
70
71 $this->lng = $DIC->language();
72 $this->user = $DIC->user();
73 $this->ctrl = $DIC->ctrl();
74 $this->tabs = $DIC->tabs();
75 $this->help = $DIC["ilHelp"];
76 $this->locator = $DIC["ilLocator"];
77 $this->tpl = $DIC["tpl"];
78 $this->toolbar = $DIC->toolbar();
79 $lng = $DIC->language();
80
81 $this->lng->loadLanguageModule('cert');
82
83 $this->type = "exc";
84 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
85
86 $lng->loadLanguageModule("exercise");
87 $lng->loadLanguageModule("exc");
88 $this->ctrl->saveParameter($this, "ass_id");
89
90 $this->service = $DIC->exercise()->internal()->service();
91 $this->exercise_request = $DIC->exercise()->internal()->request();
92 $this->exercise_ui = $DIC->exercise()->internal()->ui();
93 $this->requested_ass_id = $this->exercise_request->getRequestedAssId();
94
95 if ($this->requested_ass_id > 0 && is_object($this->object) && ilExAssignment::lookupExerciseId($this->requested_ass_id) == $this->object->getId()) {
96 $this->ass = $this->exercise_request->getRequestedAssignment();
97 } elseif ($this->requested_ass_id > 0) {
98 throw new ilExerciseException("Assignment ID does not match Exercise.");
99 }
100
101 $this->certificateDownloadValidator = new ilCertificateDownloadValidator();
102 }
103
104 public function executeCommand()
105 {
107 $ilCtrl = $this->ctrl;
108 $ilTabs = $this->tabs;
110
111 $next_class = $this->ctrl->getNextClass($this);
112 $cmd = $this->ctrl->getCmd();
113 $this->prepareOutput();
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 $ret = &$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 $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId()
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 $ret = $this->ctrl->forwardCommand($exp_gui);
157// $this->tpl->show();
158 break;
159
160 case "ilcommonactiondispatchergui":
162 $this->ctrl->forwardCommand($gui);
163 break;
164
165 case "ilcertificategui":
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($this->object->getId(), $this->object->isCompletionBySubmissionEnabled(), $this->ass);
181 $this->ctrl->forwardCommand($ass_gui);
182 break;
183
184 case "ilexsubmissiongui":
185 $this->checkPermission("read");
186 $random_manager = $this->service->getRandomAssignmentManager($this->object);
187 if (!$random_manager->isAssignmentVisible($this->requested_ass_id, $this->user->getId())) {
188 return;
189 }
190 $ilTabs->activateTab("content");
191 $this->addContentSubTabs("content");
192 $this->ctrl->setReturn($this, "showOverview");
193 $sub_gui = $this->exercise_ui->getSubmissionGUI();
194 $this->ctrl->forwardCommand($sub_gui);
195 break;
196
197 case "ilexercisemanagementgui":
198 // rbac or position access
199 if ($GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess(
200 'edit_submissions_grades',
201 'edit_submissions_grades',
202 $this->object->getRefId()
203 )) {
204 $ilTabs->activateTab("grades");
205 $mgmt_gui = new ilExerciseManagementGUI($this->getService(), $this->ass);
206 $this->ctrl->forwardCommand($mgmt_gui);
207 } else {
208 $this->checkPermission("edit_submissions_grades"); // throw error by standard procedure
209 }
210 break;
211
212 case "ilexccriteriacataloguegui":
213 $this->checkPermission("write");
214 $ilTabs->activateTab("settings");
215 $this->setSettingsSubTabs();
216 $ilTabs->activateSubTab("crit");
217 $crit_gui = new ilExcCriteriaCatalogueGUI($this->object);
218 $this->ctrl->forwardCommand($crit_gui);
219 break;
220
221
222 case "ilportfolioexercisegui":
223 $this->ctrl->saveParameter($this, array("part_id"));
224 $gui = new ilPortfolioExerciseGUI($this->object, $this->initSubmission());
225 $ilCtrl->forwardCommand($gui);
226 break;
227
228 case "ilexcrandomassignmentgui":
229 $gui = $this->exercise_ui->getRandomAssignmentGUI();
230 $this->ctrl->forwardCommand($gui);
231 break;
232
233 case 'ilobjectmetadatagui':
234 $this->checkPermissionBool("write", '', '', $this->object->getRefId());
235 $this->tabs_gui->setTabActive('meta_data');
236 $md_gui = new ilObjectMetaDataGUI($this->object);
237 $this->ctrl->forwardCommand($md_gui);
238 break;
239
240 default:
241 if (!$cmd) {
242 $cmd = "infoScreen";
243 }
244
245 $cmd .= "Object";
246
247 $this->$cmd();
248
249 break;
250 }
251
252 $this->addHeaderAction();
253
254 return true;
255 }
256
257 public function viewObject()
258 {
259 $this->infoScreenObject();
260 }
261
262 protected function afterSave(ilObject $a_new_object)
263 {
264 $ilCtrl = $this->ctrl;
265
266 $a_new_object->saveData();
267
268 ilUtil::sendSuccess($this->lng->txt("exc_added"), true);
269
270 $ilCtrl->setParameterByClass("ilExAssignmentEditorGUI", "ref_id", $a_new_object->getRefId());
271 $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "addAssignment");
272 }
273
274 protected function listAssignmentsObject()
275 {
276 $ilCtrl = $this->ctrl;
277
278 $this->checkPermissionBool("write");
279
280 // #16587
281 $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "listAssignments");
282 }
283
287 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
288 {
289 $obj_service = $this->getObjectService();
290
291 $service = $this->getService();
292 $random_manager = $service->getRandomAssignmentManager($this->object);
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
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($this->lng->txt("exc_random_selection_not_changeable_info") . " " .
330 implode(" ", $random_manager->getDeniedActivationReasons()));
331 }
332 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM && !$random_manager->canBeDeactivated()) {
333 $radg->setDisabled(true);
334 $radg->setInfo($this->lng->txt("exc_pass_mode_not_changeable_info") . " " .
335 implode(" ", $random_manager->getDeniedDeactivationReasons()));
336 }
337 // minimum number of assignments to pass
338 $rn = new ilNumberInputGUI($this->lng->txt("exc_nr_random_mand"), "nr_random_mand");
339 $rn->setSize(4);
340 $rn->setMaxLength(4);
341 $rn->setRequired(true);
342 $rn->setMinValue(1, false);
343 $cnt = ilExAssignment::count($this->object->getId());
344 $rn->setMaxValue($cnt, true);
345 $op3->addSubItem($rn);
346
347 $radg->addOption($op3);
348
349 // minimum number of assignments to pass
350 $ni = new ilNumberInputGUI($this->lng->txt("exc_min_nr"), "pass_nr");
351 $ni->setSize(4);
352 $ni->setMaxLength(4);
353 $ni->setRequired(true);
354 $mand = ilExAssignment::countMandatory($this->object->getId());
355 $min = max($mand, 1);
356 $ni->setMinValue($min, true);
357 $ni->setInfo($this->lng->txt("exc_min_nr_info"));
358 $op2->addSubItem($ni);
359
360 $a_form->addItem($radg);
361
362 // completion by submission
363 $subcompl = new ilRadioGroupInputGUI($this->lng->txt("exc_passed_status_determination"), "completion_by_submission");
364 $op1 = new ilRadioOption($this->lng->txt("exc_completion_by_tutor"), 0, "");
365 $subcompl->addOption($op1);
366 $op2 = new ilRadioOption($this->lng->txt("exc_completion_by_submission"), 1, $this->lng->txt("exc_completion_by_submission_info"));
367 $subcompl->addOption($op2);
368 $a_form->addItem($subcompl);
369
370 /*$subcompl = new ilCheckboxInputGUI($this->lng->txt('exc_completion_by_submission'), 'completion_by_submission');
371 $subcompl->setInfo($this->lng->txt('exc_completion_by_submission_info'));
372 $subcompl->setValue(1);
373 $a_form->addItem($subcompl);*/
374
376 $section->setTitle($this->lng->txt('exc_publishing'));
377 $a_form->addItem($section);
378
379 // show submissions
380 $cb = new ilCheckboxInputGUI($this->lng->txt("exc_show_submissions"), "show_submissions");
381 $cb->setInfo($this->lng->txt("exc_show_submissions_info"));
382 $a_form->addItem($cb);
383
385 $section->setTitle($this->lng->txt('exc_notification'));
386 $a_form->addItem($section);
387
388 // submission notifications
389 $cbox = new ilCheckboxInputGUI($this->lng->txt("exc_submission_notification"), "notification");
390 $cbox->setInfo($this->lng->txt("exc_submission_notification_info"));
391 $a_form->addItem($cbox);
392
393
394 // feedback settings
395
397 $section->setTitle($this->lng->txt('exc_feedback'));
398 $a_form->addItem($section);
399
400 $fdb = new ilCheckboxGroupInputGUI($this->lng->txt("exc_settings_feedback"), "tfeedback");
401 $a_form->addItem($fdb);
402
403 $option = new ilCheckboxOption($this->lng->txt("exc_settings_feedback_mail"), ilObjExercise::TUTOR_FEEDBACK_MAIL);
404 $option->setInfo($this->lng->txt("exc_settings_feedback_mail_info"));
405 $fdb->addOption($option);
406 $option = new ilCheckboxOption($this->lng->txt("exc_settings_feedback_file"), ilObjExercise::TUTOR_FEEDBACK_FILE);
407 $option->setInfo($this->lng->txt("exc_settings_feedback_file_info"));
408 $fdb->addOption($option);
409 $option = new ilCheckboxOption($this->lng->txt("exc_settings_feedback_text"), ilObjExercise::TUTOR_FEEDBACK_TEXT);
410 $option->setInfo($this->lng->txt("exc_settings_feedback_text_info"));
411 $fdb->addOption($option);
412
413 // additional features
415 $section->setTitle($this->lng->txt('obj_features'));
416 $a_form->addItem($section);
417
419
420 $position_settings = ilOrgUnitGlobalSettings::getInstance()
421 ->getObjectPositionSettingsByType($this->object->getType());
422
423 if ($position_settings->isActive()) {
425 }
426
428 $this->object->getId(),
429 $a_form,
430 $features
431 );
432 }
433
437 protected function getEditFormCustomValues(array &$a_values)
438 {
440
441 $a_values["desc"] = $this->object->getLongDescription();
442 $a_values["show_submissions"] = $this->object->getShowSubmissions();
443 $a_values["pass_mode"] = $this->object->getPassMode();
444 if ($a_values["pass_mode"] == "nr") {
445 $a_values["pass_nr"] = $this->object->getPassNr();
446 }
447
448 $a_values["nr_random_mand"] = $this->object->getNrMandatoryRandom();
449
450 $a_values["notification"] = ilNotification::hasNotification(
452 $ilUser->getId(),
453 $this->object->getId()
454 );
455
456 $a_values['completion_by_submission'] = (int) $this->object->isCompletionBySubmissionEnabled();
457
458 $tfeedback = array();
459 if ($this->object->hasTutorFeedbackMail()) {
461 }
462 if ($this->object->hasTutorFeedbackText()) {
464 }
465 if ($this->object->hasTutorFeedbackFile()) {
467 }
468 $a_values['tfeedback'] = $tfeedback;
469
470 // orgunit position setting enabled
471 $a_values['obj_orgunit_positions'] = (bool) ilOrgUnitGlobalSettings::getInstance()
472 ->isPositionAccessActiveForObject($this->object->getId());
473
474 $a_values['cont_custom_md'] = ilContainer::_lookupContainerSetting(
475 $this->object->getId(),
477 false
478 );
479 }
480
481 protected function updateCustom(ilPropertyFormGUI $a_form)
482 {
483 $obj_service = $this->getObjectService();
484
486 $this->object->setShowSubmissions($a_form->getInput("show_submissions"));
487 $this->object->setPassMode($a_form->getInput("pass_mode"));
488 if ($this->object->getPassMode() == "nr") {
489 $this->object->setPassNr($a_form->getInput("pass_nr"));
490 }
491 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
492 $this->object->setNrMandatoryRandom($a_form->getInput("nr_random_mand"));
493 }
494
495 $this->object->setCompletionBySubmission($a_form->getInput('completion_by_submission') == 1 ? true : false);
496
497 $feedback = $a_form->getInput("tfeedback");
498 $this->object->setTutorFeedback(is_array($feedback)
499 ? array_sum($feedback)
500 : null);
501
504 $ilUser->getId(),
505 $this->object->getId(),
506 (bool) $a_form->getInput("notification")
507 );
508
509 // tile image
510 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
511
513 $this->object->getId(),
514 $a_form,
515 array(
518 )
519 );
520 }
521
527 public function addContentSubTabs($a_activate)
528 {
529 $ilTabs = $this->tabs;
531 $ilCtrl = $this->ctrl;
532
533 $ilTabs->addSubTab(
534 "content",
535 $lng->txt("view"),
536 $ilCtrl->getLinkTarget($this, "showOverview")
537 );
538 if ($this->checkPermissionBool("write")) {
539 $ilTabs->addSubTab(
540 "list_assignments",
541 $lng->txt("edit"),
542 $ilCtrl->getLinkTargetByClass("ilExAssignmentEditorGUI", "listAssignments")
543 );
544 }
545 $ilTabs->activateSubTab($a_activate);
546 }
547
553 public function getTabs()
554 {
556 $ilHelp = $this->help;
557
558 $ilHelp->setScreenIdComponent("exc");
559
560 if ($this->checkPermissionBool("read")) {
561 $this->tabs_gui->addTab(
562 "content",
563 $lng->txt("exc_assignments"),
564 $this->ctrl->getLinkTarget($this, "showOverview")
565 );
566 }
567
568 $next_class = strtolower($this->ctrl->getNextClass());
569 if ($this->checkPermissionBool("visible") || $this->checkPermissionBool("read")) {
570 $this->tabs_gui->addTab(
571 "info",
572 $lng->txt("info_short"),
573 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
574 );
575 }
576
577 // edit properties
578 if ($this->checkPermissionBool("write")) {
579 /*$tabs_gui->addTab("assignments",
580 $lng->txt("exc_edit_assignments"),
581 $this->ctrl->getLinkTarget($this, 'listAssignments'));*/
582
583 $this->tabs_gui->addTab(
584 "settings",
585 $lng->txt("settings"),
586 $this->ctrl->getLinkTarget($this, 'edit')
587 );
588 }
589 if ($this->access->checkRbacOrPositionPermissionAccess(
590 'edit_submissions_grades',
591 'edit_submissions_grades',
592 $this->object->getRefId()
593 )) {
594 $this->tabs_gui->addTab(
595 "grades",
596 $lng->txt("exc_submissions_and_grades"),
597 $this->ctrl->getLinkTargetByClass("ilexercisemanagementgui", "members")
598 );
599 }
600
601 // learning progress
602 $save_sort_order = $_GET["sort_order"]; // hack, because exercise sort parameters
603 $save_sort_by = $_GET["sort_by"]; // must not be forwarded to learning progress
604 $save_offset = $_GET["offset"];
605 $_GET["offset"] = $_GET["sort_by"] = $_GET["sort_order"] = "";
606
607 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
608 $this->tabs_gui->addTab(
609 'learning_progress',
610 $lng->txt('learning_progress'),
611 $this->ctrl->getLinkTargetByClass(array('ilobjexercisegui','illearningprogressgui'), '')
612 );
613 }
614
615 // meta data
616 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
617 $mdgui = new ilObjectMetaDataGUI($this->object);
618 $mdtab = $mdgui->getTab();
619 if ($mdtab) {
620 $this->tabs_gui->addTarget(
621 "meta_data",
622 $mdtab,
623 "",
624 "ilobjectmetadatagui"
625 );
626 }
627 }
628
629 $_GET["sort_order"] = $save_sort_order; // hack, part ii
630 $_GET["sort_by"] = $save_sort_by;
631 $_GET["offset"] = $save_offset;
632
633 // export
634 if ($this->checkPermissionBool("write")) {
635 $this->tabs_gui->addTab(
636 "export",
637 $lng->txt("export"),
638 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
639 );
640 }
641
642
643 // permissions
644 if ($this->checkPermissionBool("edit_permission")) {
645 $this->tabs_gui->addTab(
646 'permissions',
647 $lng->txt("perm_settings"),
648 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
649 );
650 }
651 }
652
658 public function infoScreenObject()
659 {
660 $this->ctrl->setCmd("showSummary");
661 $this->ctrl->setCmdClass("ilinfoscreengui");
662 $this->infoScreen();
663 }
664
670 protected function getService()
671 {
672 return $this->service;
673 }
674
678 public function infoScreen()
679 {
681 $ilTabs = $this->tabs;
683
684 $ilTabs->activateTab("info");
685
687 $exc = $this->object;
688
689 if (!$this->checkPermissionBool("read")) {
690 $this->checkPermission("visible");
691 }
692
693 $info = new ilInfoScreenGUI($this);
694
695 $info->enablePrivateNotes();
696
697 $info->enableNews();
698 if ($this->checkPermissionBool("write")) {
699 $info->enableNewsEditing();
700 $info->setBlockProperty("news", "settings", true);
701 }
702
703 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'exc', $this->object->getId());
704 $record_gui->setInfoObject($info);
705 $record_gui->parse();
706
707 // standard meta data
708 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
709
710 // instructions
711 $info->addSection($this->lng->txt("exc_overview"));
712 $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
713 $cnt = 0;
714 $mcnt = 0;
715 foreach ($ass as $a) {
716 $cnt++;
717 if ($a["mandatory"]) {
718 $mcnt++;
719 }
720 }
721 $info->addProperty($lng->txt("exc_assignments"), $cnt);
722 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_ALL) {
723 $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
724 $info->addProperty(
725 $lng->txt("exc_pass_mode"),
726 $lng->txt("exc_msg_all_mandatory_ass")
727 );
728 } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_NR) {
729 $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
730 $info->addProperty(
731 $lng->txt("exc_pass_mode"),
732 sprintf($lng->txt("exc_msg_min_number_ass"), $this->object->getPassNr())
733 );
734 } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
735 $info->addProperty($lng->txt("exc_mandatory"), $exc->getNrMandatoryRandom());
736 $info->addProperty(
737 $lng->txt("exc_pass_mode"),
738 $lng->txt("exc_msg_all_mandatory_ass")
739 );
740 }
741
742 // feedback from tutor
743 if ($this->checkPermissionBool("read")) {
744 $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
745 $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
746 //$status = ilExerciseMembers::_lookupStatus($this->object->getId(), $ilUser->getId());
747 $st = $this->object->determinStatusOfUser($ilUser->getId());
748 $status = $st["overall_status"];
749 if ($lpcomment != "" || $mark != "" || $status != "notgraded") {
750 $info->addSection($this->lng->txt("exc_feedback_from_tutor"));
751 if ($lpcomment != "") {
752 $info->addProperty(
753 $this->lng->txt("exc_comment"),
754 $lpcomment
755 );
756 }
757 if ($mark != "") {
758 $info->addProperty(
759 $this->lng->txt("exc_mark"),
760 $mark
761 );
762 }
763
764 //if ($status == "")
765 //{
766 // $info->addProperty($this->lng->txt("status"),
767 // $this->lng->txt("message_no_delivered_files"));
768 //}
769 //else
770 if ($status != "notgraded") {
772
773 switch ($status) {
774 case "passed":
775 $path = $icons->getImagePathCompleted();
776 break;
777 case "failed":
778 $path = $icons->getImagePathFailed();
779 break;
780 default:
781 $path = ilUtil::getImagePath("scorm/" . $status . ".svg");
782 }
783
784 $img = $icons->renderIcon($path, $lng->txt("exc_" . $status));
785
786 $add = "";
787 if ($st["failed_a_mandatory"]) {
788 $add = " (" . $lng->txt("exc_msg_failed_mandatory") . ")";
789 } elseif ($status == "failed") {
790 $add = " (" . $lng->txt("exc_msg_missed_minimum_number") . ")";
791 }
792 $info->addProperty(
793 $this->lng->txt("status"),
794 $img . " " . $this->lng->txt("exc_" . $status) . $add
795 );
796 }
797 }
798 }
799
800 // forward the command
801 $this->ctrl->forwardCommand($info);
802 }
803
804 public function editObject()
805 {
806 $this->setSettingsSubTabs();
807 $this->tabs_gui->activateSubTab("edit");
808 return parent::editObject();
809 }
810
811 protected function setSettingsSubTabs()
812 {
813 $this->tabs_gui->addSubTab(
814 "edit",
815 $this->lng->txt("general_settings"),
816 $this->ctrl->getLinkTarget($this, "edit")
817 );
818
819 $this->tabs_gui->addSubTab(
820 "crit",
821 $this->lng->txt("exc_criteria_catalogues"),
822 $this->ctrl->getLinkTargetByClass("ilexccriteriacataloguegui", "")
823 );
824
825 $validator = new ilCertificateActiveValidator();
826 if (true === $validator->validate()) {
827 $this->tabs_gui->addSubTab(
828 "certificate",
829 $this->lng->txt("certificate"),
830 $this->ctrl->getLinkTarget($this, "certificate")
831 );
832 }
833 }
834
840 public static function _goto($a_target, $a_raw)
841 {
842 global $DIC;
843
844 $ilErr = $DIC["ilErr"];
845 $lng = $DIC->language();
846 $ilAccess = $DIC->access();
847 $ilCtrl = $DIC->ctrl();
848
849 //we don't have baseClass here...
850 $ilCtrl->setTargetScript("ilias.php");
851 $ilCtrl->initBaseClass("ilRepositoryGUI");
852
853 //ilExerciseMailNotification has links to:
854 // "Assignments", "Submission and Grades" and Downnoad the NEW files if the assignment type is "File Upload".
855 $ass_id = $_GET['ass_id'];
856 $parts = explode("_", $a_raw);
857 if (!$ass_id) {
858 $ass_id = null;
859 $action = null;
860
861 switch (end($parts)) {
862 case "download":
863 $action = $parts[3];
864 $member = $parts[2];
865 $ass_id = $parts[1];
866 break;
867
868 case "setdownload":
869 $action = $parts[3];
870 $member = $parts[2];
871 $ass_id = $parts[1];
872 break;
873
874 case "grades":
875 $action = $parts[2];
876 $ass_id = $parts[1];
877 break;
878 }
879 }
880
881 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ref_id", $a_target);
882
883 if ($ilAccess->checkAccess("read", "", $a_target)) {
884 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "target", $a_raw);
885
886 if ($ass_id) {
887 $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "ass_id", $ass_id);
888 }
889
890 switch ($action) {
891 case "grades":
892 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI"), "members");
893 break;
894
895 /*case "download":
896 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "member_id", $member);
897 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI", "ilExSubmissionFileGUI"),"downloadNewReturned");
898 break;*/
899
900 case "setdownload":
901 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "member_id", $member);
902 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI"), "waitingDownload");
903 break;
904
905 default:
906 if ($parts[1] != "") {
907 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ass_id", $parts[1]);
908 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ass_id_goto", $parts[1]);
909 }
910 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI"), "showOverview");
911 break;
912
913 }
914 } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
915 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI"), "infoScreen");
916 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
917 ilUtil::sendFailure(sprintf(
918 $lng->txt("msg_no_perm_read_item"),
920 ), true);
922 }
923 }
924
928 public function addLocatorItems()
929 {
930 $ilLocator = $this->locator;
931
932 if (is_object($this->object)) {
933 // #17955
934 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "showOverview"), "", $_GET["ref_id"]);
935 }
936 }
937
938
942
946 public function showOverviewObject()
947 {
949 $ilTabs = $this->tabs;
951 $ilToolbar = $this->toolbar;
952
953 $this->checkPermission("read");
954
955 $ilTabs->activateTab("content");
956 $this->addContentSubTabs("content");
957
958 if ($this->handleRandomAssignmentEntryPage()) {
959 return;
960 }
961
962 $tpl->addJavaScript("./Modules/Exercise/js/ilExcPresentation.js");
963
965 $ilUser->getId(),
966 $this->object->getId(),
967 $this->object->getRefId(),
968 'exc'
969 );
970
971
972 if ($this->certificateDownloadValidator->isCertificateDownloadable((int) $ilUser->getId(), (int) $this->object->getId())) {
973 $ilToolbar->addButton(
974 $this->lng->txt("certificate"),
975 $this->ctrl->getLinkTarget($this, "outCertificate")
976 );
977 }
978
979 $ass_gui = new ilExAssignmentGUI($this->object, $this->getService());
980
981 $acc = new ilAccordionGUI();
982 $acc->setId("exc_ow_" . $this->object->getId());
983
984 $ass_data = ilExAssignment::getInstancesByExercise($this->object->getId());
985 $random_manager = $this->service->getRandomAssignmentManager($this->object);
986 foreach ($ass_data as $ass) {
987 if (!$random_manager->isAssignmentVisible($ass->getId(), $this->user->getId())) {
988 continue;
989 }
990
991 // incoming assignment deeplink
992 $force_open = false;
993 if (isset($_GET["ass_id_goto"]) &&
994 (int) $_GET["ass_id_goto"] == $ass->getId()) {
995 $force_open = true;
996 }
997
998 $acc->addItem(
999 $ass_gui->getOverviewHeader($ass),
1000 $ass_gui->getOverviewBody($ass),
1001 $force_open
1002 );
1003 }
1004
1005 if (count($ass_data) < 2) {
1006 $acc->setBehaviour("FirstOpen");
1007 } else {
1008 $acc->setUseSessionStorage(true);
1009 }
1010
1011 $mtpl = new ilTemplate("tpl.exc_ass_overview.html", true, true, "Modules/Exercise");
1012 $mtpl->setVariable("CONTENT", $acc->getHTML());
1013
1014 $tpl->setContent($mtpl->get());
1015 }
1016
1017 public function certificateObject()
1018 {
1019 $this->setSettingsSubTabs();
1020 $this->tabs_gui->activateTab("settings");
1021 $this->tabs_gui->activateSubTab("certificate");
1022
1023 $guiFactory = new ilCertificateGUIFactory();
1024 $output_gui = $guiFactory->create($this->object);
1025
1026 $output_gui->certificateEditor();
1027 }
1028
1029 public function outCertificateObject()
1030 {
1031 global $DIC;
1032
1033 $database = $DIC->database();
1034 $logger = $DIC->logger()->root();
1035
1037
1038 $objectId = (int) $this->object->getId();
1039
1040 if (false === $this->certificateDownloadValidator->isCertificateDownloadable($ilUser->getId(), $objectId)) {
1041 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
1042 $this->ctrl->redirect($this);
1043 }
1044
1045 $ilUserCertificateRepository = new ilUserCertificateRepository($database, $logger);
1046 $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $logger);
1047
1048 $pdfAction = new ilCertificatePdfAction(
1049 $logger,
1050 $pdfGenerator,
1052 $this->lng->txt('error_creating_certificate_pdf')
1053 );
1054
1055 $pdfAction->downloadPdf((int) $ilUser->getId(), (int) $objectId);
1056 }
1057
1061 public function startAssignmentObject()
1062 {
1063 global $DIC;
1064
1065 $ilCtrl = $DIC->ctrl();
1066 $ilUser = $DIC->user();
1067
1068 if ($this->ass) {
1069 $state = ilExcAssMemberState::getInstanceByIds($this->ass->getId(), $ilUser->getId());
1070 if (!$state->getCommonDeadline() && $state->getRelativeDeadline()) {
1071 $idl = $state->getIndividualDeadlineObject();
1072 $idl->setStartingTimestamp(time());
1073 $idl->save();
1074 }
1075 }
1076
1077 $ilCtrl->redirect($this, "showOverview");
1078 }
1079
1086 {
1087 $service = $this->getService();
1088 $random_manager = $service->getRandomAssignmentManager($this->object);
1089 if ($random_manager->needsStart()) {
1090 $gui = $this->exercise_ui->getRandomAssignmentGUI();
1091 $gui->renderStartPage();
1092 return true;
1093 }
1094
1095 return false;
1096 }
1097}
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$section
Definition: Utf8Test.php:83
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Accordion user interface 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($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
Class ilExAssignmentEditorGUI.
GUI class for exercise assignments.
static count($a_ex_id)
Order assignments by deadline date.
static countMandatory($a_ex_id)
Count the number of mandatory assignments.
static getInstancesByExercise($a_exc_id)
static lookupExerciseId($a_ass_id)
Lookup excercise id for assignment id.
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
static getInstanceByIds($a_ass_id, $a_user_id=0)
Get instance by IDs (recommended for consumer code)
Class ilExcCriteriaCatalogueGUI.
Exercise exceptions class.
Class ilExerciseManagementGUI.
Export User Interface Class.
This class represents a section header in a property form.
Class ilInfoScreenGUI.
static _lookupMark($a_usr_id, $a_obj_id)
static _lookupComment($a_usr_id, $a_obj_id)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
Class ilObjUserTrackingGUI.
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
This class represents a number property in a property form.
Class ilObjExerciseGUI.
addLocatorItems()
Add locator item.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
getEditFormCustomValues(array &$a_values)
Get values for properties form.
handleRandomAssignmentEntryPage()
Display random assignment start page, if necessary.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
executeCommand()
execute command
static _goto($a_target, $a_raw)
redirect script
getTabs()
adds tabs to tab gui object
startAssignmentObject()
Start assignment with relative deadline.
initEditCustomForm(ilPropertyFormGUI $a_form)
Init properties form.
showOverviewObject()
Show overview of assignments.
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor @access public.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
addContentSubTabs($a_activate)
Add subtabs of content view.
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
getCreationMode()
get creation mode
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
addHeaderAction()
Add header action menu.
getObjectService()
Get object service.
Class ilObjectMetaDataGUI.
static initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Init service settings form.
static updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Update service settings.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
Class ilPortfolioExerciseGUI.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
setTitle($a_title)
Set Title.
This class represents a property in a property form.
This class represents an option in a radio group.
special template class to simplify handling of ITX/PEAR
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$img
Definition: imgupload.php:57
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Class ilPdfGeneratorConstantsTest.
$ret
Definition: parser.php:6