ILIAS  Release_4_2_x_branch Revision 61807
 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  $this->setData(ilExAssignment::getMemberListData($this->exc_id, $this->ass_id));
38  $this->setTitle($lng->txt("exc_assignment").": ".
39  ilExAssignment::lookupTitle($a_ass_id));
40  $this->setTopCommands(true);
41  //$this->setLimit(9999);
42 
43  $this->addColumn("", "", "1", true);
44  $this->addColumn($this->lng->txt("image"), "", "1");
45  $this->addColumn($this->lng->txt("name"), "name");
46  $this->addColumn($this->lng->txt("login"), "login");
47  $this->sent_col = ilExAssignment::lookupAnyExerciseSent($this->exc->getId(), $this->ass_id);
48  if ($this->sent_col)
49  {
50  $this->addColumn($this->lng->txt("exc_exercise_sent"), "sent_time");
51  }
52  $this->addColumn($this->lng->txt("exc_submission"), "submission");
53  $this->addColumn($this->lng->txt("exc_grading"), "solved_time");
54  $this->addColumn($this->lng->txt("feedback"), "feedback_time");
55 
56  $this->setDefaultOrderField("name");
57  $this->setDefaultOrderDirection("asc");
58 
59  $this->setEnableHeader(true);
60  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
61  $this->setRowTemplate("tpl.exc_members_row.html", "Modules/Exercise");
62  //$this->disable("footer");
63  $this->setEnableTitle(true);
64  $this->setSelectAllCheckbox("member");
65 
66  $this->addMultiCommand("saveStatus", $lng->txt("exc_save_changes"));
67  $this->addMultiCommand("redirectFeedbackMail", $lng->txt("exc_send_mail"));
68  $this->addMultiCommand("sendMembers", $lng->txt("exc_send_assignment"));
69  $this->addMultiCommand("confirmDeassignMembers", $lng->txt("exc_deassign_members"));
70 
71  //if(count($this->exc->members_obj->getAllDeliveredFiles()))
72  if (count(ilExAssignment::getAllDeliveredFiles($this->exc_id, $this->ass_id)))
73  {
74  $this->addCommandButton("downloadAll", $lng->txt("download_all_returned_files"));
75  }
76 
77  $this->type = ilExAssignment::lookupType($this->ass_id);
78  }
79 
83  protected function fillRow($member)
84  {
85  global $lng, $ilCtrl;
86 
87  include_once "./classes/class.ilObjectFactory.php";
88  $member_id = $member["usr_id"];
89 
90  if(!($mem_obj = ilObjectFactory::getInstanceByObjId($member_id,false)))
91  {
92  return;
93  }
94 
95  // mail sent
96  if ($this->sent_col)
97  {
98  if (ilExAssignment::lookupStatusSentOfUser($this->ass_id, $member_id))
99  {
100  $this->tpl->setCurrentBlock("mail_sent");
101  if (($st = ilExAssignment::lookupSentTimeOfUser($this->ass_id,
102  $member_id)) > 0)
103  {
104  $this->tpl->setVariable("TXT_MAIL_SENT",
105  sprintf($lng->txt("exc_sent_at"),
107  }
108  else
109  {
110  $this->tpl->setVariable("TXT_MAIL_SENT",
111  $lng->txt("sent"));
112  }
113  $this->tpl->parseCurrentBlock();
114  }
115  else
116  {
117  $this->tpl->setCurrentBlock("mail_sent");
118  $this->tpl->setVariable("TXT_MAIL_SENT",
119  "&nbsp;");
120  $this->tpl->parseCurrentBlock();
121  }
122  }
123 
124  // checkbox
125  $this->tpl->setVariable("VAL_CHKBOX",
126  ilUtil::formCheckbox(0,"member[$member_id]",1));
127  $this->tpl->setVariable("VAL_ID",
128  $member_id);
129 
130  // name and login
131  $this->tpl->setVariable("TXT_NAME",
132  $member["name"]);
133  $this->tpl->setVariable("TXT_LOGIN",
134  "[".$member["login"]."]");
135 
136  // image
137  $this->tpl->setVariable("USR_IMAGE",
138  $mem_obj->getPersonalPicturePath("xxsmall"));
139  $this->tpl->setVariable("USR_ALT", $lng->txt("personal_picture"));
140 
141  // submission:
142  // see if files have been resubmmited after solved
143  $last_sub =
144  ilExAssignment::getLastSubmission($this->ass_id, $member_id);
145  if ($last_sub)
146  {
147  $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub,IL_CAL_DATETIME));
148  }
149  else
150  {
151  $last_sub = "---";
152  }
153  if (ilExAssignment::lookupUpdatedSubmission($this->ass_id, $member_id) == 1)
154  {
155  $last_sub = "<b>".$last_sub."</b>";
156  }
157  $this->tpl->setVariable("VAL_LAST_SUBMISSION", $last_sub);
158  $this->tpl->setVariable("TXT_LAST_SUBMISSION",
159  $lng->txt("exc_last_submission"));
160 
161  switch($this->type)
162  {
164  // nr of submitted files
165  $this->tpl->setVariable("TXT_SUBMITTED_FILES",
166  $lng->txt("exc_files_returned"));
167  //$sub_cnt = count($this->exc->getDeliveredFiles($member_id, $this->ass_id));
168  $sub_cnt = count(ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id));
169  $new = ilExAssignment::lookupNewFiles($this->ass_id, $member_id);
170  if (count($new) > 0)
171  {
172  $sub_cnt.= " ".sprintf($lng->txt("cnt_new"),count($new));
173  }
174  $this->tpl->setVariable("VAL_SUBMITTED_FILES",
175  $sub_cnt);
176 
177  // download command
178  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
179  if ($sub_cnt > 0)
180  {
181  $this->tpl->setCurrentBlock("download_link");
182  $this->tpl->setVariable("LINK_DOWNLOAD",
183  $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
184  if (count($new) <= 0)
185  {
186  $this->tpl->setVariable("TXT_DOWNLOAD",
187  $lng->txt("exc_download_files"));
188  }
189  else
190  {
191  $this->tpl->setVariable("TXT_DOWNLOAD",
192  $lng->txt("exc_download_all"));
193  }
194  $this->tpl->parseCurrentBlock();
195 
196  // download new files only
197  if (count($new) > 0)
198  {
199  $this->tpl->setCurrentBlock("download_link");
200  $this->tpl->setVariable("LINK_NEW_DOWNLOAD",
201  $ilCtrl->getLinkTarget($this->parent_obj, "downloadNewReturned"));
202  $this->tpl->setVariable("TXT_NEW_DOWNLOAD",
203  $lng->txt("exc_download_new"));
204  $this->tpl->parseCurrentBlock();
205  }
206  }
207  break;
208 
210  $has_submitted = false;
211  $this->tpl->setVariable("TXT_SUBMITTED_FILES",
212  $lng->txt("exc_blog_returned"));
213  $blogs = ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id);
214  if($blogs)
215  {
216  $blogs = array_pop($blogs);
217  if($blogs && substr($blogs["filename"], -1) != "/")
218  {
219  $has_submitted = true;
220  $this->tpl->setVariable("VAL_SUBMITTED_FILES", 1);
221 
222  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
223  $this->tpl->setCurrentBlock("download_link");
224  $this->tpl->setVariable("LINK_DOWNLOAD",
225  $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
226  $this->tpl->setVariable("TXT_DOWNLOAD",
227  $lng->txt("exc_download_files"));
228  $this->tpl->parseCurrentBlock();
229  }
230  }
231  if(!$has_submitted)
232  {
233  $this->tpl->setVariable("VAL_SUBMITTED_FILES", "---");
234  }
235  break;
236 
238  $has_submitted = false;
239  $this->tpl->setVariable("TXT_SUBMITTED_FILES",
240  $lng->txt("exc_portfolio_returned"));
241  $portfolios = ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id);
242  if($portfolios)
243  {
244  $portfolios = array_pop($portfolios);
245  if($portfolios && substr($portfolios["filename"], -1) != "/")
246  {
247  $has_submitted = true;
248  $this->tpl->setVariable("VAL_SUBMITTED_FILES", 1);
249 
250  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
251  $this->tpl->setCurrentBlock("download_link");
252  $this->tpl->setVariable("LINK_DOWNLOAD",
253  $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
254  $this->tpl->setVariable("TXT_DOWNLOAD",
255  $lng->txt("exc_download_files"));
256  $this->tpl->parseCurrentBlock();
257  }
258  }
259  if(!$has_submitted)
260  {
261  $this->tpl->setVariable("VAL_SUBMITTED_FILES", "---");
262  }
263  break;
264  }
265 
266 
267 
268  // note
269  $this->tpl->setVariable("TXT_NOTE", $lng->txt("note"));
270  $this->tpl->setVariable("NAME_NOTE",
271  "notice[$member_id]");
272  $this->tpl->setVariable("VAL_NOTE",
274 
275  // comment for learner
276  $this->tpl->setVariable("TXT_LCOMMENT", $lng->txt("exc_comment_for_learner"));
277  $this->tpl->setVariable("NAME_LCOMMENT",
278  "lcomment[$member_id]");
279  $lpcomment = ilExAssignment::lookupCommentForUser($this->ass_id, $member_id);
280  $this->tpl->setVariable("VAL_LCOMMENT",
281  ilUtil::prepareFormOutput($lpcomment));
282 
283  // solved
284  //$this->tpl->setVariable("CHKBOX_SOLVED",
285  // ilUtil::formCheckbox($this->exc->members_obj->getStatusByMember($member_id),"solved[$member_id]",1));
286  $status = ilExAssignment::lookupStatusOfUser($this->ass_id, $member_id);
287  $this->tpl->setVariable("SEL_".strtoupper($status), ' selected="selected" ');
288  $this->tpl->setVariable("TXT_NOTGRADED", $lng->txt("exc_notgraded"));
289  $this->tpl->setVariable("TXT_PASSED", $lng->txt("exc_passed"));
290  $this->tpl->setVariable("TXT_FAILED", $lng->txt("exc_failed"));
291  if (($sd = ilExAssignment::lookupStatusTimeOfUser($this->ass_id, $member_id)) > 0)
292  {
293  $this->tpl->setCurrentBlock("status_date");
294  $this->tpl->setVariable("TXT_LAST_CHANGE", $lng->txt("last_change"));
295  $this->tpl->setVariable('VAL_STATUS_DATE',
297  $this->tpl->parseCurrentBlock();
298  }
299  switch($status)
300  {
301  case "passed": $pic = "scorm/passed.gif"; break;
302  case "failed": $pic = "scorm/failed.gif"; break;
303  default: $pic = "scorm/not_attempted.gif"; break;
304  }
305  $this->tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
306  $this->tpl->setVariable("ALT_STATUS", $lng->txt("exc_".$status));
307 
308  // mark
309  $this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
310  $this->tpl->setVariable("NAME_MARK",
311  "mark[$member_id]");
312  $mark = ilExAssignment::lookupMarkOfUser($this->ass_id, $member_id);
313  $this->tpl->setVariable("VAL_MARK",
315 
316  // feedback
317  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
318  if (($ft = ilExAssignment::lookupFeedbackTimeOfUser($this->ass_id, $member_id)) > 0)
319  {
320  $this->tpl->setCurrentBlock("feedback_date");
321  $this->tpl->setVariable("TXT_FEEDBACK_MAIL_SENT",
322  sprintf($lng->txt("exc_sent_at"),
324  $this->tpl->parseCurrentBlock();
325  }
326 
327  // feedback mail
328  $ilCtrl->setParameter($this, "rcp_to", $mem_obj->getLogin());
329  $this->tpl->setVariable("LINK_FEEDBACK",
330  $ilCtrl->getLinkTarget($this->parent_obj, "redirectFeedbackMail"));
331  $this->tpl->setVariable("TXT_FEEDBACK",
332  $lng->txt("exc_send_mail"));
333  $ilCtrl->setParameter($this->parent_obj, "rcp_to", "");
334 
335  // file feedback
336  $cnt_files = $this->storage->countFeedbackFiles($member_id);
337  $ilCtrl->setParameter($this->parent_obj, "fsmode", "feedback");
338  $this->tpl->setVariable("LINK_FILE_FEEDBACK",
339  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
340  if ($cnt_files == 0)
341  {
342  $this->tpl->setVariable("TXT_FILE_FEEDBACK",
343  $lng->txt("exc_add_feedback_file"));
344  }
345  else
346  {
347  $this->tpl->setVariable("TXT_FILE_FEEDBACK",
348  $lng->txt("exc_fb_files")." (".$cnt_files.")");
349  }
350 
351  $this->tpl->parseCurrentBlock();
352  }
353 
354 }
355 ?>