ILIAS  Release_4_1_x_branch Revision 61804
 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 
81  protected function fillRow($member)
82  {
83  global $lng, $ilCtrl;
84 
85  include_once "./classes/class.ilObjectFactory.php";
86  $member_id = $member["usr_id"];
87 
88  if(!($mem_obj = ilObjectFactory::getInstanceByObjId($member_id,false)))
89  {
90  continue;
91  }
92 
93  // mail sent
94  if ($this->sent_col)
95  {
96  if (ilExAssignment::lookupStatusSentOfUser($this->ass_id, $member_id))
97  {
98  $this->tpl->setCurrentBlock("mail_sent");
99  if (($st = ilExAssignment::lookupSentTimeOfUser($this->ass_id,
100  $member_id)) > 0)
101  {
102  $this->tpl->setVariable("TXT_MAIL_SENT",
103  sprintf($lng->txt("exc_sent_at"),
105  }
106  else
107  {
108  $this->tpl->setVariable("TXT_MAIL_SENT",
109  $lng->txt("sent"));
110  }
111  $this->tpl->parseCurrentBlock();
112  }
113  else
114  {
115  $this->tpl->setCurrentBlock("mail_sent");
116  $this->tpl->setVariable("TXT_MAIL_SENT",
117  "&nbsp;");
118  $this->tpl->parseCurrentBlock();
119  }
120  }
121 
122  // checkbox
123  $this->tpl->setVariable("VAL_CHKBOX",
124  ilUtil::formCheckbox(0,"member[$member_id]",1));
125  $this->tpl->setVariable("VAL_ID",
126  $member_id);
127 
128  // name and login
129  $this->tpl->setVariable("TXT_NAME",
130  $member["name"]);
131  $this->tpl->setVariable("TXT_LOGIN",
132  "[".$member["login"]."]");
133 
134  // image
135  $this->tpl->setVariable("USR_IMAGE",
136  $mem_obj->getPersonalPicturePath("xxsmall"));
137  $this->tpl->setVariable("USR_ALT", $lng->txt("personal_picture"));
138 
139  // submission:
140  // see if files have been resubmmited after solved
141  $last_sub =
142  ilExAssignment::getLastSubmission($this->ass_id, $member_id);
143  if ($last_sub)
144  {
145  $last_sub = ilDatePresentation::formatDate(new ilDateTime($last_sub,IL_CAL_DATETIME));
146  }
147  else
148  {
149  $last_sub = "---";
150  }
151  if (ilExAssignment::lookupUpdatedSubmission($this->ass_id, $member_id) == 1)
152  {
153  $last_sub = "<b>".$last_sub."</b>";
154  }
155  $this->tpl->setVariable("VAL_LAST_SUBMISSION", $last_sub);
156  $this->tpl->setVariable("TXT_LAST_SUBMISSION",
157  $lng->txt("exc_last_submission"));
158 
159  // nr of submitted files
160  $this->tpl->setVariable("TXT_SUBMITTED_FILES",
161  $lng->txt("exc_files_returned"));
162  //$sub_cnt = count($this->exc->getDeliveredFiles($member_id, $this->ass_id));
163  $sub_cnt = count(ilExAssignment::getDeliveredFiles($this->exc_id, $this->ass_id, $member_id));
164  $new = ilExAssignment::lookupNewFiles($this->ass_id, $member_id);
165  if (count($new) > 0)
166  {
167  $sub_cnt.= " ".sprintf($lng->txt("cnt_new"),count($new));
168  }
169  $this->tpl->setVariable("VAL_SUBMITTED_FILES",
170  $sub_cnt);
171 
172  // download command
173  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
174  if ($sub_cnt > 0)
175  {
176  $this->tpl->setCurrentBlock("download_link");
177  $this->tpl->setVariable("LINK_DOWNLOAD",
178  $ilCtrl->getLinkTarget($this->parent_obj, "downloadReturned"));
179  if (count($new) <= 0)
180  {
181  $this->tpl->setVariable("TXT_DOWNLOAD",
182  $lng->txt("exc_download_files"));
183  }
184  else
185  {
186  $this->tpl->setVariable("TXT_DOWNLOAD",
187  $lng->txt("exc_download_all"));
188  }
189  $this->tpl->parseCurrentBlock();
190 
191  // download new files only
192  if (count($new) > 0)
193  {
194  $this->tpl->setCurrentBlock("download_link");
195  $this->tpl->setVariable("LINK_NEW_DOWNLOAD",
196  $ilCtrl->getLinkTarget($this->parent_obj, "downloadNewReturned"));
197  $this->tpl->setVariable("TXT_NEW_DOWNLOAD",
198  $lng->txt("exc_download_new"));
199  $this->tpl->parseCurrentBlock();
200  }
201  }
202 
203  // note
204  $this->tpl->setVariable("TXT_NOTE", $lng->txt("note"));
205  $this->tpl->setVariable("NAME_NOTE",
206  "notice[$member_id]");
207  $this->tpl->setVariable("VAL_NOTE",
209 
210  // comment for learner
211  $this->tpl->setVariable("TXT_LCOMMENT", $lng->txt("exc_comment_for_learner"));
212  $this->tpl->setVariable("NAME_LCOMMENT",
213  "lcomment[$member_id]");
214  $lpcomment = ilExAssignment::lookupCommentForUser($this->ass_id, $member_id);
215  $this->tpl->setVariable("VAL_LCOMMENT",
216  ilUtil::prepareFormOutput($lpcomment));
217 
218  // solved
219  //$this->tpl->setVariable("CHKBOX_SOLVED",
220  // ilUtil::formCheckbox($this->exc->members_obj->getStatusByMember($member_id),"solved[$member_id]",1));
221  $status = ilExAssignment::lookupStatusOfUser($this->ass_id, $member_id);
222  $this->tpl->setVariable("SEL_".strtoupper($status), ' selected="selected" ');
223  $this->tpl->setVariable("TXT_NOTGRADED", $lng->txt("exc_notgraded"));
224  $this->tpl->setVariable("TXT_PASSED", $lng->txt("exc_passed"));
225  $this->tpl->setVariable("TXT_FAILED", $lng->txt("exc_failed"));
226  if (($sd = ilExAssignment::lookupStatusTimeOfUser($this->ass_id, $member_id)) > 0)
227  {
228  $this->tpl->setCurrentBlock("status_date");
229  $this->tpl->setVariable("TXT_LAST_CHANGE", $lng->txt("last_change"));
230  $this->tpl->setVariable('VAL_STATUS_DATE',
232  $this->tpl->parseCurrentBlock();
233  }
234  switch($status)
235  {
236  case "passed": $pic = "scorm/passed.gif"; break;
237  case "failed": $pic = "scorm/failed.gif"; break;
238  default: $pic = "scorm/not_attempted.gif"; break;
239  }
240  $this->tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
241  $this->tpl->setVariable("ALT_STATUS", $lng->txt("exc_".$status));
242 
243  // mark
244  $this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
245  $this->tpl->setVariable("NAME_MARK",
246  "mark[$member_id]");
247  $mark = ilExAssignment::lookupMarkOfUser($this->ass_id, $member_id);
248  $this->tpl->setVariable("VAL_MARK",
250 
251  // feedback
252  $ilCtrl->setParameter($this->parent_obj, "member_id", $member_id);
253  if (($ft = ilExAssignment::lookupFeedbackTimeOfUser($this->ass_id, $member_id)) > 0)
254  {
255  $this->tpl->setCurrentBlock("feedback_date");
256  $this->tpl->setVariable("TXT_FEEDBACK_MAIL_SENT",
257  sprintf($lng->txt("exc_sent_at"),
259  $this->tpl->parseCurrentBlock();
260  }
261 
262  // feedback mail
263  $ilCtrl->setParameter($this, "rcp_to", $mem_obj->getLogin());
264  $this->tpl->setVariable("LINK_FEEDBACK",
265  $ilCtrl->getLinkTarget($this->parent_obj, "redirectFeedbackMail"));
266  $this->tpl->setVariable("TXT_FEEDBACK",
267  $lng->txt("exc_send_mail"));
268  $ilCtrl->setParameter($this->parent_obj, "rcp_to", "");
269 
270  // file feedback
271  $cnt_files = $this->storage->countFeedbackFiles($member_id);
272  $ilCtrl->setParameter($this->parent_obj, "fsmode", "feedback");
273  $this->tpl->setVariable("LINK_FILE_FEEDBACK",
274  $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"));
275  if ($cnt_files == 0)
276  {
277  $this->tpl->setVariable("TXT_FILE_FEEDBACK",
278  $lng->txt("exc_add_feedback_file"));
279  }
280  else
281  {
282  $this->tpl->setVariable("TXT_FILE_FEEDBACK",
283  $lng->txt("exc_fb_files")." (".$cnt_files.")");
284  }
285 
286  $this->tpl->parseCurrentBlock();
287  }
288 
289 }
290 ?>