ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilExerciseSubmissionTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
6include_once("./Modules/Exercise/classes/class.ilExAssignmentTeam.php");
7include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
8
18{
22 protected $access;
23
24 protected $exc; // [ilObjExercise]
25 protected $mode; // [int]
26 protected $filter; // [array]
27 protected $comment_modals = array(); // [array]
28
30 const MODE_BY_USER = 2;
31
32 // needs PH P5.6 for array support
33 protected $cols_mandatory = array("name", "status");
34 protected $cols_default = array("login", "submission_date", "idl");
35 protected $cols_order = array("image", "name", "login", "team_members",
36 "sent_time", "submission", "idl", "status", "mark", "status_time",
37 "feedback_time", "comment", "notice");
38
48 public function __construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item_id)
49 {
50 global $DIC;
51
52 $this->ctrl = $DIC->ctrl();
53 $this->access = $DIC->access();
54 $this->tpl = $DIC["tpl"];
55 $this->lng = $DIC->language();
56
57
58 $ilCtrl = $DIC->ctrl();
59
60 $this->exc = $a_exc;
61
62 $this->initMode($a_item_id);
63
64 parent::__construct($a_parent_obj, $a_parent_cmd);
65
66 $this->setShowTemplates(true);
67
68 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
69 $this->setRowTemplate("tpl.exc_members_row.html", "Modules/Exercise");
70
71 #25100
72 if ($this->mode == self::MODE_BY_ASSIGNMENT) {
73 $this->setDefaultOrderField("name");
74 $this->setDefaultOrderDirection("asc");
75 }
76
77
78 // columns
79
80 $this->addColumn("", "", "1", true);
81
82 $selected = $this->getSelectedColumns();
83 $columns = $this->parseColumns();
84 foreach ($this->cols_order as $id) {
85 if (in_array($id, $this->cols_mandatory) ||
86 in_array($id, $selected)) {
87 if (array_key_exists($id, $columns)) {
88 $col = $columns[$id];
89 $this->addColumn($col[0], $col[1]);
90 }
91 }
92 }
93
94 $this->addColumn($this->lng->txt("actions"));
95
96
97 // multi actions
98
99 $this->addMultiCommand("saveStatusSelected", $this->lng->txt("exc_save_selected"));
100
101 $this->setFormName("ilExcIDlForm");
102
103 // see 0021530 and parseRow here with similar action per user
104 if ($this->mode == self::MODE_BY_ASSIGNMENT &&
105 $this->ass->hasActiveIDl() &&
106 !$this->ass->hasReadOnlyIDl()) {
107 $this->addMultiCommand("setIndividualDeadline", $this->lng->txt("exc_individual_deadline_action"));
108 }
109
110 if ($this->exc->hasTutorFeedbackMail() &&
111 $this->mode == self::MODE_BY_ASSIGNMENT) {
112 $this->addMultiCommand("redirectFeedbackMail", $this->lng->txt("exc_tbl_action_feedback_mail"));
113 }
114
115 $this->addMultiCommand("sendMembers", $this->lng->txt("exc_send_assignment"));
116
117 if ($this->mode == self::MODE_BY_ASSIGNMENT &&
118 $this->ass &&
119 $this->ass->hasTeam()) {
120 $this->addMultiCommand("createTeams", $this->lng->txt("exc_team_multi_create"));
121 $this->addMultiCommand("dissolveTeams", $this->lng->txt("exc_team_multi_dissolve"));
122 }
123
124 if ($this->mode == self::MODE_BY_ASSIGNMENT) {
125 $this->addMultiCommand("confirmDeassignMembers", $this->lng->txt("exc_deassign_members"));
126 }
127
128 $this->setFilterCommand($this->getParentCmd() . "Apply");
129 $this->setResetCommand($this->getParentCmd() . "Reset");
130
131 $this->initFilter();
132 $this->setData($this->parseData());
133
134 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
135 }
136
137 public function initFilter()
138 {
139 if ($this->mode == self::MODE_BY_ASSIGNMENT) {
140 $item = $this->addFilterItemByMetaType("flt_name", self::FILTER_TEXT, false, $this->lng->txt("name") . " / " . $this->lng->txt("login"));
141 $this->filter["name"] = $item->getValue();
142 }
143
144 $this->lng->loadLanguageModule("search");
145 $options = array(
146 "" => $this->lng->txt("search_any"),
147 "notgraded" => $this->lng->txt("exc_notgraded"),
148 "passed" => $this->lng->txt("exc_passed"),
149 "failed" => $this->lng->txt("exc_failed")
150 );
151 $item = $this->addFilterItemByMetaType("flt_status", self::FILTER_SELECT, false, $this->lng->txt("exc_tbl_status"));
152 $item->setOptions($options);
153 $this->filter["status"] = $item->getValue();
154
155 $options = array(
156 "" => $this->lng->txt("search_any"),
157 "y" => $this->lng->txt("exc_tbl_filter_has_submission"),
158 "n" => $this->lng->txt("exc_tbl_filter_has_no_submission")
159 );
160 $item = $this->addFilterItemByMetaType("flt_subm", self::FILTER_SELECT, false, $this->lng->txt("exc_tbl_filter_submission"));
161 $item->setOptions($options);
162 $this->filter["subm"] = $item->getValue();
163 }
164
165 abstract protected function initMode($a_item_id);
166
167 abstract protected function parseData();
168
169 abstract protected function parseModeColumns();
170
171 public function getSelectableColumns()
172 {
173 $cols = array();
174
175 $columns = $this->parseColumns();
176 foreach ($this->cols_order as $id) {
177 if (in_array($id, $this->cols_mandatory)) {
178 continue;
179 }
180
181 if (array_key_exists($id, $columns)) {
182 $col = $columns[$id];
183
184 $cols[$id] = array(
185 "txt" => $col[0],
186 "default" => in_array($id, $this->cols_default)
187 );
188 }
189 }
190
191 return $cols;
192 }
193
194 protected function parseColumns()
195 {
196 $cols = $this->parseModeColumns();
197
198 $cols["submission"] = array($this->lng->txt("exc_tbl_submission_date"), "submission");
199
200 $cols["status"] = array($this->lng->txt("exc_tbl_status"), "status");
201 $cols["mark"] = array($this->lng->txt("exc_tbl_mark"), "mark");
202 $cols["status_time"] = array($this->lng->txt("exc_tbl_status_time"), "status_time");
203
204 $cols["sent_time"] = array($this->lng->txt("exc_tbl_sent_time"), "sent_time");
205
206 if ($this->exc->hasTutorFeedbackText() ||
207 $this->exc->hasTutorFeedbackMail() ||
208 $this->exc->hasTutorFeedbackFile()) {
209 $cols["feedback_time"] = array($this->lng->txt("exc_tbl_feedback_time"), "feedback_time");
210 }
211
212 if ($this->exc->hasTutorFeedbackText()) {
213 $cols["comment"] = array($this->lng->txt("exc_tbl_comment"), "comment");
214 }
215
216 $cols["notice"] = array($this->lng->txt("exc_tbl_notice"), "note");
217
218 return $cols;
219 }
220
221 protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row)
222 {
224 $ilAccess = $this->access;
225
226 $has_no_team_yet = ($a_ass->hasTeam() &&
227 !ilExAssignmentTeam::getTeamId($a_ass->getId(), $a_user_id));
228
229
230 // static columns
231
232 if ($this->mode == self::MODE_BY_ASSIGNMENT) {
233 if (!$a_ass->hasTeam()) {
234 $this->tpl->setVariable("VAL_NAME", $a_row["name"]);
235
236 // #18327
237 if (!$ilAccess->checkAccessOfUser($a_user_id, "read", "", $this->exc->getRefId()) &&
238 is_array($info = $ilAccess->getInfo())) {
239 $this->tpl->setCurrentBlock('access_warning');
240 $this->tpl->setVariable('PARENT_ACCESS', $info[0]["text"]);
241 $this->tpl->parseCurrentBlock();
242 }
243 } else {
244 asort($a_row["team"]);
245 foreach ($a_row["team"] as $team_member_id => $team_member_name) { // #10749
246 if (sizeof($a_row["team"]) > 1) {
247 $ilCtrl->setParameterByClass("ilExSubmissionTeamGUI", "id", $team_member_id);
248 $url = $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "confirmRemoveTeamMember");
249 $ilCtrl->setParameterByClass("ilExSubmissionTeamGUI", "id", "");
250
251 include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
252
253 $this->tpl->setCurrentBlock("team_member_removal_bl");
254 $this->tpl->setVariable("URL_TEAM_MEMBER_REMOVAL", $url);
255 $this->tpl->setVariable(
256 "TXT_TEAM_MEMBER_REMOVAL",
257 ilGlyphGUI::get(ilGlyphGUI::CLOSE, $this->lng->txt("remove"))
258 );
259 $this->tpl->parseCurrentBlock();
260 }
261
262 // #18327
263 if (!$ilAccess->checkAccessOfUser($team_member_id, "read", "", $this->exc->getRefId()) &&
264 is_array($info = $ilAccess->getInfo())) {
265 $this->tpl->setCurrentBlock('team_access_warning');
266 $this->tpl->setVariable('TEAM_PARENT_ACCESS', $info[0]["text"]);
267 $this->tpl->parseCurrentBlock();
268 }
269
270 $this->tpl->setCurrentBlock("team_member");
271 $this->tpl->setVariable("TXT_MEMBER_NAME", $team_member_name);
272 $this->tpl->parseCurrentBlock();
273 }
274
275 if ($has_no_team_yet) {
276 // #11957
277 $this->tpl->setCurrentBlock("team_info");
278 $this->tpl->setVariable("TXT_TEAM_INFO", $this->lng->txt("exc_no_team_yet"));
279 }
280 }
281 } else {
282 $this->tpl->setVariable("VAL_NAME", $a_row["name"]);
283 }
284
285 // do not grade or mark if no team yet
286 if (!$has_no_team_yet) {
287 // status
288 $this->tpl->setVariable("SEL_" . strtoupper($a_row["status"]), ' selected="selected" ');
289 $this->tpl->setVariable("TXT_NOTGRADED", $this->lng->txt("exc_notgraded"));
290 $this->tpl->setVariable("TXT_PASSED", $this->lng->txt("exc_passed"));
291 $this->tpl->setVariable("TXT_FAILED", $this->lng->txt("exc_failed"));
292 } else {
293 $nt_colspan = in_array("mark", $this->getSelectedColumns())
294 ? 2
295 : 1;
296
297 $this->tpl->setVariable("NO_TEAM_COLSPAN", $nt_colspan);
298 }
299
300
301 // comment modal
302
303 if ($this->exc->hasTutorFeedbackText()) {
304 $comment_id = "excasscomm_" . $a_ass->getId() . "_" . $a_user_id;
305
306 $modal = ilModalGUI::getInstance();
307 $modal->setId($comment_id);
308 $modal->setHeading($this->lng->txt("exc_tbl_action_feedback_text"));
309
310 $lcomment_form = new ilPropertyFormGUI();
311 $lcomment_form->setId($comment_id);
312 $lcomment_form->setPreventDoubleSubmission(false);
313
314 $lcomment = new ilTextAreaInputGUI($this->lng->txt("exc_comment_for_learner"), "lcomment_" . $a_ass->getId() . "_" . $a_user_id);
315 $lcomment->setInfo($this->lng->txt("exc_comment_for_learner_info"));
316 $lcomment->setValue($a_row["comment"]);
317 $lcomment->setCols(45);
318 $lcomment->setRows(10);
319 $lcomment_form->addItem($lcomment);
320
321 $lcomment_form->addCommandButton("save", $this->lng->txt("save"));
322 // $lcomment_form->addCommandButton("cancel", $lng->txt("cancel"));
323
324 $modal->setBody($lcomment_form->getHTML());
325
326 $this->comment_modals[] = $modal->getHTML();
327 unset($modal);
328 }
329
330
331 // selectable columns
332
333 foreach ($this->getSelectedColumns() as $col) {
334 switch ($col) {
335 case "image":
336 if (!$a_ass->hasTeam()) {
337 include_once "./Services/Object/classes/class.ilObjectFactory.php";
338 if ($usr_obj = ilObjectFactory::getInstanceByObjId($a_user_id, false)) {
339 $this->tpl->setVariable("VAL_IMAGE", $usr_obj->getPersonalPicturePath("xxsmall"));
340 $this->tpl->setVariable("TXT_IMAGE", $this->lng->txt("personal_picture"));
341 }
342 }
343 break;
344
345 case "team_members":
346 if ($a_ass->hasTeam()) {
347 if (!sizeof($a_row["team"])) {
348 $this->tpl->setVariable("VAL_TEAM_MEMBER", $this->lng->txt("exc_no_team_yet"));
349 } else {
350 foreach ($a_row["team"] as $name) {
351 $this->tpl->setCurrentBlock("team_member_bl");
352 $this->tpl->setVariable("VAL_TEAM_MEMBER", $name);
353 $this->tpl->parseCurrentBlock();
354 }
355 }
356 } else {
357 $this->tpl->setVariable("VAL_TEAM_MEMBER", "&nbsp;");
358 }
359 break;
360
361 case "idl":
362 $this->tpl->setVariable(
363 "VAL_" . strtoupper($col),
364 $a_row[$col]
366 : "&nbsp;"
367 );
368 break;
369
370
371 case "mark":
372 if ($has_no_team_yet) {
373 continue;
374 }
375 // fallthrough
376
377 // no break
378 case "notice":
379 // see #22076
380 $this->tpl->setVariable("VAL_" . strtoupper($col), ilUtil::prepareFormOutput(trim($a_row[$col])));
381 break;
382
383 case "comment":
384 // for js-updating
385 $this->tpl->setVariable("LCOMMENT_ID", $comment_id . "_snip");
386
387 // see #22076
388 $this->tpl->setVariable("VAL_" . strtoupper($col), (trim($a_row[$col]) !== "")
389 ? nl2br(trim($a_row[$col]))
390 : "&nbsp;");
391 break;
392
393 case "submission":
394 if ($a_row["submission_obj"]) {
395 foreach ($a_row["submission_obj"]->getFiles() as $file) {
396 if ($file["late"]) {
397 $this->tpl->setVariable("TXT_LATE", $this->lng->txt("exc_late_submission"));
398 break;
399 }
400 }
401 }
402 // fallthrough
403
404 // no break
405 case "feedback_time":
406 case "status_time":
407 case "sent_time":
408 $this->tpl->setVariable(
409 "VAL_" . strtoupper($col),
410 $a_row[$col]
412 : "&nbsp;"
413 );
414 break;
415
416 case "login":
417 if ($a_ass->hasTeam()) {
418 continue;
419 }
420 // fallthrough
421
422 // no break
423 default:
424 $this->tpl->setVariable("VAL_" . strtoupper($col), $a_row[$col]
425 ? trim($a_row[$col])
426 : "&nbsp;");
427 break;
428 }
429 }
430
431
432 // actions
433
434 include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
435 $actions = new ilAdvancedSelectionListGUI();
436 $actions->setId($a_ass->getId() . "_" . $a_user_id);
437 $actions->setListTitle($this->lng->txt("actions"));
438
439 $file_info = $a_row["submission_obj"]->getDownloadedFilesInfoForTableGUIS($this->getParentObject(), $this->getParentCmd());
440
441 $counter = $file_info["files"]["count"];
442 if ($counter) {
443 if ($file_info["files"]["download_url"]) {
444 $actions->addItem(
445 $file_info["files"]["download_txt"] . " (" . $counter . ")",
446 "",
447 $file_info["files"]["download_url"]
448 );
449 }
450
451 if ($file_info["files"]["download_new_url"]) {
452 $actions->addItem(
453 $file_info["files"]["download_new_txt"],
454 "",
455 $file_info["files"]["download_new_url"]
456 );
457 }
458 }
459
460 if (!$has_no_team_yet &&
461 $a_ass->hasActiveIDl() &&
462 !$a_ass->hasReadOnlyIDl()) {
463 $idl_id = $a_ass->hasTeam()
464 ? "t" . ilExAssignmentTeam::getTeamId($a_ass->getId(), $a_user_id)
465 : $a_user_id;
466
467 $this->tpl->setVariable("VAL_IDL_ID", $a_ass->getId() . "_" . $idl_id);
468
469 $actions->addItem(
470 $this->lng->txt("exc_individual_deadline_action"),
471 "",
472 "#",
473 "",
474 "",
475 "",
476 "",
477 false,
478 "il.ExcIDl.trigger('" . $idl_id . "'," . $a_ass->getId() . ")"
479 );
480 }
481
482 // feedback mail
483 if ($this->exc->hasTutorFeedbackMail()) {
484 $actions->addItem(
485 $this->lng->txt("exc_tbl_action_feedback_mail"),
486 "",
487 $ilCtrl->getLinkTarget($this->parent_obj, "redirectFeedbackMail")
488 );
489 }
490
491 // feedback files
492 if ($this->exc->hasTutorFeedbackFile()) {
493 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
494 $storage = new ilFSStorageExercise($this->exc->getId(), $a_ass->getId());
495 $counter = $storage->countFeedbackFiles($a_row["submission_obj"]->getFeedbackId());
497 ? " (" . $counter . ")"
498 : "";
499 $actions->addItem(
500 $this->lng->txt("exc_tbl_action_feedback_file") . $counter,
501 "",
502 $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles")
503 );
504 }
505
506 // comment (modal - see above)
507 if ($this->exc->hasTutorFeedbackText()) {
508 $actions->addItem(
509 $this->lng->txt("exc_tbl_action_feedback_text"),
510 "",
511 "#",
512 "",
513 "",
514 "",
515 "",
516 false,
517 "il.ExcManagement.showComment('" . $comment_id . "')"
518 );
519 }
520
521 // peer review
522 if (($peer_review = $a_row["submission_obj"]->getPeerReview()) && $a_ass->afterDeadlineStrict()) { // see #22246
523 $counter = $peer_review->countGivenFeedback(true, $a_user_id);
525 ? " (" . $counter . ")"
526 : "";
527 $actions->addItem(
528 $this->lng->txt("exc_tbl_action_peer_review_given") . $counter,
529 "",
530 $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showGivenPeerReview")
531 );
532
533 $counter = sizeof($peer_review->getPeerReviewsByPeerId($a_user_id, true));
535 ? " (" . $counter . ")"
536 : "";
537 $actions->addItem(
538 $this->lng->txt("exc_tbl_action_peer_review_received") . $counter,
539 "",
540 $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showReceivedPeerReview")
541 );
542 }
543
544 // team
545 if ($has_no_team_yet) {
546 $actions->addItem(
547 $this->lng->txt("exc_create_team"),
548 "",
549 $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "createSingleMemberTeam")
550 );
551 } elseif ($a_ass->hasTeam()) {
552 $actions->addItem(
553 $this->lng->txt("exc_tbl_action_team_log"),
554 "",
555 $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "showTeamLog")
556 );
557 }
558
559 $this->tpl->setVariable("ACTIONS", $actions->getHTML());
560 }
561
562 public function render()
563 {
564 global $DIC;
566 $tpl = $DIC->ui()->mainTemplate();
567
568 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "saveCommentForLearners", "", true, false);
569
570 $tpl->addJavaScript("Modules/Exercise/js/ilExcManagement.js");
571 $tpl->addOnLoadCode('il.ExcManagement.init("' . $url . '");');
572
573 return parent::render() .
574 implode("\n", $this->comment_modals);
575 }
576}
if(! $in) $columns
Definition: Utf8Test.php:45
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
User interface class for advanced drop-down selection lists.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand=false)
Get team id for member id.
Exercise assignment.
afterDeadlineStrict($a_include_personal=true)
getId()
Get assignment id.
parseRow($a_user_id, ilExAssignment $a_ass, array $a_row)
__construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item_id)
Constructor.
static get($a_glyph, $a_text="")
Get glyph html.
static getInstance()
Get instance.
Class ilObjExercise.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
This class represents a property form user interface.
Class ilTable2GUI.
getParentCmd()
Get parent command.
getSelectedColumns()
Get selected columns.
getParentObject()
Get parent object.
setData($a_data)
set table data @access public
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
setShowTemplates($a_value)
Toggle templates.
This class represents a text area property in a property form.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$counter
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
$info
Definition: index.php:5
$url
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
$cols
Definition: xhr_table.php:11