ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
51 protected $request;
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->request = $DIC->exercise()->internal()->request();
92 $this->exercise_ui = $DIC->exercise()->internal()->ui();
93 $this->requested_ass_id = $this->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->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 {
108 $ilTabs = $this->tabs;
110
111 $next_class = $this->ctrl->getNextClass($this);
112 $cmd = $this->ctrl->getCmd();
113 $this->prepareOutput();
114
115 //echo "-".$next_class."-".$cmd."-"; exit;
116 switch ($next_class) {
117 case "ilinfoscreengui":
118 $ilTabs->activateTab("info");
119 $this->infoScreen(); // forwards command
120 break;
121
122 case 'ilpermissiongui':
123 $ilTabs->activateTab("permissions");
124 $perm_gui = new ilPermissionGUI($this);
125 $ret = &$this->ctrl->forwardCommand($perm_gui);
126 break;
127
128 case "illearningprogressgui":
129 $ilTabs->activateTab("learning_progress");
130 $new_gui = new ilLearningProgressGUI(
132 $this->object->getRefId(),
133 $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId()
134 );
135 $this->ctrl->forwardCommand($new_gui);
136 $this->tabs_gui->setTabActive('learning_progress');
137 break;
138
139 case 'ilobjectcopygui':
140 $ilCtrl->saveParameter($this, 'new_type');
141 $ilCtrl->setReturnByClass(get_class($this), 'create');
142
143 $cp = new ilObjectCopyGUI($this);
144 $cp->setType('exc');
145 $this->ctrl->forwardCommand($cp);
146 break;
147
148 case "ilexportgui":
149 $ilTabs->activateTab("export");
150 $exp_gui = new ilExportGUI($this);
151 $exp_gui->addFormat("xml");
152 $ret = $this->ctrl->forwardCommand($exp_gui);
153// $this->tpl->show();
154 break;
155
156 case "ilcommonactiondispatchergui":
158 $this->ctrl->forwardCommand($gui);
159 break;
160
161 case "ilcertificategui":
162 $this->setSettingsSubTabs();
163 $this->tabs_gui->activateTab("settings");
164 $this->tabs_gui->activateSubTab("certificate");
165
166 $guiFactory = new ilCertificateGUIFactory();
167 $output_gui = $guiFactory->create($this->object);
168
169 $this->ctrl->forwardCommand($output_gui);
170 break;
171
172 case "ilexassignmenteditorgui":
173 $this->checkPermission("write");
174 $ilTabs->activateTab("content");
175 $this->addContentSubTabs("list_assignments");
176 $ass_gui = new ilExAssignmentEditorGUI($this->object->getId(), $this->object->isCompletionBySubmissionEnabled(), $this->ass);
177 $this->ctrl->forwardCommand($ass_gui);
178 break;
179
180 case "ilexsubmissiongui":
181 $this->checkPermission("read");
182 $random_manager = $this->service->getRandomAssignmentManager($this->object);
183 if (!$random_manager->isAssignmentVisible($this->requested_ass_id, $this->user->getId())) {
184 return;
185 }
186 $ilTabs->activateTab("content");
187 $this->addContentSubTabs("content");
188 $this->ctrl->setReturn($this, "showOverview");
189 $sub_gui = $this->exercise_ui->getSubmissionGUI();
190 $this->ctrl->forwardCommand($sub_gui);
191 break;
192
193 case "ilexercisemanagementgui":
194 // rbac or position access
195 if ($GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess(
196 'edit_submissions_grades',
197 'edit_submissions_grades',
198 $this->object->getRefId()
199 )) {
200 $ilTabs->activateTab("grades");
201 $mgmt_gui = new ilExerciseManagementGUI($this->getService(), $this->ass);
202 $this->ctrl->forwardCommand($mgmt_gui);
203 } else {
204 $this->checkPermission("edit_submissions_grades"); // throw error by standard procedure
205 }
206 break;
207
208 case "ilexccriteriacataloguegui":
209 $this->checkPermission("write");
210 $ilTabs->activateTab("settings");
211 $this->setSettingsSubTabs();
212 $ilTabs->activateSubTab("crit");
213 $crit_gui = new ilExcCriteriaCatalogueGUI($this->object);
214 $this->ctrl->forwardCommand($crit_gui);
215 break;
216
217
218 case "ilportfolioexercisegui":
219 $this->ctrl->saveParameter($this, array("part_id"));
220 $gui = new ilPortfolioExerciseGUI($this->object, $this->initSubmission());
221 $ilCtrl->forwardCommand($gui);
222 break;
223
224 case "ilexcrandomassignmentgui":
225 $gui = $this->exercise_ui->getRandomAssignmentGUI();
226 $this->ctrl->forwardCommand($gui);
227 break;
228
229 case 'ilobjectmetadatagui':
230 $this->checkPermissionBool("write", '', '', $this->object->getRefId());
231 $this->tabs_gui->setTabActive('meta_data');
232 $md_gui = new ilObjectMetaDataGUI($this->object);
233 $this->ctrl->forwardCommand($md_gui);
234 break;
235
236 default:
237 if (!$cmd) {
238 $cmd = "infoScreen";
239 }
240
241 $cmd .= "Object";
242
243 $this->$cmd();
244
245 break;
246 }
247
248 $this->addHeaderAction();
249
250 return true;
251 }
252
253 public function viewObject()
254 {
255 $this->infoScreenObject();
256 }
257
258 protected function afterSave(ilObject $a_new_object)
259 {
261
262 $a_new_object->saveData();
263
264 ilUtil::sendSuccess($this->lng->txt("exc_added"), true);
265
266 $ilCtrl->setParameterByClass("ilExAssignmentEditorGUI", "ref_id", $a_new_object->getRefId());
267 $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "addAssignment");
268 }
269
270 protected function listAssignmentsObject()
271 {
273
274 $this->checkPermissionBool("write");
275
276 // #16587
277 $ilCtrl->redirectByClass("ilExAssignmentEditorGUI", "listAssignments");
278 }
279
283 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
284 {
285 $obj_service = $this->getObjectService();
286
287 $service = $this->getService();
288 $random_manager = $service->getRandomAssignmentManager($this->object);
289
290 $a_form->setTitle($this->lng->txt("exc_edit_exercise"));
291
292 $pres = new ilFormSectionHeaderGUI();
293 $pres->setTitle($this->lng->txt('obj_presentation'));
294 $a_form->addItem($pres);
295
296 // tile image
297 $a_form = $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
298
300 $section->setTitle($this->lng->txt('exc_passing_exc'));
301 $a_form->addItem($section);
302
303 // pass mode
304 $radg = new ilRadioGroupInputGUI($this->lng->txt("exc_pass_mode"), "pass_mode");
305
306 $op1 = new ilRadioOption(
307 $this->lng->txt("exc_pass_all"),
309 $this->lng->txt("exc_pass_all_info")
310 );
311 $radg->addOption($op1);
312 $op2 = new ilRadioOption(
313 $this->lng->txt("exc_pass_minimum_nr"),
315 $this->lng->txt("exc_pass_minimum_nr_info")
316 );
317 $radg->addOption($op2);
318 $op3 = new ilRadioOption(
319 $this->lng->txt("exc_random_selection"),
321 $this->lng->txt("exc_random_selection_info")
322 );
323 if (!$random_manager->canBeActivated() && $this->object->getPassMode() != ilObjExercise::PASS_MODE_RANDOM) {
324 $op3->setDisabled(true);
325 $op3->setInfo($this->lng->txt("exc_random_selection_not_changeable_info") . " " .
326 implode(" ", $random_manager->getDeniedActivationReasons()));
327 }
328 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM && !$random_manager->canBeDeactivated()) {
329 $radg->setDisabled(true);
330 $radg->setInfo($this->lng->txt("exc_pass_mode_not_changeable_info") . " " .
331 implode(" ", $random_manager->getDeniedDeactivationReasons()));
332 }
333 // minimum number of assignments to pass
334 $rn = new ilNumberInputGUI($this->lng->txt("exc_nr_random_mand"), "nr_random_mand");
335 $rn->setSize(4);
336 $rn->setMaxLength(4);
337 $rn->setRequired(true);
338 $rn->setMinValue(1, false);
339 $cnt = ilExAssignment::count($this->object->getId());
340 $rn->setMaxValue($cnt, true);
341 $op3->addSubItem($rn);
342
343 $radg->addOption($op3);
344
345 // minimum number of assignments to pass
346 $ni = new ilNumberInputGUI($this->lng->txt("exc_min_nr"), "pass_nr");
347 $ni->setSize(4);
348 $ni->setMaxLength(4);
349 $ni->setRequired(true);
350 $mand = ilExAssignment::countMandatory($this->object->getId());
351 $min = max($mand, 1);
352 $ni->setMinValue($min, true);
353 $ni->setInfo($this->lng->txt("exc_min_nr_info"));
354 $op2->addSubItem($ni);
355
356 $a_form->addItem($radg);
357
358 // completion by submission
359 $subcompl = new ilRadioGroupInputGUI($this->lng->txt("exc_passed_status_determination"), "completion_by_submission");
360 $op1 = new ilRadioOption($this->lng->txt("exc_completion_by_tutor"), 0, "");
361 $subcompl->addOption($op1);
362 $op2 = new ilRadioOption($this->lng->txt("exc_completion_by_submission"), 1, $this->lng->txt("exc_completion_by_submission_info"));
363 $subcompl->addOption($op2);
364 $a_form->addItem($subcompl);
365
366 /*$subcompl = new ilCheckboxInputGUI($this->lng->txt('exc_completion_by_submission'), 'completion_by_submission');
367 $subcompl->setInfo($this->lng->txt('exc_completion_by_submission_info'));
368 $subcompl->setValue(1);
369 $a_form->addItem($subcompl);*/
370
372 $section->setTitle($this->lng->txt('exc_publishing'));
373 $a_form->addItem($section);
374
375 // show submissions
376 $cb = new ilCheckboxInputGUI($this->lng->txt("exc_show_submissions"), "show_submissions");
377 $cb->setInfo($this->lng->txt("exc_show_submissions_info"));
378 $a_form->addItem($cb);
379
381 $section->setTitle($this->lng->txt('exc_notification'));
382 $a_form->addItem($section);
383
384 // submission notifications
385 $cbox = new ilCheckboxInputGUI($this->lng->txt("exc_submission_notification"), "notification");
386 $cbox->setInfo($this->lng->txt("exc_submission_notification_info"));
387 $a_form->addItem($cbox);
388
389
390 // feedback settings
391
393 $section->setTitle($this->lng->txt('exc_feedback'));
394 $a_form->addItem($section);
395
396 $fdb = new ilCheckboxGroupInputGUI($this->lng->txt("exc_settings_feedback"), "tfeedback");
397 $a_form->addItem($fdb);
398
399 $option = new ilCheckboxOption($this->lng->txt("exc_settings_feedback_mail"), ilObjExercise::TUTOR_FEEDBACK_MAIL);
400 $option->setInfo($this->lng->txt("exc_settings_feedback_mail_info"));
401 $fdb->addOption($option);
402 $option = new ilCheckboxOption($this->lng->txt("exc_settings_feedback_file"), ilObjExercise::TUTOR_FEEDBACK_FILE);
403 $option->setInfo($this->lng->txt("exc_settings_feedback_file_info"));
404 $fdb->addOption($option);
405 $option = new ilCheckboxOption($this->lng->txt("exc_settings_feedback_text"), ilObjExercise::TUTOR_FEEDBACK_TEXT);
406 $option->setInfo($this->lng->txt("exc_settings_feedback_text_info"));
407 $fdb->addOption($option);
408
409 // additional features
411 $section->setTitle($this->lng->txt('obj_features'));
412 $a_form->addItem($section);
413
415
416 $position_settings = ilOrgUnitGlobalSettings::getInstance()
417 ->getObjectPositionSettingsByType($this->object->getType());
418
419 if ($position_settings->isActive()) {
421 }
422
424 $this->object->getId(),
425 $a_form,
426 $features
427 );
428 }
429
433 protected function getEditFormCustomValues(array &$a_values)
434 {
436
437 $a_values["desc"] = $this->object->getLongDescription();
438 $a_values["show_submissions"] = $this->object->getShowSubmissions();
439 $a_values["pass_mode"] = $this->object->getPassMode();
440 if ($a_values["pass_mode"] == "nr") {
441 $a_values["pass_nr"] = $this->object->getPassNr();
442 }
443
444 $a_values["nr_random_mand"] = $this->object->getNrMandatoryRandom();
445
446 $a_values["notification"] = ilNotification::hasNotification(
448 $ilUser->getId(),
449 $this->object->getId()
450 );
451
452 $a_values['completion_by_submission'] = (int) $this->object->isCompletionBySubmissionEnabled();
453
454 $tfeedback = array();
455 if ($this->object->hasTutorFeedbackMail()) {
457 }
458 if ($this->object->hasTutorFeedbackText()) {
460 }
461 if ($this->object->hasTutorFeedbackFile()) {
463 }
464 $a_values['tfeedback'] = $tfeedback;
465
466 // orgunit position setting enabled
467 $a_values['obj_orgunit_positions'] = (bool) ilOrgUnitGlobalSettings::getInstance()
468 ->isPositionAccessActiveForObject($this->object->getId());
469
470 $a_values['cont_custom_md'] = ilContainer::_lookupContainerSetting(
471 $this->object->getId(),
473 false
474 );
475 }
476
477 protected function updateCustom(ilPropertyFormGUI $a_form)
478 {
479 $obj_service = $this->getObjectService();
480
482 $this->object->setShowSubmissions($a_form->getInput("show_submissions"));
483 $this->object->setPassMode($a_form->getInput("pass_mode"));
484 if ($this->object->getPassMode() == "nr") {
485 $this->object->setPassNr($a_form->getInput("pass_nr"));
486 }
487 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
488 $this->object->setNrMandatoryRandom($a_form->getInput("nr_random_mand"));
489 }
490
491 $this->object->setCompletionBySubmission($a_form->getInput('completion_by_submission') == 1 ? true : false);
492
493 $feedback = $a_form->getInput("tfeedback");
494 $this->object->setTutorFeedback(is_array($feedback)
495 ? array_sum($feedback)
496 : null);
497
500 $ilUser->getId(),
501 $this->object->getId(),
502 (bool) $a_form->getInput("notification")
503 );
504
505 // tile image
506 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
507
509 $this->object->getId(),
510 $a_form,
511 array(
514 )
515 );
516 }
517
523 public function addContentSubTabs($a_activate)
524 {
525 $ilTabs = $this->tabs;
528
529 $ilTabs->addSubTab(
530 "content",
531 $lng->txt("view"),
532 $ilCtrl->getLinkTarget($this, "showOverview")
533 );
534 if ($this->checkPermissionBool("write")) {
535 $ilTabs->addSubTab(
536 "list_assignments",
537 $lng->txt("edit"),
538 $ilCtrl->getLinkTargetByClass("ilExAssignmentEditorGUI", "listAssignments")
539 );
540 }
541 $ilTabs->activateSubTab($a_activate);
542 }
543
549 public function getTabs()
550 {
552 $ilHelp = $this->help;
553
554 $ilHelp->setScreenIdComponent("exc");
555
556 if ($this->checkPermissionBool("read")) {
557 $this->tabs_gui->addTab(
558 "content",
559 $lng->txt("exc_assignments"),
560 $this->ctrl->getLinkTarget($this, "showOverview")
561 );
562 }
563
564 $next_class = strtolower($this->ctrl->getNextClass());
565 if ($this->checkPermissionBool("visible") || $this->checkPermissionBool("read")) {
566 $this->tabs_gui->addTab(
567 "info",
568 $lng->txt("info_short"),
569 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
570 );
571 }
572
573 // edit properties
574 if ($this->checkPermissionBool("write")) {
575 /*$tabs_gui->addTab("assignments",
576 $lng->txt("exc_edit_assignments"),
577 $this->ctrl->getLinkTarget($this, 'listAssignments'));*/
578
579 $this->tabs_gui->addTab(
580 "settings",
581 $lng->txt("settings"),
582 $this->ctrl->getLinkTarget($this, 'edit')
583 );
584 }
585 if ($this->access->checkRbacOrPositionPermissionAccess(
586 'edit_submissions_grades',
587 'edit_submissions_grades',
588 $this->object->getRefId()
589 )) {
590 $this->tabs_gui->addTab(
591 "grades",
592 $lng->txt("exc_submissions_and_grades"),
593 $this->ctrl->getLinkTargetByClass("ilexercisemanagementgui", "members")
594 );
595 }
596
597 // learning progress
598 $save_sort_order = $_GET["sort_order"]; // hack, because exercise sort parameters
599 $save_sort_by = $_GET["sort_by"]; // must not be forwarded to learning progress
600 $save_offset = $_GET["offset"];
601 $_GET["offset"] = $_GET["sort_by"] = $_GET["sort_order"] = "";
602
603 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
604 $this->tabs_gui->addTab(
605 'learning_progress',
606 $lng->txt('learning_progress'),
607 $this->ctrl->getLinkTargetByClass(array('ilobjexercisegui','illearningprogressgui'), '')
608 );
609 }
610
611 // meta data
612 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
613 $mdgui = new ilObjectMetaDataGUI($this->object);
614 $mdtab = $mdgui->getTab();
615 if ($mdtab) {
616 $this->tabs_gui->addTarget(
617 "meta_data",
618 $mdtab,
619 "",
620 "ilobjectmetadatagui"
621 );
622 }
623 }
624
625 $_GET["sort_order"] = $save_sort_order; // hack, part ii
626 $_GET["sort_by"] = $save_sort_by;
627 $_GET["offset"] = $save_offset;
628
629 // export
630 if ($this->checkPermissionBool("write")) {
631 $this->tabs_gui->addTab(
632 "export",
633 $lng->txt("export"),
634 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
635 );
636 }
637
638
639 // permissions
640 if ($this->checkPermissionBool("edit_permission")) {
641 $this->tabs_gui->addTab(
642 'permissions',
643 $lng->txt("perm_settings"),
644 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
645 );
646 }
647 }
648
654 public function infoScreenObject()
655 {
656 $this->ctrl->setCmd("showSummary");
657 $this->ctrl->setCmdClass("ilinfoscreengui");
658 $this->infoScreen();
659 }
660
666 protected function getService()
667 {
668 return $this->service;
669 }
670
674 public function infoScreen()
675 {
677 $ilTabs = $this->tabs;
679
680 $ilTabs->activateTab("info");
681
683 $exc = $this->object;
684
685 if (!$this->checkPermissionBool("read")) {
686 $this->checkPermission("visible");
687 }
688
689 $info = new ilInfoScreenGUI($this);
690
691 $info->enablePrivateNotes();
692
693 $info->enableNews();
694 if ($this->checkPermissionBool("write")) {
695 $info->enableNewsEditing();
696 $info->setBlockProperty("news", "settings", true);
697 }
698
699 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'exc', $this->object->getId());
700 $record_gui->setInfoObject($info);
701 $record_gui->parse();
702
703 // standard meta data
704 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
705
706 // instructions
707 $info->addSection($this->lng->txt("exc_overview"));
708 $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId());
709 $cnt = 0;
710 $mcnt = 0;
711 foreach ($ass as $a) {
712 $cnt++;
713 if ($a["mandatory"]) {
714 $mcnt++;
715 }
716 }
717 $info->addProperty($lng->txt("exc_assignments"), $cnt);
718 if ($this->object->getPassMode() == ilObjExercise::PASS_MODE_ALL) {
719 $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
720 $info->addProperty(
721 $lng->txt("exc_pass_mode"),
722 $lng->txt("exc_msg_all_mandatory_ass")
723 );
724 } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_NR) {
725 $info->addProperty($lng->txt("exc_mandatory"), $mcnt);
726 $info->addProperty(
727 $lng->txt("exc_pass_mode"),
728 sprintf($lng->txt("exc_msg_min_number_ass"), $this->object->getPassNr())
729 );
730 } elseif ($this->object->getPassMode() == ilObjExercise::PASS_MODE_RANDOM) {
731 $info->addProperty($lng->txt("exc_mandatory"), $exc->getNrMandatoryRandom());
732 $info->addProperty(
733 $lng->txt("exc_pass_mode"),
734 $lng->txt("exc_msg_all_mandatory_ass")
735 );
736 }
737
738 // feedback from tutor
739 if ($this->checkPermissionBool("read")) {
740 $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
741 $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
742 //$status = ilExerciseMembers::_lookupStatus($this->object->getId(), $ilUser->getId());
743 $st = $this->object->determinStatusOfUser($ilUser->getId());
744 $status = $st["overall_status"];
745 if ($lpcomment != "" || $mark != "" || $status != "notgraded") {
746 $info->addSection($this->lng->txt("exc_feedback_from_tutor"));
747 if ($lpcomment != "") {
748 $info->addProperty(
749 $this->lng->txt("exc_comment"),
750 $lpcomment
751 );
752 }
753 if ($mark != "") {
754 $info->addProperty(
755 $this->lng->txt("exc_mark"),
756 $mark
757 );
758 }
759
760 //if ($status == "")
761 //{
762 // $info->addProperty($this->lng->txt("status"),
763 // $this->lng->txt("message_no_delivered_files"));
764 //}
765 //else
766 if ($status != "notgraded") {
767 $img = '<img src="' . ilUtil::getImagePath("scorm/" . $status . ".svg") . '" ' .
768 ' alt="' . $lng->txt("exc_" . $status) . '" title="' . $lng->txt("exc_" . $status) .
769 '" />';
770
771 $add = "";
772 if ($st["failed_a_mandatory"]) {
773 $add = " (" . $lng->txt("exc_msg_failed_mandatory") . ")";
774 } elseif ($status == "failed") {
775 $add = " (" . $lng->txt("exc_msg_missed_minimum_number") . ")";
776 }
777 $info->addProperty(
778 $this->lng->txt("status"),
779 $img . " " . $this->lng->txt("exc_" . $status) . $add
780 );
781 }
782 }
783 }
784
785 // forward the command
786 $this->ctrl->forwardCommand($info);
787 }
788
789 public function editObject()
790 {
791 $this->setSettingsSubTabs();
792 $this->tabs_gui->activateSubTab("edit");
793 return parent::editObject();
794 }
795
796 protected function setSettingsSubTabs()
797 {
798 $this->tabs_gui->addSubTab(
799 "edit",
800 $this->lng->txt("general_settings"),
801 $this->ctrl->getLinkTarget($this, "edit")
802 );
803
804 $this->tabs_gui->addSubTab(
805 "crit",
806 $this->lng->txt("exc_criteria_catalogues"),
807 $this->ctrl->getLinkTargetByClass("ilexccriteriacataloguegui", "")
808 );
809
810 $validator = new ilCertificateActiveValidator();
811 if (true === $validator->validate()) {
812 $this->tabs_gui->addSubTab(
813 "certificate",
814 $this->lng->txt("certificate"),
815 $this->ctrl->getLinkTarget($this, "certificate")
816 );
817 }
818 }
819
825 public static function _goto($a_target, $a_raw)
826 {
827 global $DIC;
828
829 $ilErr = $DIC["ilErr"];
830 $lng = $DIC->language();
831 $ilAccess = $DIC->access();
832 $ilCtrl = $DIC->ctrl();
833
834 //we don't have baseClass here...
835 $ilCtrl->setTargetScript("ilias.php");
836 $ilCtrl->initBaseClass("ilRepositoryGUI");
837
838 //ilExerciseMailNotification has links to:
839 // "Assignments", "Submission and Grades" and Downnoad the NEW files if the assignment type is "File Upload".
840 $ass_id = $_GET['ass_id'];
841 $parts = explode("_", $a_raw);
842 if (!$ass_id) {
843 $ass_id = null;
844 $action = null;
845
846 switch (end($parts)) {
847 case "download":
848 $action = $parts[3];
849 $member = $parts[2];
850 $ass_id = $parts[1];
851 break;
852
853 case "setdownload":
854 $action = $parts[3];
855 $member = $parts[2];
856 $ass_id = $parts[1];
857 break;
858
859 case "grades":
860 $action = $parts[2];
861 $ass_id = $parts[1];
862 break;
863 }
864 }
865
866 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ref_id", $a_target);
867
868 if ($ilAccess->checkAccess("read", "", $a_target)) {
869 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "target", $a_raw);
870
871 if ($ass_id) {
872 $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "ass_id", $ass_id);
873 }
874
875 switch ($action) {
876 case "grades":
877 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI"), "members");
878 break;
879
880 /*case "download":
881 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "member_id", $member);
882 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI", "ilExSubmissionFileGUI"),"downloadNewReturned");
883 break;*/
884
885 case "setdownload":
886 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "member_id", $member);
887 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI"), "waitingDownload");
888 break;
889
890 default:
891 if ($parts[1] != "") {
892 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ass_id", $parts[1]);
893 $ilCtrl->setParameterByClass("ilExerciseHandlerGUI", "ass_id_goto", $parts[1]);
894 }
895 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI"), "showOverview");
896 break;
897
898 }
899 } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
900 $ilCtrl->redirectByClass(array("ilRepositoryGUI", "ilExerciseHandlerGUI", "ilObjExerciseGUI"), "infoScreen");
901 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
902 ilUtil::sendFailure(sprintf(
903 $lng->txt("msg_no_perm_read_item"),
905 ), true);
907 }
908 }
909
913 public function addLocatorItems()
914 {
915 $ilLocator = $this->locator;
916
917 if (is_object($this->object)) {
918 // #17955
919 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "showOverview"), "", $_GET["ref_id"]);
920 }
921 }
922
923
927
931 public function showOverviewObject()
932 {
934 $ilTabs = $this->tabs;
936 $ilToolbar = $this->toolbar;
937
938 $this->checkPermission("read");
939
940 $ilTabs->activateTab("content");
941 $this->addContentSubTabs("content");
942
943 if ($this->handleRandomAssignmentEntryPage()) {
944 return;
945 }
946
947 $tpl->addJavaScript("./Modules/Exercise/js/ilExcPresentation.js");
948
950 $ilUser->getId(),
951 $this->object->getId(),
952 $this->object->getRefId(),
953 'exc'
954 );
955
956
957 if ($this->certificateDownloadValidator->isCertificateDownloadable((int) $ilUser->getId(), (int) $this->object->getId())) {
958 $ilToolbar->addButton(
959 $this->lng->txt("certificate"),
960 $this->ctrl->getLinkTarget($this, "outCertificate")
961 );
962 }
963
964 $ass_gui = new ilExAssignmentGUI($this->object, $this->getService());
965
966 $acc = new ilAccordionGUI();
967 $acc->setId("exc_ow_" . $this->object->getId());
968
969 $ass_data = ilExAssignment::getInstancesByExercise($this->object->getId());
970 $random_manager = $this->service->getRandomAssignmentManager($this->object);
971 foreach ($ass_data as $ass) {
972 if (!$random_manager->isAssignmentVisible($ass->getId(), $this->user->getId())) {
973 continue;
974 }
975
976 // incoming assignment deeplink
977 $force_open = false;
978 if (isset($_GET["ass_id_goto"]) &&
979 (int) $_GET["ass_id_goto"] == $ass->getId()) {
980 $force_open = true;
981 }
982
983 $acc->addItem(
984 $ass_gui->getOverviewHeader($ass),
985 $ass_gui->getOverviewBody($ass),
986 $force_open
987 );
988 }
989
990 if (count($ass_data) < 2) {
991 $acc->setBehaviour("FirstOpen");
992 } else {
993 $acc->setUseSessionStorage(true);
994 }
995
996 $mtpl = new ilTemplate("tpl.exc_ass_overview.html", true, true, "Modules/Exercise");
997 $mtpl->setVariable("CONTENT", $acc->getHTML());
998
999 $tpl->setContent($mtpl->get());
1000 }
1001
1002 public function certificateObject()
1003 {
1004 $this->setSettingsSubTabs();
1005 $this->tabs_gui->activateTab("settings");
1006 $this->tabs_gui->activateSubTab("certificate");
1007
1008 $guiFactory = new ilCertificateGUIFactory();
1009 $output_gui = $guiFactory->create($this->object);
1010
1011 $output_gui->certificateEditor();
1012 }
1013
1014 public function outCertificateObject()
1015 {
1016 global $DIC;
1017
1018 $database = $DIC->database();
1019 $logger = $DIC->logger()->root();
1020
1022
1023 $objectId = (int) $this->object->getId();
1024
1025 if (false === $this->certificateDownloadValidator->isCertificateDownloadable($ilUser->getId(), $objectId)) {
1026 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
1027 $this->ctrl->redirect($this);
1028 }
1029
1030 $ilUserCertificateRepository = new ilUserCertificateRepository($database, $logger);
1031 $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $logger);
1032
1033 $pdfAction = new ilCertificatePdfAction(
1034 $logger,
1035 $pdfGenerator,
1037 $this->lng->txt('error_creating_certificate_pdf')
1038 );
1039
1040 $pdfAction->downloadPdf((int) $ilUser->getId(), (int) $objectId);
1041 }
1042
1046 public function startAssignmentObject()
1047 {
1048 global $DIC;
1049
1050 $ilCtrl = $DIC->ctrl();
1051 $ilUser = $DIC->user();
1052
1053 if ($this->ass) {
1054 $state = ilExcAssMemberState::getInstanceByIds($this->ass->getId(), $ilUser->getId());
1055 if (!$state->getCommonDeadline() && $state->getRelativeDeadline()) {
1056 $idl = $state->getIndividualDeadlineObject();
1057 $idl->setStartingTimestamp(time());
1058 $idl->save();
1059 }
1060 }
1061
1062 $ilCtrl->redirect($this, "showOverview");
1063 }
1064
1071 {
1072 $service = $this->getService();
1073 $random_manager = $service->getRandomAssignmentManager($this->object);
1074 if ($random_manager->needsStart()) {
1075 $gui = $this->exercise_ui->getRandomAssignmentGUI();
1076 $gui->renderStartPage();
1077 return true;
1078 }
1079
1080 return false;
1081 }
1082}
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 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.
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)
help()
Definition: help.php:2
global $ilCtrl
Definition: ilias.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
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46