ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilExAssignmentGUI.php
Go to the documentation of this file.
1 <?php
2 
12 {
13  protected $exc; // [ilObjExercise]
14  protected $current_ass_id; // [int]
15 
19  function __construct(ilObjExercise $a_exc)
20  {
21  $this->exc = $a_exc;
22  }
23 
28  {
29  global $lng, $ilUser;
30 
31  $lng->loadLanguageModule("exc");
32 
33  $tpl = new ilTemplate("tpl.assignment_head.html", true, true, "Modules/Exercise");
34 
35  // we are completely ignoring the extended deadline here
36 
37  $idl = $a_ass->getPersonalDeadline($ilUser->getId());
38 
39  // :TODO: meaning of "ended on"
40  $dl = max($a_ass->getDeadline(), $idl);
41  if ($dl &&
42  $dl < time())
43  {
44  $tpl->setCurrentBlock("prop");
45  $tpl->setVariable("PROP", $lng->txt("exc_ended_on"));
46  $tpl->setVariable("PROP_VAL",
48  $tpl->parseCurrentBlock();
49 
50  // #14077
51  if($a_ass->getPeerReview() &&
52  $a_ass->getPeerReviewDeadline())
53  {
54  $tpl->setCurrentBlock("prop");
55  $tpl->setVariable("PROP", $lng->txt("exc_peer_review_deadline"));
56  $tpl->setVariable("PROP_VAL",
58  $tpl->parseCurrentBlock();
59  }
60  }
61  else if ($a_ass->notStartedYet())
62  {
63  $tpl->setCurrentBlock("prop");
64  $tpl->setVariable("PROP", $lng->txt("exc_starting_on"));
65  $tpl->setVariable("PROP_VAL",
67  $tpl->parseCurrentBlock();
68  }
69  else
70  {
71  $time_str = $this->getTimeString($idl);
72  $tpl->setCurrentBlock("prop");
73  $tpl->setVariable("PROP", $lng->txt("exc_time_to_send"));
74  $tpl->setVariable("PROP_VAL", $time_str);
75  $tpl->parseCurrentBlock();
76 
77  if ($a_ass->getDeadline())
78  {
79  $tpl->setCurrentBlock("prop");
80  $tpl->setVariable("PROP", $lng->txt("exc_edit_until"));
81  $tpl->setVariable("PROP_VAL",
83  $tpl->parseCurrentBlock();
84  }
85 
86  if ($idl && $idl != $a_ass->getDeadline())
87  {
88  $tpl->setCurrentBlock("prop");
89  $tpl->setVariable("PROP", $lng->txt("exc_individual_deadline"));
90  $tpl->setVariable("PROP_VAL",
92  $tpl->parseCurrentBlock();
93  }
94  }
95 
96  $mand = "";
97  if ($a_ass->getMandatory())
98  {
99  $mand = " (".$lng->txt("exc_mandatory").")";
100  }
101  $tpl->setVariable("TITLE", $a_ass->getTitle().$mand);
102 
103  // status icon
104  $stat = $a_ass->getMemberStatus()->getStatus();
105  $pic = $a_ass->getMemberStatus()->getStatusIcon();
106  $tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
107  $tpl->setVariable("ALT_STATUS", $lng->txt("exc_".$stat));
108 
109  return $tpl->get();
110  }
111 
116  {
117  $this->current_ass_id = $a_ass->getId();
118 
119  $tpl = new ilTemplate("tpl.assignment_body.html", true, true, "Modules/Exercise");
120 
121  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
122  include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
123 
124  $info = new ilInfoScreenGUI(null);
125  $info->setTableClass("");
126 
127  $this->addInstructions($info, $a_ass);
128  $this->addSchedule($info, $a_ass);
129 
130  if ($this->exc->getShowSubmissions())
131  {
132  $this->addPublicSubmissions($info, $a_ass);
133  }
134 
135  if (!$a_ass->notStartedYet())
136  {
137  $this->addFiles($info, $a_ass);
138  $this->addSubmission($info, $a_ass);
139  }
140 
141  $tpl->setVariable("CONTENT", $info->getHTML());
142 
143  return $tpl->get();
144  }
145 
146 
147  protected function addInstructions(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
148  {
149  global $lng;
150 
151  if (!$a_ass->notStartedYet())
152  {
153  $inst = $a_ass->getInstruction();
154  if(trim($inst))
155  {
156  $a_info->addSection($lng->txt("exc_instruction"));
157 
158  $is_html = (strlen($inst) != strlen(strip_tags($inst)));
159  if(!$is_html)
160  {
161  $inst = nl2br(ilUtil::makeClickable($inst, true));
162  }
163  $a_info->addProperty("", $inst);
164  }
165  }
166  }
167 
168  protected function addSchedule(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
169  {
170  global $lng, $ilUser;
171 
172  $idl = $a_ass->getPersonalDeadline($ilUser->getId());
173 
174  $a_info->addSection($lng->txt("exc_schedule"));
175  if ($a_ass->getStartTime() > 0)
176  {
177  $a_info->addProperty($lng->txt("exc_start_time"),
179  }
180 
181  // extended deadline info/warning
182  $late_dl = "";
183  if ($idl &&
184  $idl < time() &&
185  $a_ass->beforeDeadline()) // ext dl is last deadline
186  {
187  // extended deadline date should not be presented anywhere
189  $late_dl = "<br />".sprintf($lng->txt("exc_late_submission_warning"), $late_dl);
190  $late_dl = '<span class="warning">'.$late_dl.'</span>';
191  }
192 
193  if ($a_ass->getDeadline())
194  {
196 
197  // add late info if no idl
198  if ($late_dl &&
199  $idl == $a_ass->getDeadline())
200  {
201  $until .= $late_dl;
202  }
203 
204  $a_info->addProperty($lng->txt("exc_edit_until"), $until);
205  }
206 
207  if ($idl &&
208  $idl != $a_ass->getDeadline())
209  {
211 
212  // add late info?
213  if ($late_dl)
214  {
215  $until .= $late_dl;
216  }
217 
218  $a_info->addProperty($lng->txt("exc_individual_deadline"), $until);
219  }
220 
221  if (!$a_ass->notStartedYet())
222  {
223  $a_info->addProperty($lng->txt("exc_time_to_send"),
224  "<b>".$this->getTimeString($idl)."</b>");
225  }
226  }
227 
228  protected function addPublicSubmissions(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
229  {
230  global $lng;
231 
232  if ($a_ass->afterDeadline())
233  {
234  $button = ilLinkButton::getInstance();
235  $button->setCaption("exc_list_submission");
236  $button->setUrl($this->getSubmissionLink("listPublicSubmissions"));
237 
238  $a_info->addProperty($lng->txt("exc_public_submission"), $button->render());
239  }
240  else
241  {
242  $a_info->addProperty($lng->txt("exc_public_submission"),
243  $lng->txt("exc_msg_public_submission"));
244  }
245  }
246 
247  protected function addFiles(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
248  {
249  global $lng, $ilCtrl;
250 
251  $files = $a_ass->getFiles();
252  if (count($files) > 0)
253  {
254  $a_info->addSection($lng->txt("exc_files"));
255  foreach($files as $file)
256  {
257  $a_info->addProperty($file["name"], $lng->txt("download"), $this->getSubmissionLink("downloadFile", array("file"=>urlencode($file["name"]))));
258  }
259  }
260  }
261 
262  protected function addSubmission(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
263  {
264  global $lng, $ilCtrl, $ilUser;
265 
266  $a_info->addSection($lng->txt("exc_your_submission"));
267 
268  include_once "Modules/Exercise/classes/class.ilExSubmission.php";
269  $submission = new ilExSubmission($a_ass, $ilUser->getId());
270 
271  include_once "Modules/Exercise/classes/class.ilExSubmissionGUI.php";
272  ilExSubmissionGUI::getOverviewContent($a_info, $submission);
273 
274  $last_sub = null;
275  if($submission->hasSubmitted())
276  {
277  $last_sub = $submission->getLastSubmission();
278  if($last_sub)
279  {
280  $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub,IL_CAL_DATETIME));
281  $a_info->addProperty($lng->txt("exc_last_submission"), $last_sub);
282  }
283  }
284 
285  include_once "Modules/Exercise/classes/class.ilExPeerReviewGUI.php";
286  ilExPeerReviewGUI::getOverviewContent($a_info, $submission);
287 
288  // global feedback / sample solution
290  {
291  $show_global_feedback = ($a_ass->afterDeadlineStrict() && $a_ass->getFeedbackFile());
292  }
293  else
294  {
295  $show_global_feedback = ($last_sub && $a_ass->getFeedbackFile());
296  }
297 
298  $this->addSubmissionFeedback($a_info, $a_ass, $submission->getFeedbackId(), $show_global_feedback);
299  }
300 
301  protected function addSubmissionFeedback(ilInfoScreenGUI $a_info, ilExAssignment $a_ass, $a_feedback_id, $a_show_global_feedback)
302  {
303  global $lng;
304 
305  $storage = new ilFSStorageExercise($a_ass->getExerciseId(), $a_ass->getId());
306  $cnt_files = $storage->countFeedbackFiles($a_feedback_id);
307 
308  $lpcomment = $a_ass->getMemberStatus()->getComment();
309  $mark = $a_ass->getMemberStatus()->getMark();
310  $status = $a_ass->getMemberStatus()->getStatus();
311 
312  if ($lpcomment != "" ||
313  $mark != "" ||
314  $status != "notgraded" ||
315  $cnt_files > 0 ||
316  $a_show_global_feedback)
317  {
318  $a_info->addSection($lng->txt("exc_feedback_from_tutor"));
319  if ($lpcomment != "")
320  {
321  $a_info->addProperty($lng->txt("exc_comment"),
322  nl2br($lpcomment));
323  }
324  if ($mark != "")
325  {
326  $a_info->addProperty($lng->txt("exc_mark"),
327  $mark);
328  }
329 
330  if ($status == "")
331  {
332 // $a_info->addProperty($lng->txt("status"),
333 // $lng->txt("message_no_delivered_files"));
334  }
335  else if ($status != "notgraded")
336  {
337  $img = '<img src="'.ilUtil::getImagePath("scorm/".$status.".svg").'" '.
338  ' alt="'.$lng->txt("exc_".$status).'" title="'.$lng->txt("exc_".$status).
339  '" />';
340  $a_info->addProperty($lng->txt("status"),
341  $img." ".$lng->txt("exc_".$status));
342  }
343 
344  if ($cnt_files > 0)
345  {
346  $a_info->addSection($lng->txt("exc_fb_files").
347  '<a name="fb'.$a_ass->getId().'"></a>');
348 
349  if($cnt_files > 0)
350  {
351  $files = $storage->getFeedbackFiles($a_feedback_id);
352  foreach($files as $file)
353  {
354  $a_info->addProperty($file,
355  $lng->txt("download"),
356  $this->getSubmissionLink("downloadFeedbackFile", array("file"=>urlencode($file))));
357  }
358  }
359  }
360 
361  // #15002 - global feedback
362  if($a_show_global_feedback)
363  {
364  $a_info->addSection($lng->txt("exc_global_feedback_file"));
365 
366  $a_info->addProperty($a_ass->getFeedbackFile(),
367  $lng->txt("download"),
368  $this->getSubmissionLink("downloadGlobalFeedbackFile"));
369  }
370  }
371  }
372 
376  function getTimeString($a_deadline)
377  {
378  global $lng;
379 
380  if ($a_deadline == 0)
381  {
382  return $lng->txt("exc_no_deadline_specified");
383  }
384 
385  if ($a_deadline - time() <= 0)
386  {
387  $time_str = $lng->txt("exc_time_over_short");
388  }
389  else
390  {
391  $time_str = ilUtil::period2String(new ilDateTime($a_deadline, IL_CAL_UNIX));
392  }
393 
394  return $time_str;
395  }
396 
397  protected function getSubmissionLink($a_cmd, array $a_params = null)
398  {
399  global $ilCtrl;
400 
401  if(is_array($a_params))
402  {
403  foreach($a_params as $name => $value)
404  {
405  $ilCtrl->setParameterByClass("ilexsubmissiongui", $name, $value);
406  }
407  }
408 
409  $ilCtrl->setParameterByClass("ilexsubmissiongui", "ass_id", $this->current_ass_id);
410  $url = $ilCtrl->getLinkTargetByClass("ilexsubmissiongui", $a_cmd);
411  $ilCtrl->setParameterByClass("ilexsubmissiongui", "ass_id", "");
412 
413  if(is_array($a_params))
414  {
415  foreach($a_params as $name => $value)
416  {
417  $ilCtrl->setParameterByClass("ilexsubmissiongui", $name, "");
418  }
419  }
420 
421  return $url;
422  }
423 }
$files
Definition: add-vimline.php:18
getPeerReview()
Get peer review status.
addSubmissionFeedback(ilInfoScreenGUI $a_info, ilExAssignment $a_ass, $a_feedback_id, $a_show_global_feedback)
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
getMemberStatus($a_user_id=null)
getPersonalDeadline($a_user_id)
Get individual deadline.
Class ilInfoScreenGUI.
Exercise assignment.
const IL_CAL_DATETIME
addPublicSubmissions(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
getFeedbackDate()
Get (global) feedback file availability date.
getStartTime()
Get start time (timestamp)
getId()
Get assignment id.
getDeadline()
Get deadline (timestamp)
addInstructions(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
addSection($a_title)
add a new section
$url
Definition: shib_logout.php:72
addSchedule(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
const IL_CAL_UNIX
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
GUI class for exercise assignments.
$info
Definition: example_052.php:80
getExerciseId()
Get exercise id.
Class ilObjExercise.
getOverviewBody(ilExAssignment $a_ass)
Get assignment body for overview.
getTimeString($a_deadline)
Get time string for deadline.
addFiles(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
special template class to simplify handling of ITX/PEAR
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
$ilUser
Definition: imgupload.php:18
getFeedbackFile()
Get (global) feedback file.
Create styles array
The data for the language used.
__construct(ilObjExercise $a_exc)
Constructor.
getMandatory()
Get mandatory.
getOverviewHeader(ilExAssignment $a_ass)
Get assignment header for overview.
afterDeadlineStrict($a_include_personal=true)
addProperty($a_name, $a_value, $a_link="")
add a property to current section
getInstruction()
Get instruction.
addSubmission(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
static getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmission $a_submission)
global $lng
Definition: privfeed.php:17
getPeerReviewDeadline()
Get peer review deadline (timestamp)
Exercise submission.
countFeedbackFiles($a_user_id)
Count number of feedback files for a user.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
getSubmissionLink($a_cmd, array $a_params=null)