ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAppointmentPresentationExerciseGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 public function collectPropertiesAndActions(): void
30 {
31 global $DIC;
32
33 $this->lng->loadLanguageModule("exc");
34
35 $f = $DIC->ui()->factory();
36 $r = $DIC->ui()->renderer();
37
38 $a_app = $this->appointment;
39 $exc_obj = new ilObjExercise($this->getObjIdForAppointment(), false);
40 //is this safe?
41
42 $refs = $this->getReadableRefIds($this->getObjIdForAppointment());
43 $exc_ref = current($refs);
44
45 // common section: title, location, parent info
46 $this->addCommonSection($a_app, $this->getObjIdForAppointment(), null, true);
47
48 //Assignment title information
49 $this->addInfoSection($this->lng->txt("cal_exc_info"));
50
51 //var_dump($a_app); exit;
52 $ass_id = $a_app["event"]->getContextId() / 10; // see ilExAssignment->handleCalendarEntries $dl parameter
53 $assignment = new ilExAssignment($ass_id);
54 $state = ilExcAssMemberState::getInstanceByIds($assignment->getId(), $this->user->getId());
55 if ($state->areInstructionsVisible()) {
56 $assignment_instructions = trim($assignment->getInstruction());
57 if ($assignment_instructions != "") {
58 #21517
59 $is_html = (strlen($assignment_instructions) != strlen(strip_tags($assignment_instructions)));
60 if (!$is_html) {
61 $assignment_instructions = nl2br($assignment_instructions);
62 }
63 $this->addInfoProperty($this->lng->txt("exc_instruction"), $assignment_instructions);
64 }
65 $files = $assignment->getFiles();
66 if (count($files) > 0) {
67 $this->has_files = true;
68 $str_files = array();
69 foreach ($files as $file) {
70 $this->ctrl->setParameterByClass("ilexsubmissiongui", "ref_id", $exc_ref);
71 $this->ctrl->setParameterByClass("ilexsubmissiongui", "file", urlencode($file["name"]));
72 $this->ctrl->setParameterByClass("ilexsubmissiongui", "ass_id", $ass_id);
73 $url = $this->ctrl->getLinkTargetByClass(array("ilExerciseHandlerGUI",
74 "ilobjexercisegui",
75 ilAssignmentPresentationGUI::class, ilExSubmissionGUI::class
76 ), "downloadFile");
77 $this->ctrl->setParameterByClass("ilexsubmissiongui", "ass_id", "");
78 $this->ctrl->setParameterByClass("ilexsubmissiongui", "file", "");
79 $this->ctrl->setParameterByClass("ilexsubmissiongui", "ref_if", "");
80 $str_files[$file["name"]] = $r->render($f->button()->shy($file["name"], $url));
81 }
82 ksort($str_files, SORT_NATURAL | SORT_FLAG_CASE);
83 $str_files = implode("<br>", $str_files);
84 $this->addInfoProperty($this->lng->txt("exc_instruction_files"), $str_files);
86 $this->lng->txt("exc_instruction_files"),
87 str_replace("<br>", ", ", $str_files)
88 );
89 }
90 }
91
92 //pass mode
93 if ($assignment->getMandatory()) {
94 $this->addInfoProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("yes"));
95 $this->addListItemProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("yes"));
96 } else {
97 $this->addInfoProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("no"));
98 $this->addListItemProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("no"));
99 }
100
101 // last edited
102 $this->addLastUpdate($a_app);
103
104 //go to the exercise.
105 $this->addAction(
106 $this->lng->txt("cal_exc_open"),
107 "goto.php?target=exc_" . $exc_ref . "_" . $ass_id . "&client_id=" . CLIENT_ID
108 );
109 }
110
114 protected function buildDirectLinkForAppointment(int $a_ref_id, ?array $a_appointment = null): string
115 {
116 $ass_id = 0;
117 if (is_array($a_appointment)) {
118 $ass_id = $a_appointment["event"]->getContextId() / 10;
119 }
120 if (!$ass_id) {
121 return parent::buildDirectLinkForAppointment($a_ref_id, $a_appointment);
122 }
123 return ilLink::_getLink(
124 $a_ref_id,
125 'exc',
126 [],
127 '_' . $ass_id
128 );
129 }
130}
buildDirectLinkForAppointment(int $a_ref_id, ?array $a_appointment=null)
Build direct link for appointment.
addInfoProperty(string $a_txt, string $a_val)
Add info property.
addCommonSection(array $a_app, int $a_obj_id=0, ?array $cat_info=null, bool $a_container_info=false)
addAction(string $a_txt, string $a_link)
Add action.
addInfoSection(string $a_txt)
Add info section.
addListItemProperty(string $a_txt, string $a_val)
Add list item property.
Exercise assignment.
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
Class ilObjExercise.
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68