ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExAssignmentGUI.php
Go to the documentation of this file.
1 <?php
2 
11 {
12 
16  function __construct($a_exc)
17  {
18  $this->exc = $a_exc;
19  }
20 
21 
25  function getOverviewHeader($a_data)
26  {
27  global $lng, $ilUser;
28 
29  $tpl = new ilTemplate("tpl.assignment_head.html", true, true, "Modules/Exercise");
30 
31  if ($a_data["deadline"] - time() <= 0)
32  {
33  $tpl->setCurrentBlock("prop");
34  $tpl->setVariable("PROP", $lng->txt("exc_ended_on"));
35  $tpl->setVariable("PROP_VAL",
36  ilDatePresentation::formatDate(new ilDateTime($a_data["deadline"],IL_CAL_UNIX)));
37  $tpl->parseCurrentBlock();
38  }
39  else if ($a_data["start_time"] > 0 && time() - $a_data["start_time"] <= 0)
40  {
41  $tpl->setCurrentBlock("prop");
42  $tpl->setVariable("PROP", $lng->txt("exc_starting_on"));
43  $tpl->setVariable("PROP_VAL",
44  ilDatePresentation::formatDate(new ilDateTime($a_data["start_time"],IL_CAL_UNIX)));
45  $tpl->parseCurrentBlock();
46  }
47  else
48  {
49  $time_str = $this->getTimeString($a_data["deadline"]);
50  $tpl->setCurrentBlock("prop");
51  $tpl->setVariable("PROP", $lng->txt("exc_time_to_send"));
52  $tpl->setVariable("PROP_VAL", $time_str);
53  $tpl->parseCurrentBlock();
54 
55  $tpl->setCurrentBlock("prop");
56  $tpl->setVariable("PROP", $lng->txt("exc_edit_until"));
57  $tpl->setVariable("PROP_VAL",
58  ilDatePresentation::formatDate(new ilDateTime($a_data["deadline"],IL_CAL_UNIX)));
59  $tpl->parseCurrentBlock();
60 
61  }
62 
63  $mand = "";
64  if ($a_data["mandatory"])
65  {
66  $mand = " (".$lng->txt("exc_mandatory").")";
67  }
68  $tpl->setVariable("TITLE", $a_data["title"].$mand);
69  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("accordion_arrow.gif"));
70 
71  // status icon
72  $stat = ilExAssignment::lookupStatusOfUser($a_data["id"], $ilUser->getId());
73  switch ($stat)
74  {
75  case "passed": $pic = "scorm/passed.gif"; break;
76  case "failed": $pic = "scorm/failed.gif"; break;
77  default: $pic = "scorm/not_attempted.gif"; break;
78  }
79  $tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
80  $tpl->setVariable("ALT_STATUS", $lng->txt("exc_".$stat));
81 
82  return $tpl->get();
83  }
84 
88  function getOverviewBody($a_data)
89  {
90  global $lng, $ilCtrl, $ilUser;
91 
92  $tpl = new ilTemplate("tpl.assignment_body.html", true, true, "Modules/Exercise");
93 
94  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
95  $info = new ilInfoScreenGUI(null);
96  $info->setTableClass("");
97 
98  $not_started_yet = false;
99  if ($a_data["start_time"] > 0 && time() - $a_data["start_time"] <= 0)
100  {
101  $not_started_yet = true;
102  }
103 
104  if (!$not_started_yet)
105  {
106  // instructions
107  $info->addSection($lng->txt("exc_instruction"));
108  $info->addProperty("",
109  nl2br(ilUtil::makeClickable($a_data["instruction"], true)));
110  }
111 
112  // schedule
113  $info->addSection($lng->txt("exc_schedule"));
114  if ($a_data["start_time"] > 0)
115  {
116  $info->addProperty($lng->txt("exc_start_time"),
117  ilDatePresentation::formatDate(new ilDateTime($a_data["start_time"],IL_CAL_UNIX)));
118  }
119  $info->addProperty($lng->txt("exc_edit_until"),
120  ilDatePresentation::formatDate(new ilDateTime($a_data["deadline"],IL_CAL_UNIX)));
121  $time_str = $this->getTimeString($a_data["deadline"]);
122  if (!$not_started_yet)
123  {
124  $info->addProperty($lng->txt("exc_time_to_send"),
125  "<b>".$time_str."</b>");
126  }
127 
128  // public submissions
129  if ($this->exc->getShowSubmissions())
130  {
131  $ilCtrl->setParameterByClass("ilobjexercisegui", "ass_id", $a_data["id"]);
132  if ($a_data["deadline"] - time() <= 0)
133  {
134  $link = '<a class="submit" href="'.
135  $ilCtrl->getLinkTargetByClass("ilobjexercisegui", "listPublicSubmissions").'">'.
136  $lng->txt("exc_list_submission").'</a>';
137  $info->addProperty($lng->txt("exc_public_submission"), $link);
138  }
139  else
140  {
141  $info->addProperty($lng->txt("exc_public_submission"),
142  $lng->txt("exc_msg_public_submission"));
143  }
144  $ilCtrl->setParameterByClass("ilobjexercisegui", "ass_id", $_GET["ass_id"]);
145  }
146 
147  $ilCtrl->setParameterByClass("ilobjexercisegui", "ass_id", $a_data["id"]);
148 
149  if (!$not_started_yet)
150  {
151  // download files
152  $files = ilExAssignment::getFiles($a_data["exc_id"], $a_data["id"]);
153  if (count($files) > 0)
154  {
155  $info->addSection($lng->txt("exc_files"));
156  foreach($files as $file)
157  {
158  $ilCtrl->setParameterByClass("ilobjexercisegui", "file", urlencode($file["name"]));
159  $info->addProperty($file["name"],
160  $lng->txt("download"),
161  $ilCtrl->getLinkTargetByClass("ilobjexercisegui", "downloadFile"));
162  $ilCtrl->setParameter($this, "file", "");
163  }
164  }
165 
166  // submission
167  $info->addSection($lng->txt("exc_your_submission"));
168  $delivered_files = ilExAssignment::getDeliveredFiles($a_data["exc_id"], $a_data["id"], $ilUser->getId());
169  $titles = array();
170  foreach($delivered_files as $file)
171  {
172  $titles[] = $file["filetitle"];
173  }
174  $files_str = implode($titles, ", ");
175  if ($files_str == "")
176  {
177  $files_str = $lng->txt("message_no_delivered_files");
178  }
179 
180  $ilCtrl->setParameterByClass("ilobjexercisegui", "ass_id", $a_data["id"]);
181 
182  if ($a_data["deadline"] - time() > 0)
183  {
184  $files_str.= ' <a class="submit" href="'.
185  $ilCtrl->getLinkTargetByClass("ilobjexercisegui", "submissionScreen").'">'.
186  (count($titles) == 0
187  ? $lng->txt("exc_hand_in")
188  : $lng->txt("exc_edit_submission")).'</a>';
189  }
190  else
191  {
192  $files_str.= ' <a class="submit" href="'.
193  $ilCtrl->getLinkTargetByClass("ilobjexercisegui", "submissionScreen").'">'.
194  $lng->txt("already_delivered_files").'</a>';
195  }
196 
197  $info->addProperty($lng->txt("exc_files_returned"),
198  $files_str);
199  $last_sub = ilExAssignment::getLastSubmission($a_data["id"], $ilUser->getId());
200  if ($last_sub)
201  {
202  $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub,IL_CAL_DATETIME));
203  }
204  else
205  {
206  $last_sub = "---";
207  }
208 
209  if ($last_sub != "---")
210  {
211  $info->addProperty($lng->txt("exc_last_submission"),
212  $last_sub);
213  }
214 
215  // feedback from tutor
216  $storage = new ilFSStorageExercise($a_data["exc_id"], $a_data["id"]);
217  $cnt_files = $storage->countFeedbackFiles($ilUser->getId());
218  $lpcomment = ilExAssignment::lookupCommentForUser($a_data["id"], $ilUser->getId());
219  $mark = ilExAssignment::lookupMarkOfUser($a_data["id"], $ilUser->getId());
220  $status = ilExAssignment::lookupStatusOfUser($a_data["id"], $ilUser->getId());
221  if ($lpcomment != "" || $mark != "" || $status != "notgraded" || $cnt_files > 0)
222  {
223  $info->addSection($lng->txt("exc_feedback_from_tutor"));
224  if ($lpcomment != "")
225  {
226  $info->addProperty($lng->txt("exc_comment"),
227  $lpcomment);
228  }
229  if ($mark != "")
230  {
231  $info->addProperty($lng->txt("exc_mark"),
232  $mark);
233  }
234 
235  if ($status == "")
236  {
237 // $info->addProperty($lng->txt("status"),
238 // $lng->txt("message_no_delivered_files"));
239  }
240  else if ($status != "notgraded")
241  {
242  $img = '<img border="0" src="'.ilUtil::getImagePath("scorm/".$status.".gif").'" '.
243  ' alt="'.$lng->txt("exc_".$status).'" title="'.$lng->txt("exc_".$status).
244  '" style="vertical-align:middle;"/>';
245  $info->addProperty($lng->txt("status"),
246  $img." ".$lng->txt("exc_".$status));
247  }
248 
249  if ($cnt_files > 0)
250  {
251  $info->addSection($lng->txt("exc_fb_files"));
252  $files = $storage->getFeedbackFiles($ilUser->getId());
253  foreach($files as $file)
254  {
255  $ilCtrl->setParameterByClass("ilobjexercisegui", "file", urlencode($file));
256  $info->addProperty($file,
257  $lng->txt("download"),
258  $ilCtrl->getLinkTargetByClass("ilobjexercisegui", "downloadFeedbackFile"));
259  $ilCtrl->setParameter($this, "file", "");
260  }
261  }
262  }
263  }
264 
265  $tpl->setVariable("CONTENT", $info->getHTML());
266 
267  return $tpl->get();
268  }
269 
273  function getTimeString($a_deadline)
274  {
275  global $lng;
276 
277  if ($a_deadline - time() <= 0)
278  {
279  $time_str = $lng->txt("exc_time_over_short");
280  }
281  else
282  {
283  $time_diff = ilUtil::int2array($a_deadline - time(),null);
284  unset($time_diff['seconds']);
285  if (isset($time_diff['days']))
286  {
287  unset($time_diff['minutes']);
288  }
289  if (isset($time_diff['months']))
290  {
291  unset($time_diff['hours']);
292  }
293  $time_str = ilUtil::timearray2string($time_diff);
294  }
295 
296  return $time_str;
297  }
298 
299 
300 }