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