ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExerciseMemberTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 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 
16 {
17 
21  function __construct($a_parent_obj, $a_parent_cmd, $a_exc, $a_ass_id)
22  {
23  global $ilCtrl, $lng, $ilAccess, $lng;
24 
25  $this->exc = $a_exc;
26  $this->exc_id = $this->exc->getId();
27  $this->setId("exc_mem_".$a_ass_id);
28 
29 
30  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
31  $this->storage = new ilFSStorageExercise($this->exc_id, $a_ass_id);
32  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
33 
34  $this->ass_id = $a_ass_id;
35 
36  parent::__construct($a_parent_obj, $a_parent_cmd);
37 
38  $this->setTitle($lng->txt("exc_assignment").": ".
39  ilExAssignment::lookupTitle($a_ass_id));
40  $this->setTopCommands(true);
41  //$this->setLimit(9999);
42 
43  $this->type = ilExAssignment::lookupType($this->ass_id);
44 
45  $data = ilExAssignment::getMemberListData($this->exc_id, $this->ass_id);
46 
47  // team upload? (1 row == 1 team)
48  if($this->type == ilExAssignment::TYPE_UPLOAD_TEAM)
49  {
50  $ass_obj = new ilExAssignment($this->ass_id);
51 
52  $team_map = ilExAssignment::getAssignmentTeamMap($this->ass_id);
53  $tmp = array();
54 
55  foreach($data as $item)
56  {
57  $team_id = $team_map[$item["usr_id"]];
58 
59  if(!$team_id)
60  {
61  // #11058
62  // $team_id = $ass_obj->getTeamId($item["usr_id"], true);
63 
64  // #11957
65  $team_id = "nty".$item["usr_id"];
66  }
67 
68  if(!isset($tmp[$team_id]))
69  {
70  $tmp[$team_id] = $item;
71  }
72 
73  $tmp[$team_id]["team"][$item["usr_id"]] = $item["name"];
74  $tmp[$team_id]["team_id"] = $team_id;
75  }
76 
77  $data = $tmp;
78  unset($tmp);
79  }
80 
81  $this->setData($data);
82 
83  $this->addColumn("", "", "1", true);
84 
85  if($this->type != ilExAssignment::TYPE_UPLOAD_TEAM)
86  {
87  $this->addColumn($this->lng->txt("image"), "", "1");
88  $this->addColumn($this->lng->txt("name"), "name");
89  $this->addColumn($this->lng->txt("login"), "login");
90  }
91  else
92  {
93  $this->addColumn($this->lng->txt("exc_team"));
94  }
95 
96  $this->sent_col = ilExAssignment::lookupAnyExerciseSent($this->exc->getId(), $this->ass_id);
97  if ($this->sent_col)
98  {
99  $this->addColumn($this->lng->txt("exc_exercise_sent"), "sent_time");
100  }
101  $this->addColumn($this->lng->txt("exc_submission"), "submission");
102  $this->addColumn($this->lng->txt("exc_grading"), "solved_time");
103  $this->addColumn($this->lng->txt("feedback"), "feedback_time");
104 
105  $this->setDefaultOrderField("name");
106  $this->setDefaultOrderDirection("asc");
107 
108  $this->setEnableHeader(true);
109  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
110  $this->setRowTemplate("tpl.exc_members_row.html", "Modules/Exercise");
111  //$this->disable("footer");
112  $this->setEnableTitle(true);
113  $this->setSelectAllCheckbox("member");
114 
115  $this->addMultiCommand("saveStatus", $lng->txt("exc_save_changes"));
116  $this->addMultiCommand("redirectFeedbackMail", $lng->txt("exc_send_mail"));
117  $this->addMultiCommand("sendMembers", $lng->txt("exc_send_assignment"));
118  $this->addMultiCommand("confirmDeassignMembers", $lng->txt("exc_deassign_members"));
119 
120  //if(count($this->exc->members_obj->getAllDeliveredFiles()))
121  if (count(ilExAssignment::getAllDeliveredFiles($this->exc_id, $this->ass_id)))
122  {
123  $this->addCommandButton("downloadAll", $lng->txt("download_all_returned_files"));
124  }
125  }
126 
130  protected function fillRow($member)
131  {
132  global $lng, $ilCtrl;
133 
134  include_once "./Services/Object/classes/class.ilObjectFactory.php";
135  $member_id = $member["usr_id"];
136 
137  if(!($mem_obj = ilObjectFactory::getInstanceByObjId($member_id,false)))
138  {
139  return;
140  }
141 
142  $has_no_team_yet = (substr($member["team_id"], 0, 3) == "nty");
143 
144  if(!$has_no_team_yet)
145  {
146  // mail sent
147  if ($this->sent_col)
148  {
149  if (ilExAssignment::lookupStatusSentOfUser($this->ass_id, $member_id))
150  {
151  $this->tpl->setCurrentBlock("mail_sent");
152  if (($st = ilExAssignment::lookupSentTimeOfUser($this->ass_id,
153  $member_id)) > 0)
154  {
155  $this->tpl->setVariable("TXT_MAIL_SENT",
156  sprintf($lng->txt("exc_sent_at"),
158  }
159  else
160  {
161  $this->tpl->setVariable("TXT_MAIL_SENT",
162  $lng->txt("sent"));
163  }
164  $this->tpl->parseCurrentBlock();
165  }
166  else
167  {
168  $this->tpl->setCurrentBlock("mail_sent");
169  $this->tpl->setVariable("TXT_MAIL_SENT",
170  "&nbsp;");
171  $this->tpl->parseCurrentBlock();
172  }
173  }
174 
175  // checkbox
176  $this->tpl->setVariable("VAL_CHKBOX",
177  ilUtil::formCheckbox(0,"member[$member_id]",1));
178  $this->tpl->setVariable("VAL_ID",
179  $member_id);
180  }
181 
182  // name and login
183  if(!isset($member["team"]))
184  {
185  $this->tpl->setVariable("TXT_NAME",
186  $member["name"]);
187  $this->tpl->setVariable("TXT_LOGIN",
188  "[".$member["login"]."]");
189 
190  // image
191  $this->tpl->setVariable("USR_IMAGE",
192  $mem_obj->getPersonalPicturePath("xxsmall"));
193  $this->tpl->setVariable("USR_ALT", $lng->txt("personal_picture"));
194  }
195  // team upload
196  else
197  {
198  $this->tpl->setCurrentBlock("team_member");
199  asort($member["team"]);
200  foreach($member["team"] as $member_name) // #10749
201  {
202  $this->tpl->setVariable("TXT_MEMBER_NAME", $member_name);
203  $this->tpl->parseCurrentBlock();
204  }
205 
206  if(!$has_no_team_yet)
207  {
208  $this->tpl->setCurrentBlock("team_log");
209  $ilCtrl->setParameter($this->parent_obj, "lmem", $member_id);
210  $this->tpl->setVariable("HREF_LOG",
211  $ilCtrl->getLinkTarget($this->parent_obj, "showTeamLog"));
212  $this->tpl->setVariable("TXT_LOG", $lng->txt("exc_team_log"));
213  $ilCtrl->setParameter($this->parent_obj, "lmem", "");
214  $this->tpl->parseCurrentBlock();
215  }
216  else
217  {
218  // #11957
219  $this->tpl->setCurrentBlock("team_info");
220  $this->tpl->setVariable("TXT_TEAM_INFO", $lng->txt("exc_no_team_yet"));
221  $this->tpl->setVariable("TXT_CREATE_TEAM", $lng->txt("exc_create_team"));
222 
223  $ilCtrl->setParameter($this->parent_obj, "lmem", $member_id);
224  $this->tpl->setVariable("URL_CREATE_TEAM",
225  $ilCtrl->getLinkTarget($this->getParentObject(), "createSingleMemberTeam"));
226  $ilCtrl->setParameter($this->parent_obj, "lmem", "");
227 
228  $files_nr = count(ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id));
229  if($files_nr)
230  {
231  $this->tpl->setVariable("TEAM_FILES_INFO", "<br />".
232  $lng->txt("exc_files_returned").": ".$files_nr);
233  }
234  $this->tpl->parseCurrentBlock();
235  }
236  }
237 
238  if(!$has_no_team_yet)
239  {
240  // submission:
241  // see if files have been resubmmited after solved
242  $last_sub =
243  ilExAssignment::getLastSubmission($this->ass_id, $member_id);
244  if ($last_sub)
245  {
246  $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub,IL_CAL_DATETIME));
247  }
248  else
249  {
250  $last_sub = "---";
251  }
252  if (ilExAssignment::lookupUpdatedSubmission($this->ass_id, $member_id) == 1)
253  {
254  $last_sub = "<b>".$last_sub."</b>";
255  }
256  $this->tpl->setVariable("VAL_LAST_SUBMISSION", $last_sub);
257  $this->tpl->setVariable("TXT_LAST_SUBMISSION",
258  $lng->txt("exc_last_submission"));
259 
260  switch($this->type)
261  {
263  // data is merged by team - see above
264  // fallthrough
265 
267  // nr of submitted files
268  $this->tpl->setVariable("TXT_SUBMITTED_FILES",
269  $lng->txt("exc_files_returned"));
270  //$sub_cnt = count($this->exc->getDeliveredFiles($member_id, $this->ass_id));
271  $sub_cnt = count(ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id));
272  $new = ilExAssignment::lookupNewFiles($this->ass_id, $member_id);
273  if (count($new) > 0)
274  {
275  $sub_cnt.= " ".sprintf($lng->txt("cnt_new"),count($new));
276  }
277  $this->tpl->setVariable("VAL_SUBMITTED_FILES",
278  $sub_cnt);
279 
280  // download command
281  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
282  if ($sub_cnt > 0)
283  {
284  $this->tpl->setCurrentBlock("download_link");
285  $this->tpl->setVariable("LINK_DOWNLOAD",
286  $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
287  if (count($new) <= 0)
288  {
289  $this->tpl->setVariable("TXT_DOWNLOAD",
290  $lng->txt("exc_download_files"));
291  }
292  else
293  {
294  $this->tpl->setVariable("TXT_DOWNLOAD",
295  $lng->txt("exc_download_all"));
296  }
297  $this->tpl->parseCurrentBlock();
298 
299  // download new files only
300  if (count($new) > 0)
301  {
302  $this->tpl->setCurrentBlock("download_link");
303  $this->tpl->setVariable("LINK_NEW_DOWNLOAD",
304  $ilCtrl->getLinkTarget($this->parent_obj, "downloadNewReturned"));
305  $this->tpl->setVariable("TXT_NEW_DOWNLOAD",
306  $lng->txt("exc_download_new"));
307  $this->tpl->parseCurrentBlock();
308  }
309  }
310  break;
311 
313  $has_submitted = false;
314  $this->tpl->setVariable("TXT_SUBMITTED_FILES",
315  $lng->txt("exc_blog_returned"));
316  $blogs = ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id);
317  if($blogs)
318  {
319  $blogs = array_pop($blogs);
320  if($blogs && substr($blogs["filename"], -1) != "/")
321  {
322  $has_submitted = true;
323  $this->tpl->setVariable("VAL_SUBMITTED_FILES", 1);
324 
325  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
326  $this->tpl->setCurrentBlock("download_link");
327  $this->tpl->setVariable("LINK_DOWNLOAD",
328  $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
329  $this->tpl->setVariable("TXT_DOWNLOAD",
330  $lng->txt("exc_download_files"));
331  $this->tpl->parseCurrentBlock();
332  }
333  }
334  if(!$has_submitted)
335  {
336  $this->tpl->setVariable("VAL_SUBMITTED_FILES", "---");
337  }
338  break;
339 
341  $has_submitted = false;
342  $this->tpl->setVariable("TXT_SUBMITTED_FILES",
343  $lng->txt("exc_portfolio_returned"));
344  $portfolios = ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id);
345  if($portfolios)
346  {
347  $portfolios = array_pop($portfolios);
348  if($portfolios && substr($portfolios["filename"], -1) != "/")
349  {
350  $has_submitted = true;
351  $this->tpl->setVariable("VAL_SUBMITTED_FILES", 1);
352 
353  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
354  $this->tpl->setCurrentBlock("download_link");
355  $this->tpl->setVariable("LINK_DOWNLOAD",
356  $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
357  $this->tpl->setVariable("TXT_DOWNLOAD",
358  $lng->txt("exc_download_files"));
359  $this->tpl->parseCurrentBlock();
360  }
361  }
362  if(!$has_submitted)
363  {
364  $this->tpl->setVariable("VAL_SUBMITTED_FILES", "---");
365  }
366  break;
367  }
368 
369 
370 
371  // note
372  $this->tpl->setVariable("TXT_NOTE", $lng->txt("note"));
373  $this->tpl->setVariable("NAME_NOTE",
374  "notice[$member_id]");
375  $this->tpl->setVariable("VAL_NOTE",
377 
378  // comment for learner
379  $this->tpl->setVariable("TXT_LCOMMENT", $lng->txt("exc_comment_for_learner"));
380  $this->tpl->setVariable("NAME_LCOMMENT",
381  "lcomment[$member_id]");
382  $lpcomment = ilExAssignment::lookupCommentForUser($this->ass_id, $member_id);
383  $this->tpl->setVariable("VAL_LCOMMENT",
384  ilUtil::prepareFormOutput($lpcomment));
385 
386  // solved
387  //$this->tpl->setVariable("CHKBOX_SOLVED",
388  // ilUtil::formCheckbox($this->exc->members_obj->getStatusByMember($member_id),"solved[$member_id]",1));
389  $status = ilExAssignment::lookupStatusOfUser($this->ass_id, $member_id);
390  $this->tpl->setVariable("SEL_".strtoupper($status), ' selected="selected" ');
391  $this->tpl->setVariable("TXT_NOTGRADED", $lng->txt("exc_notgraded"));
392  $this->tpl->setVariable("TXT_PASSED", $lng->txt("exc_passed"));
393  $this->tpl->setVariable("TXT_FAILED", $lng->txt("exc_failed"));
394  if (($sd = ilExAssignment::lookupStatusTimeOfUser($this->ass_id, $member_id)) > 0)
395  {
396  $this->tpl->setCurrentBlock("status_date");
397  $this->tpl->setVariable("TXT_LAST_CHANGE", $lng->txt("last_change"));
398  $this->tpl->setVariable('VAL_STATUS_DATE',
400  $this->tpl->parseCurrentBlock();
401  }
402  switch($status)
403  {
404  case "passed": $pic = "scorm/passed.png"; break;
405  case "failed": $pic = "scorm/failed.png"; break;
406  default: $pic = "scorm/not_attempted.png"; break;
407  }
408  $this->tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
409  $this->tpl->setVariable("ALT_STATUS", $lng->txt("exc_".$status));
410 
411  // mark
412  $this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
413  $this->tpl->setVariable("NAME_MARK",
414  "mark[$member_id]");
415  $mark = ilExAssignment::lookupMarkOfUser($this->ass_id, $member_id);
416  $this->tpl->setVariable("VAL_MARK",
418 
419  // feedback
420  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
421  if (($ft = ilExAssignment::lookupFeedbackTimeOfUser($this->ass_id, $member_id)) > 0)
422  {
423  $this->tpl->setCurrentBlock("feedback_date");
424  $this->tpl->setVariable("TXT_FEEDBACK_MAIL_SENT",
425  sprintf($lng->txt("exc_sent_at"),
427  $this->tpl->parseCurrentBlock();
428  }
429 
430  // feedback mail
431  $this->tpl->setVariable("LINK_FEEDBACK",
432  $ilCtrl->getLinkTarget($this->parent_obj, "redirectFeedbackMail"));
433  $this->tpl->setVariable("TXT_FEEDBACK",
434  $lng->txt("exc_send_mail"));
435 
436  if($this->type == ilExAssignment::TYPE_UPLOAD_TEAM)
437  {
438  $feedback_id = "t".$member["team_id"];
439  }
440  else
441  {
442  $feedback_id = $member_id;
443  }
444 
445  // file feedback
446  $cnt_files = $this->storage->countFeedbackFiles($feedback_id);
447  $ilCtrl->setParameter($this->parent_obj, "fsmode", "feedback");
448  $this->tpl->setVariable("LINK_FILE_FEEDBACK",
449  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
450  if ($cnt_files == 0)
451  {
452  $this->tpl->setVariable("TXT_FILE_FEEDBACK",
453  $lng->txt("exc_add_feedback_file"));
454  }
455  else
456  {
457  $this->tpl->setVariable("TXT_FILE_FEEDBACK",
458  $lng->txt("exc_fb_files")." (".$cnt_files.")");
459  }
460 
461  $this->tpl->parseCurrentBlock();
462  }
463  else
464  {
465  $this->tpl->touchBlock("member_has_no_team_bl");
466  }
467  }
468 
469 }
470 ?>