ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilExAssignmentInfo.php
Go to the documentation of this file.
1 <?php
2 
23 {
25  protected ilExAssignment $ass;
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  {
62  $ctrl = $this->ctrl;
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  {
94  $lng = $this->lng;
95  $ret = [];
96  $state = $this->state;
97 
98  if ($state->getGeneralStart() > 0) {
99  if ($state->getRelativeDeadline()) {
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,
106  "value" => $state->getGeneralStartPresentation()
107  ];
108  }
109 
110  // extended deadline info/warning
111  $late_dl = "";
112  if ($state->inLateSubmissionPhase()) {
113  // extended deadline date should not be presented anywhere
114  $late_dl = $state->getOfficialDeadlinePresentation();
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)
120  $until = $state->getCommonDeadlinePresentation();
121 
122  // add late info if no idl
123  if ($late_dl &&
124  $state->getOfficialDeadline() == $state->getCommonDeadline()) {
125  $until .= $late_dl;
126  }
127 
128  $prop = $lng->txt("exc_edit_until");
129  if ($state->exceededOfficialDeadline()) {
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 
138  if ($state->getOfficialDeadline() > $state->getCommonDeadline()) {
139  $until = $state->getOfficialDeadlinePresentation();
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 
149  if ($state->hasSubmissionStarted()) {
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 }
Exercise assignment.
const IL_CAL_DATETIME
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...
setParameterByClass(string $a_class, string $a_parameter, $a_value)
__construct(int $ass_id, int $user_id)
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...
hasSubmissionStarted()
Check if the submission phase has started for the current user (if the assignment is generally starte...
getInstructionFileInfo(int $readable_ref_id=0)
global $DIC
Definition: shib_login.php:22
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
clearParametersByClass(string $a_class)
ilExcAssMemberState $state
$txt
Definition: error.php:31
getRemainingTimePresentation()
Remaining time presentation (based on official deadline)
getOfficialDeadline()
Get official deadline (individual deadline, fixed deadline or calculated deadline (using relative dea...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Exercise submission //TODO: This class has many static methods related to delivered "files"...
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)