ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilExAssignmentGUI.php
Go to the documentation of this file.
1<?php
2
12{
16 protected $lng;
17
21 protected $user;
22
26 protected $ctrl;
27
28 protected $exc; // [ilObjExercise]
29 protected $current_ass_id; // [int]
30
34 public function __construct(ilObjExercise $a_exc)
35 {
36 global $DIC;
37
38 $this->lng = $DIC->language();
39 $this->user = $DIC->user();
40 $this->ctrl = $DIC->ctrl();
41 $this->exc = $a_exc;
42 }
43
47 public function getOverviewHeader(ilExAssignment $a_ass)
48 {
51
52 $lng->loadLanguageModule("exc");
53
54 $tpl = new ilTemplate("tpl.assignment_head.html", true, true, "Modules/Exercise");
55
56 // we are completely ignoring the extended deadline here
57
58 $idl = $a_ass->getPersonalDeadline($ilUser->getId());
59
60 // :TODO: meaning of "ended on"
61 $dl = max($a_ass->getDeadline(), $idl);
62 if ($dl &&
63 $dl < time()) {
64 $tpl->setCurrentBlock("prop");
65 $tpl->setVariable("PROP", $lng->txt("exc_ended_on"));
66 $tpl->setVariable(
67 "PROP_VAL",
69 );
70 $tpl->parseCurrentBlock();
71
72 // #14077
73 if ($a_ass->getPeerReview() &&
74 $a_ass->getPeerReviewDeadline()) {
75 $tpl->setCurrentBlock("prop");
76 $tpl->setVariable("PROP", $lng->txt("exc_peer_review_deadline"));
77 $tpl->setVariable(
78 "PROP_VAL",
80 );
81 $tpl->parseCurrentBlock();
82 }
83 } elseif ($a_ass->notStartedYet()) {
84 $tpl->setCurrentBlock("prop");
85 $tpl->setVariable("PROP", $lng->txt("exc_starting_on"));
86 $tpl->setVariable(
87 "PROP_VAL",
89 );
90 $tpl->parseCurrentBlock();
91 } else {
92 $time_str = $this->getTimeString($idl);
93 $tpl->setCurrentBlock("prop");
94 $tpl->setVariable("PROP", $lng->txt("exc_time_to_send"));
95 $tpl->setVariable("PROP_VAL", $time_str);
96 $tpl->parseCurrentBlock();
97
98 if ($a_ass->getDeadline()) {
99 $tpl->setCurrentBlock("prop");
100 $tpl->setVariable("PROP", $lng->txt("exc_edit_until"));
101 $tpl->setVariable(
102 "PROP_VAL",
104 );
105 $tpl->parseCurrentBlock();
106 }
107
108 if ($idl && $idl != $a_ass->getDeadline()) {
109 $tpl->setCurrentBlock("prop");
110 $tpl->setVariable("PROP", $lng->txt("exc_individual_deadline"));
111 $tpl->setVariable(
112 "PROP_VAL",
114 );
115 $tpl->parseCurrentBlock();
116 }
117 }
118
119 $mand = "";
120 if ($a_ass->getMandatory()) {
121 $mand = " (" . $lng->txt("exc_mandatory") . ")";
122 }
123 $tpl->setVariable("TITLE", $a_ass->getTitle() . $mand);
124
125 // status icon
126 $stat = $a_ass->getMemberStatus()->getStatus();
127 $pic = $a_ass->getMemberStatus()->getStatusIcon();
128 $tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
129 $tpl->setVariable("ALT_STATUS", $lng->txt("exc_" . $stat));
130
131 return $tpl->get();
132 }
133
137 public function getOverviewBody(ilExAssignment $a_ass)
138 {
139 $this->current_ass_id = $a_ass->getId();
140
141 $tpl = new ilTemplate("tpl.assignment_body.html", true, true, "Modules/Exercise");
142
143 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
144 include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
145
146 $info = new ilInfoScreenGUI(null);
147 $info->setTableClass("");
148
149 $this->addInstructions($info, $a_ass);
150
151 if (!$a_ass->notStartedYet()) {
152 $this->addFiles($info, $a_ass);
153 }
154
155 $this->addSchedule($info, $a_ass);
156
157 if (!$a_ass->notStartedYet()) {
158 $this->addSubmission($info, $a_ass);
159 }
160
161 $tpl->setVariable("CONTENT", $info->getHTML());
162
163 return $tpl->get();
164 }
165
166
167 protected function addInstructions(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
168 {
170
171 if (!$a_ass->notStartedYet()) {
172 $inst = $a_ass->getInstruction();
173 if (trim($inst)) {
174 $a_info->addSection($lng->txt("exc_instruction"));
175
176 $is_html = (strlen($inst) != strlen(strip_tags($inst)));
177 if (!$is_html) {
178 $inst = nl2br(ilUtil::makeClickable($inst, true));
179 }
180 $a_info->addProperty("", $inst);
181 }
182 }
183 }
184
185 protected function addSchedule(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
186 {
189
190 $idl = $a_ass->getPersonalDeadline($ilUser->getId());
191
192 $a_info->addSection($lng->txt("exc_schedule"));
193 if ($a_ass->getStartTime() > 0) {
194 $a_info->addProperty(
195 $lng->txt("exc_start_time"),
197 );
198 }
199
200 // extended deadline info/warning
201 $late_dl = "";
202 if ($idl &&
203 $idl < time() &&
204 $a_ass->beforeDeadline()) { // ext dl is last deadline
205 // extended deadline date should not be presented anywhere
207 $late_dl = "<br />" . sprintf($lng->txt("exc_late_submission_warning"), $late_dl);
208 $late_dl = '<span class="warning">' . $late_dl . '</span>';
209 }
210
211 if ($a_ass->getDeadline()) {
213
214 // add late info if no idl
215 if ($late_dl &&
216 $idl == $a_ass->getDeadline()) {
217 $until .= $late_dl;
218 }
219
220 $a_info->addProperty($lng->txt("exc_edit_until"), $until);
221 }
222
223 if ($idl &&
224 $idl != $a_ass->getDeadline()) {
226
227 // add late info?
228 if ($late_dl) {
229 $until .= $late_dl;
230 }
231
232 $a_info->addProperty($lng->txt("exc_individual_deadline"), $until);
233 }
234
235 if (!$a_ass->notStartedYet()) {
236 $a_info->addProperty(
237 $lng->txt("exc_time_to_send"),
238 "<b>" . $this->getTimeString($idl) . "</b>"
239 );
240 }
241 }
242
243 protected function addPublicSubmissions(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
244 {
246
247 if ($a_ass->afterDeadline()) {
248 $button = ilLinkButton::getInstance();
249 $button->setCaption("exc_list_submission");
250 $button->setUrl($this->getSubmissionLink("listPublicSubmissions"));
251
252 $a_info->addProperty($lng->txt("exc_public_submission"), $button->render());
253 } else {
254 $a_info->addProperty(
255 $lng->txt("exc_public_submission"),
256 $lng->txt("exc_msg_public_submission")
257 );
258 }
259 }
260
261 protected function addFiles(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
262 {
265
266 $files = $a_ass->getFiles();
267
268 if (count($files) > 0) {
269 $a_info->addSection($lng->txt("exc_files"));
270
271 global $DIC;
272
273 //file has -> name,fullpath,size,ctime
274 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
275 include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
276 include_once "./Services/UIComponent/Modal/classes/class.ilModalGUI.php";
277
278 $cnt = 0;
279 foreach ($files as $file) {
280 $cnt++;
281 // get mime type
282 $mime = ilObjMediaObject::getMimeType($file['fullpath']);
283
284 list($format, $type) = explode("/", $mime);
285
286 $ui_factory = $DIC->ui()->factory();
287 $ui_renderer = $DIC->ui()->renderer();
288
289 if (in_array($mime, array("image/jpeg", "image/svg+xml", "image/gif", "image/png"))) {
290 $item_id = "il-ex-modal-img-" . $a_ass->getId() . "-" . $cnt;
291
292
293 $image = $ui_renderer->render($ui_factory->image()->responsive($file['fullpath'], $file['name']));
294 $image_lens = ilUtil::getImagePath("enlarge.svg");
295
296 $modal = ilModalGUI::getInstance();
297 $modal->setId($item_id);
298 $modal->setType(ilModalGUI::TYPE_LARGE);
299 $modal->setBody($image);
300 $modal->setHeading($file["name"]);
301 $modal = $modal->getHTML();
302
303 $img_tpl = new ilTemplate("tpl.image_file.html", true, true, "Modules/Exercise");
304 $img_tpl->setCurrentBlock("image_content");
305 $img_tpl->setVariable("MODAL", $modal);
306 $img_tpl->setVariable("ITEM_ID", $item_id);
307 $img_tpl->setVariable("IMAGE", $image);
308 $img_tpl->setvariable("IMAGE_LENS", $image_lens);
309 $img_tpl->parseCurrentBlock();
310
311 $a_info->addProperty($file["name"], $img_tpl->get());
312 } elseif (in_array($mime, array("audio/mpeg", "audio/ogg", "video/mp4", "video/x-flv", "video/webm"))) {
313 $media_tpl = new ilTemplate("tpl.media_file.html", true, true, "Modules/Exercise");
314 $mp = new ilMediaPlayerGUI();
315 $mp->setFile($file['fullpath']);
316 $media_tpl->setVariable("MEDIA", $mp->getMediaPlayerHtml());
317
318 $but = $ui_factory->button()->shy(
319 $lng->txt("download"),
320 $this->getSubmissionLink("downloadFile", array("file"=>urlencode($file["name"])))
321 );
322 $media_tpl->setVariable("DOWNLOAD_BUTTON", $ui_renderer->render($but));
323 $a_info->addProperty($file["name"], $media_tpl->get());
324 } else {
325 $a_info->addProperty($file["name"], $lng->txt("download"), $this->getSubmissionLink("downloadFile", array("file"=>urlencode($file["name"]))));
326 }
327 }
328 }
329 }
330
331 protected function addSubmission(ilInfoScreenGUI $a_info, ilExAssignment $a_ass)
332 {
336
337 $a_info->addSection($lng->txt("exc_submission"));
338
339 include_once "Modules/Exercise/classes/class.ilExSubmission.php";
340 $submission = new ilExSubmission($a_ass, $ilUser->getId());
341
342 include_once "Modules/Exercise/classes/class.ilExSubmissionGUI.php";
343 ilExSubmissionGUI::getOverviewContent($a_info, $submission);
344
345 $last_sub = null;
346 if ($submission->hasSubmitted()) {
347 $last_sub = $submission->getLastSubmission();
348 if ($last_sub) {
349 $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub, IL_CAL_DATETIME));
350 $a_info->addProperty($lng->txt("exc_last_submission"), $last_sub);
351 }
352 }
353
354 if ($this->exc->getShowSubmissions()) {
355 $this->addPublicSubmissions($a_info, $a_ass);
356 }
357
358 include_once "Modules/Exercise/classes/class.ilExPeerReviewGUI.php";
359 ilExPeerReviewGUI::getOverviewContent($a_info, $submission);
360
361 // global feedback / sample solution
363 $show_global_feedback = ($a_ass->afterDeadlineStrict() && $a_ass->getFeedbackFile());
364 } else {
365 $show_global_feedback = ($last_sub && $a_ass->getFeedbackFile());
366 }
367
368 $this->addSubmissionFeedback($a_info, $a_ass, $submission->getFeedbackId(), $show_global_feedback);
369 }
370
371 protected function addSubmissionFeedback(ilInfoScreenGUI $a_info, ilExAssignment $a_ass, $a_feedback_id, $a_show_global_feedback)
372 {
374
375 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
376
377 $storage = new ilFSStorageExercise($a_ass->getExerciseId(), $a_ass->getId());
378 $cnt_files = $storage->countFeedbackFiles($a_feedback_id);
379
380 $lpcomment = $a_ass->getMemberStatus()->getComment();
381 $mark = $a_ass->getMemberStatus()->getMark();
382 $status = $a_ass->getMemberStatus()->getStatus();
383
384 if ($lpcomment != "" ||
385 $mark != "" ||
386 $status != "notgraded" ||
387 $cnt_files > 0 ||
388 $a_show_global_feedback) {
389 $a_info->addSection($lng->txt("exc_feedback_from_tutor"));
390 if ($lpcomment != "") {
391 $a_info->addProperty(
392 $lng->txt("exc_comment"),
393 nl2br($lpcomment)
394 );
395 }
396 if ($mark != "") {
397 $a_info->addProperty(
398 $lng->txt("exc_mark"),
399 $mark
400 );
401 }
402
403 if ($status == "") {
404 // $a_info->addProperty($lng->txt("status"),
405// $lng->txt("message_no_delivered_files"));
406 } elseif ($status != "notgraded") {
407 $img = '<img src="' . ilUtil::getImagePath("scorm/" . $status . ".svg") . '" ' .
408 ' alt="' . $lng->txt("exc_" . $status) . '" title="' . $lng->txt("exc_" . $status) .
409 '" />';
410 $a_info->addProperty(
411 $lng->txt("status"),
412 $img . " " . $lng->txt("exc_" . $status)
413 );
414 }
415
416 if ($cnt_files > 0) {
417 $a_info->addSection($lng->txt("exc_fb_files") .
418 '<a name="fb' . $a_ass->getId() . '"></a>');
419
420 if ($cnt_files > 0) {
421 $files = $storage->getFeedbackFiles($a_feedback_id);
422 foreach ($files as $file) {
423 $a_info->addProperty(
424 $file,
425 $lng->txt("download"),
426 $this->getSubmissionLink("downloadFeedbackFile", array("file"=>urlencode($file)))
427 );
428 }
429 }
430 }
431
432 // #15002 - global feedback
433 if ($a_show_global_feedback) {
434 $a_info->addSection($lng->txt("exc_global_feedback_file"));
435
436 $a_info->addProperty(
437 $a_ass->getFeedbackFile(),
438 $lng->txt("download"),
439 $this->getSubmissionLink("downloadGlobalFeedbackFile")
440 );
441 }
442 }
443 }
444
448 public function getTimeString($a_deadline)
449 {
451
452 if ($a_deadline == 0) {
453 return $lng->txt("exc_submit_convenience_no_deadline");
454 }
455
456 if ($a_deadline - time() <= 0) {
457 $time_str = $lng->txt("exc_time_over_short");
458 } else {
459 $time_str = ilUtil::period2String(new ilDateTime($a_deadline, IL_CAL_UNIX));
460 }
461
462 return $time_str;
463 }
464
465 protected function getSubmissionLink($a_cmd, array $a_params = null)
466 {
468
469 if (is_array($a_params)) {
470 foreach ($a_params as $name => $value) {
471 $ilCtrl->setParameterByClass("ilexsubmissiongui", $name, $value);
472 }
473 }
474
475 $ilCtrl->setParameterByClass("ilexsubmissiongui", "ass_id", $this->current_ass_id);
476 $url = $ilCtrl->getLinkTargetByClass("ilexsubmissiongui", $a_cmd);
477 $ilCtrl->setParameterByClass("ilexsubmissiongui", "ass_id", "");
478
479 if (is_array($a_params)) {
480 foreach ($a_params as $name => $value) {
481 $ilCtrl->setParameterByClass("ilexsubmissiongui", $name, "");
482 }
483 }
484
485 return $url;
486 }
487}
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
$tpl
Definition: ilias.php:10
$files
Definition: add-vimline.php:18
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
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.
getPersonalDeadline($a_user_id)
Get individual deadline.
afterDeadlineStrict($a_include_personal=true)
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.
User interface for media player.
static getInstance()
Get instance.
Class ilObjExercise.
static getMimeType($a_file, $a_external=null)
get mime type for file
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)
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
$format
Definition: metadata.php:141
$info
Definition: index.php:5
$type
$url
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18