ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExAssignmentInfo.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
16  protected $state;
17 
21  protected $ass;
22 
26  protected $user_id;
27 
31  public function __construct(int $ass_id, int $user_id)
32  {
33  global $DIC;
34 
35  $this->state = ilExcAssMemberState::getInstanceByIds($ass_id, $user_id);
36  $this->lng = $DIC->language();
37  $this->ass = new ilExAssignment($ass_id);
38  $this->ctrl = $DIC->ctrl();
39  $this->user_id = $user_id;
40  }
41 
47  public function getInstructionInfo()
48  {
49  if ($this->state->areInstructionsVisible()) {
50  $inst = $this->ass->getInstructionPresentation();
51  if (trim($inst)) {
52  return [
53  "instruction" => [
54  "txt" => $this->lng->txt("exc_instruction"),
55  "value" => $inst
56  ]
57  ];
58  }
59  }
60  return [];
61  }
62 
69  public function getInstructionFileInfo($readable_ref_id = 0)
70  {
71  $ctrl = $this->ctrl;
72  $ass_files = $this->ass->getFiles();
73  if (count($ass_files) > 0) {
74  $items = [];
75 
76  foreach ($ass_files as $file) {
77  $dl_link = "";
78  if ($readable_ref_id > 0) {
79  $ctrl->setParameterByClass("ilExSubmissionGUI", "ref_id", $readable_ref_id);
80  $ctrl->setParameterByClass("ilExSubmissionGUI", "ass_id", $this->ass->getId());
81  $ctrl->setParameterByClass("ilExSubmissionGUI", "file", urlencode($file["name"]));
82  $dl_link = $ctrl->getLinkTargetByClass([
83  "ilExerciseHandlerGUI",
84  "ilObjExerciseGUI",
85  "ilExSubmissionGUI"
86  ], "downloadFile");
87  $ctrl->clearParametersByClass("ilExSubmissionGUI");
88  }
89  $items[] = [
90  "txt" => $file["name"],
91  "value" => $dl_link
92  ];
93  }
94  }
95  return $items;
96  }
97 
98 
105  public function getScheduleInfo()
106  {
107  $lng = $this->lng;
108  $ret = [];
110 
111  if ($state->getGeneralStart() > 0) {
112  if ($state->getRelativeDeadline()) {
113  $txt = $lng->txt("exc_earliest_start_time");
114  } else {
115  $txt = $lng->txt("exc_start_time");
116  }
117  $ret["start_time"] = [
118  "txt" => $txt,
119  "value" => $state->getGeneralStartPresentation()
120  ];
121  }
122 
123  // extended deadline info/warning
124  $late_dl = "";
125  if ($state->inLateSubmissionPhase()) {
126  // extended deadline date should not be presented anywhere
127  $late_dl = $state->getOfficialDeadlinePresentation();
128  $late_dl = "<br />" . sprintf($lng->txt("exc_late_submission_warning"), $late_dl);
129  $late_dl = '<span class="warning">' . $late_dl . '</span>';
130  }
131 
132  if ($state->getCommonDeadline()) { // if we have a common deadline (target timestamp)
133  $until = $state->getCommonDeadlinePresentation();
134 
135  // add late info if no idl
136  if ($late_dl &&
137  $state->getOfficialDeadline() == $state->getCommonDeadline()) {
138  $until .= $late_dl;
139  }
140 
141  $prop = $lng->txt("exc_edit_until");
142  if ($state->exceededOfficialDeadline()) {
143  $prop = $lng->txt("exc_ended_on");
144  }
145 
146  $ret["until"] = ["txt" => $prop, "value" => $until];
147  } elseif ($state->getRelativeDeadline()) { // if we only have a relative deadline (not started yet)
148  $ret["time_after_start"] = ["txt" => $lng->txt("exc_rem_time_after_start"), "value" => $state->getRelativeDeadlinePresentation()];
149  }
150 
151  if ($state->getOfficialDeadline() > $state->getCommonDeadline()) {
152  $until = $state->getOfficialDeadlinePresentation();
153 
154  // add late info?
155  if ($late_dl) {
156  $until .= $late_dl;
157  }
158 
159  $ret["individual_deadline"] = ["txt" => $lng->txt("exc_individual_deadline"), "value" => $until];
160  }
161 
162  if ($state->hasSubmissionStarted()) {
163  $ret["time_to_send"] = ["txt" => $lng->txt("exc_time_to_send"), "value" => "<b>" . $state->getRemainingTimePresentation() . "</b>"];
164  }
165  return $ret;
166  }
167 
173  public function getSubmissionInfo()
174  {
175  // submitted files
176  $submission = new ilExSubmission($this->ass, $this->user_id);
177  $ret = [];
178  if ($submission->hasSubmitted()) {
179  // #16888
180  $submitted = $submission->getSelectedObject();
181  if ($submitted["ts"] != "") {
182  $ret["submitted"] = [
183  "txt" => $this->lng->txt("exc_last_submission"),
184  "value" => ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME))
185  ];
186  }
187  }
188  return $ret;
189  }
190 }
Exercise assignment.
const IL_CAL_DATETIME
getInstructionFileInfo($readable_ref_id=0)
Get instruction file info.
__construct(int $ass_id, int $user_id)
Constructor.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static getInstanceByIds($a_ass_id, $a_user_id=0)
Get instance by IDs (recommended for consumer code)
getSubmissionInfo()
Get submission info.
$lng
global $DIC
Definition: goto.php:24
$txt
Definition: error.php:13
getInstructionInfo()
Get instruction info.
$ret
Definition: parser.php:6
Exercise submission //TODO: This class has to much static methods related to delivered "files"...