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