ILIAS  release_8 Revision v8.24
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
37 $this->state = ilExcAssMemberState::getInstanceByIds($ass_id, $user_id);
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 "ilExSubmissionGUI"
76 ], "downloadFile");
77 $ctrl->clearParametersByClass("ilExSubmissionGUI");
78 }
79 $items[] = [
80 "txt" => $file["name"],
81 "value" => $dl_link
82 ];
83 }
84 }
85 return $items;
86 }
87
91 public function getScheduleInfo(): array
92 {
94 $ret = [];
96
97 if ($state->getGeneralStart() > 0) {
99 $txt = $lng->txt("exc_earliest_start_time");
100 } else {
101 $txt = $lng->txt("exc_start_time");
102 }
103 $ret["start_time"] = [
104 "txt" => $txt,
106 ];
107 }
108
109 // extended deadline info/warning
110 $late_dl = "";
112 // extended deadline date should not be presented anywhere
114 $late_dl = "<br />" . sprintf($lng->txt("exc_late_submission_warning"), $late_dl);
115 $late_dl = '<span class="warning">' . $late_dl . '</span>';
116 }
117
118 if ($state->getCommonDeadline()) { // if we have a common deadline (target timestamp)
120
121 // add late info if no idl
122 if ($late_dl &&
124 $until .= $late_dl;
125 }
126
127 $prop = $lng->txt("exc_edit_until");
129 $prop = $lng->txt("exc_ended_on");
130 }
131
132 $ret["until"] = ["txt" => $prop, "value" => $until];
133 } elseif ($state->getRelativeDeadline()) { // if we only have a relative deadline (not started yet)
134 $ret["time_after_start"] = ["txt" => $lng->txt("exc_rem_time_after_start"), "value" => $state->getRelativeDeadlinePresentation()];
135 }
136
139
140 // add late info?
141 if ($late_dl) {
142 $until .= $late_dl;
143 }
144
145 $ret["individual_deadline"] = ["txt" => $lng->txt("exc_individual_deadline"), "value" => $until];
146 }
147
149 $ret["time_to_send"] = ["txt" => $lng->txt("exc_time_to_send"), "value" => "<b>" . $state->getRemainingTimePresentation() . "</b>"];
150 }
151 return $ret;
152 }
153
157 public function getSubmissionInfo(): array
158 {
159 // submitted files
160 $submission = new ilExSubmission($this->ass, $this->user_id);
161 $ret = [];
162 if ($submission->hasSubmitted()) {
163 // #16888
164 $submitted = $submission->getSelectedObject();
165 if ($submitted["ts"] != "") {
166 $ret["submitted"] = [
167 "txt" => $this->lng->txt("exc_last_submission"),
168 "value" => ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME))
169 ];
170 }
171 }
172 return $ret;
173 }
174}
const IL_CAL_DATETIME
Class ilCtrl provides processing control methods.
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
clearParametersByClass(string $a_class)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@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.
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...
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:13
global $DIC
Definition: feed.php:28