ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExAssignmentInfo.php
Go to the documentation of this file.
1<?php
2
23{
26 protected int $user_id;
27 protected ilLanguage $lng;
28 protected ilCtrl $ctrl;
29
33 public function __construct(int $ass_id, int $user_id)
34 {
35 global $DIC;
36
38 $this->lng = $DIC->language();
39 $this->ass = new ilExAssignment($ass_id);
40 $this->ctrl = $DIC->ctrl();
41 $this->user_id = $user_id;
42 }
43
44 public function getInstructionInfo(): array
45 {
46 if ($this->state->areInstructionsVisible()) {
47 $inst = $this->ass->getInstructionPresentation();
48 if (trim($inst)) {
49 return [
50 "instruction" => [
51 "txt" => $this->lng->txt("exc_instruction"),
52 "value" => $inst
53 ]
54 ];
55 }
56 }
57 return [];
58 }
59
60 public function getInstructionFileInfo(int $readable_ref_id = 0): array
61 {
63 $ass_files = $this->ass->getFiles();
64 $items = [];
65 if (count($ass_files) > 0) {
66 foreach ($ass_files as $file) {
67 $dl_link = "";
68 if ($readable_ref_id > 0) {
69 $ctrl->setParameterByClass("ilExSubmissionGUI", "ref_id", $readable_ref_id);
70 $ctrl->setParameterByClass("ilExSubmissionGUI", "ass_id", $this->ass->getId());
71 $ctrl->setParameterByClass("ilExSubmissionGUI", "file", urlencode($file["name"]));
72 $dl_link = $ctrl->getLinkTargetByClass([
73 "ilExerciseHandlerGUI",
74 "ilObjExerciseGUI",
75 \ilAssignmentPresentationGUI::class,
76 "ilExSubmissionGUI"
77 ], "downloadFile");
78 $ctrl->clearParametersByClass("ilExSubmissionGUI");
79 }
80 $items[] = [
81 "txt" => $file["name"],
82 "value" => $dl_link
83 ];
84 }
85 }
86 return $items;
87 }
88
92 public function getScheduleInfo(): array
93 {
95 $ret = [];
97
98 if ($state->getGeneralStart() > 0) {
100 $txt = $lng->txt("exc_earliest_start_time");
101 } else {
102 $txt = $lng->txt("exc_start_time");
103 }
104 $ret["start_time"] = [
105 "txt" => $txt,
107 ];
108 }
109
110 // extended deadline info/warning
111 $late_dl = "";
113 // extended deadline date should not be presented anywhere
115 $late_dl = "<br />" . sprintf($lng->txt("exc_late_submission_warning"), $late_dl);
116 $late_dl = '<span class="warning">' . $late_dl . '</span>';
117 }
118
119 if ($state->getCommonDeadline()) { // if we have a common deadline (target timestamp)
121
122 // add late info if no idl
123 if ($late_dl &&
125 $until .= $late_dl;
126 }
127
128 $prop = $lng->txt("exc_edit_until");
130 $prop = $lng->txt("exc_ended_on");
131 }
132
133 $ret["until"] = ["txt" => $prop, "value" => $until];
134 } elseif ($state->getRelativeDeadline()) { // if we only have a relative deadline (not started yet)
135 $ret["time_after_start"] = ["txt" => $lng->txt("exc_rem_time_after_start"), "value" => $state->getRelativeDeadlinePresentation()];
136 }
137
140
141 // add late info?
142 if ($late_dl) {
143 $until .= $late_dl;
144 }
145
146 $ret["individual_deadline"] = ["txt" => $lng->txt("exc_individual_deadline"), "value" => $until];
147 }
148
150 $ret["time_to_send"] = ["txt" => $lng->txt("exc_time_to_send"), "value" => "<strong>" . $state->getRemainingTimePresentation() . "</strong>"];
151 }
152 return $ret;
153 }
154
158 public function getSubmissionInfo(): array
159 {
160 // submitted files
161 $submission = new ilExSubmission($this->ass, $this->user_id);
162 $ret = [];
163 if ($submission->hasSubmitted()) {
164 // #16888
165 $submitted = $submission->getSelectedObject();
166 if ($submitted?->getTimestamp() !== "") {
167 $ret["submitted"] = [
168 "txt" => $this->lng->txt("exc_last_submission"),
169 "value" => ilDatePresentation::formatDate(new ilDateTime($submitted?->getTimestamp(), IL_CAL_DATETIME))
170 ];
171 }
172 }
173 return $ret;
174 }
175}
const IL_CAL_DATETIME
Class ilCtrl provides processing control methods.
clearParametersByClass(string $a_class)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getInstructionFileInfo(int $readable_ref_id=0)
ilExcAssMemberState $state
__construct(int $ass_id, int $user_id)
Exercise assignment.
Exercise submission //TODO: This class has many static methods related to delivered "files".
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
getOfficialDeadline()
Get official deadline (individual deadline, fixed deadline or calculated deadline (using relative dea...
getRemainingTimePresentation()
Remaining time presentation (based on official deadline)
hasSubmissionStarted()
Check if the submission phase has started for the current user (if the assignment is generally starte...
language handling
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...
$txt
Definition: error.php:31
global $DIC
Definition: shib_login.php:26