ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPProgressTableGUI.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/Tracking/classes/class.ilLPTableBaseGUI.php");
5 
16 {
20  function __construct($a_parent_obj, $a_parent_cmd, $a_user = "", $obj_ids = NULL, $details = false, $mode = null, $personal_only = false, $a_parent_id = null)
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng, $ilObjDataCache, $ilUser;
23 
24  $this->tracked_user = $a_user;
25  $this->obj_ids = $obj_ids;
26  $this->details = $details;
27  $this->mode = $mode;
28  $this->parent_obj_id = $a_parent_id;
29 
30  $this->setId("lpprgtbl");
31 
32  parent::__construct($a_parent_obj, $a_parent_cmd);
33 
34  $this->setLimit(9999);
35 
36  if(!$this->details)
37  {
38  $user = $this->tracked_user;
39  if(!$user)
40  {
41  $user = $ilUser;
42  }
43 
44  $this->addColumn("", "", "1", true);
45  $this->addColumn($this->lng->txt("trac_title"), "title", "26%");
46  $this->addColumn($this->lng->txt("status"), "status", "7%");
47  $this->addColumn($this->lng->txt('trac_status_changed'),'status_changed','10%');
48  $this->addColumn($this->lng->txt("trac_percentage"), "percentage", "7%");
49  $this->addColumn($this->lng->txt("trac_mark"), "", "5%");
50  $this->addColumn($this->lng->txt("comment"), "", "10%");
51  $this->addColumn($this->lng->txt("trac_mode"), "", "20%");
52  $this->addColumn($this->lng->txt("path"), "", "20%");
53  $this->addColumn($this->lng->txt("actions"), "", "5%");
54 
55  $this->setTitle(sprintf($this->lng->txt("trac_learning_progress_of"), $user->getFullName()));
56  $this->initFilter();
57 
58  $this->setSelectAllCheckbox("item_id");
59  $this->addMultiCommand("hideSelected", $lng->txt("trac_hide_selected"));
60  }
61  else
62  {
63  if(!$personal_only)
64  {
65  $this->parseTitle($a_parent_obj->details_obj_id, "trac_subitems");
66  }
67  else
68  {
69  $this->parseTitle($a_parent_obj->details_obj_id, "trac_progress");
70  }
71 
72  $this->addColumn($this->lng->txt("trac_title"), "title", "31%");
73  $this->addColumn($this->lng->txt("status"), "status", "7%");
74 
75  if($this->mode != LP_MODE_SCORM && $this->mode != LP_MODE_OBJECTIVES)
76  {
77  $this->addColumn($this->lng->txt('trac_status_changed'),'status_changed','10%');
78  $this->addColumn($this->lng->txt("trac_percentage"), "percentage", "7%");
79  $this->addColumn($this->lng->txt("trac_mark"), "", "5%");
80  $this->addColumn($this->lng->txt("comment"), "", "10%");
81  $this->addColumn($this->lng->txt("trac_mode"), "", "20%");
82  $this->addColumn($this->lng->txt("path"), "", "20%");
83  }
84  }
85 
86  $this->setEnableHeader(true);
87  $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
88  $this->setRowTemplate("tpl.lp_progress_list_row.html", "Services/Tracking");
89  $this->setEnableHeader(true);
90  $this->setEnableNumInfo(true);
91  $this->setEnableTitle(true);
92  $this->setDefaultOrderField("title");
93  $this->setDefaultOrderDirection("asc");
94  $this->setShowTemplates(true);
95 
96  if($this->mode != LP_MODE_SCORM && $this->mode != LP_MODE_OBJECTIVES)
97  {
98  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
99  }
100 
101  // area selector gets in the way
102  if($this->tracked_user)
103  {
104  $this->getItems();
105  }
106  }
107 
108  function getItems()
109  {
110  $obj_ids = $this->obj_ids;
111  if(!$obj_ids && !$this->details)
112  {
113  // restrict courses/groups to objects where current user is member
114  $membership_ids = null;
115  if($this->filter["type"] == "crs" || $this->filter["type"] == "grp")
116  {
117  include_once "Services/Membership/classes/class.ilParticipants.php";
118  $membership_ids = ilParticipants::_getMembershipByType($this->tracked_user->getId(),
119  $this->filter["type"]);
120  }
121  if($membership_ids === null || sizeof($membership_ids))
122  {
123  $obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read",
124  $membership_ids);
125  }
126  }
127  if($obj_ids)
128  {
129  include_once("./Services/Tracking/classes/class.ilTrQuery.php");
130  switch($this->mode)
131  {
132  case LP_MODE_SCORM:
133  $data = ilTrQuery::getSCOsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids);
134  break;
135 
136  case LP_MODE_OBJECTIVES:
137  $data = ilTrQuery::getObjectivesStatusForUser($this->tracked_user->getId(), $obj_ids);
138  break;
139 
140  default:
141  $data = ilTrQuery::getObjectsStatusForUser($this->tracked_user->getId(), $obj_ids);
142  foreach($data as $idx => $item)
143  {
144  $data[$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($item["obj_id"], $item["type"]);
145  }
146  break;
147  }
148  $this->setData($data);
149  }
150  }
151 
155  protected function fillRow($a_set)
156  {
157  global $ilObjDataCache, $ilCtrl;
158 
159  if(!$this->details)
160  {
161  $this->tpl->setCurrentBlock("column_checkbox");
162  $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
163  $this->tpl->parseCurrentBlock();
164  }
165 
166  $this->tpl->setVariable("ICON_SRC", ilUtil::getTypeIconPath($a_set["type"], $a_set["obj_id"], "tiny"));
167  $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
168  $this->tpl->setVariable("TITLE_TEXT", $a_set["title"]);
169 
170  if($a_set["offline"])
171  {
172  $this->tpl->setCurrentBlock("offline");
173  $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
174  $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline"));
175  $this->tpl->parseCurrentBlock();
176  }
177 
178  $this->tpl->setVariable("STATUS_ALT", ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
179  $this->tpl->setVariable("STATUS_IMG", ilLearningProgressBaseGUI::_getImagePathForStatus($a_set["status"]));
180 
181  if($this->mode != LP_MODE_SCORM && $this->mode != LP_MODE_OBJECTIVES)
182  {
183  $this->tpl->setCurrentBlock("status_details");
184 
185  $this->tpl->setVariable('STATUS_CHANGED_VAL', ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
186 
187  $this->tpl->setVariable("MODE_TEXT", ilLPObjSettings::_mode2Text($a_set["u_mode"]));
188  $this->tpl->setVariable("MARK_VALUE", $a_set["mark"]);
189  $this->tpl->setVariable("COMMENT_TEXT", $a_set["comment"]);
190 
191  if(!$this->isPercentageAvailable($a_set["obj_id"]) || (int)$a_set["percentage"] === 0)
192  {
193  $this->tpl->setVariable("PERCENTAGE_VALUE", "");
194  }
195  else
196  {
197  $this->tpl->setVariable("PERCENTAGE_VALUE", sprintf("%d%%", $a_set["percentage"]));
198  }
199 
200  // path
201  $path = $this->buildPath($a_set["ref_ids"]);
202  if($path)
203  {
204  $this->tpl->setCurrentBlock("item_path");
205  foreach($path as $path_item)
206  {
207  $this->tpl->setVariable("PATH_ITEM", $path_item);
208  $this->tpl->parseCurrentBlock();
209  }
210  }
211 
212  $this->tpl->parseCurrentBlock();
213  }
214 
215  // not for objectives/scos
216  if(!$this->mode)
217  {
218  // tlt warning
219  if($a_set["status"] != LP_STATUS_COMPLETED_NUM && $a_set["ref_ids"])
220  {
221  $ref_id = $a_set["ref_ids"];
222  $ref_id = array_shift($ref_id);
223  $timing = $this->showTimingsWarning($ref_id, $this->tracked_user->getId());
224  if($timing)
225  {
226  if($timing !== true)
227  {
228  $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX));
229  }
230  else
231  {
232  $timing = "";
233  }
234  $this->tpl->setCurrentBlock('warning_img');
235  $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.gif'));
236  $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing);
237  $this->tpl->parseCurrentBlock();
238  }
239  }
240 
241  // hide / unhide?!
242  if(!$this->details)
243  {
244  $this->tpl->setCurrentBlock("item_command");
245  $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
246  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
247  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
248  $this->tpl->parseCurrentBlock();
249 
250  if(ilLPObjSettings::_isContainer($a_set["u_mode"]) && $a_set["ref_ids"])
251  {
252  $ref_id = $a_set["ref_ids"];
253  $ref_id = array_shift($ref_id);
254  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
255  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
256  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
257  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_subitems'));
258  $this->tpl->parseCurrentBlock();
259  }
260 
261  $this->tpl->setCurrentBlock("column_action");
262  $this->tpl->parseCurrentBlock();
263  }
264  }
265  }
266 
267  protected function fillHeaderExcel($worksheet, &$a_row)
268  {
269  $worksheet->write($a_row, 0, $this->lng->txt("type"));
270  $worksheet->write($a_row, 1, $this->lng->txt("trac_title"));
271  $worksheet->write($a_row, 2, $this->lng->txt("status"));
272  $worksheet->write($a_row, 3, $this->lng->txt("trac_status_changed"));
273  $worksheet->write($a_row, 4, $this->lng->txt("trac_percentage"));
274  $worksheet->write($a_row, 5, $this->lng->txt("trac_mark"));
275  $worksheet->write($a_row, 6, $this->lng->txt("comment"));
276  $worksheet->write($a_row, 7, $this->lng->txt("trac_mode"));
277  // $worksheet->write($a_row, 7, $this->lng->txt("path"));
278  }
279 
280  protected function fillRowExcel($worksheet, &$a_row, $a_set)
281  {
282  $worksheet->write($a_row, 0, $this->lng->txt($a_set["type"]));
283  $worksheet->write($a_row, 1, $a_set["title"]);
284  $worksheet->write($a_row, 2, ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
285 
287  $worksheet->write($a_row, 3, ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
289 
290  $worksheet->write($a_row, 4, sprintf("%d%%", $a_set["percentage"]));
291  $worksheet->write($a_row, 5, $a_set["mark"]);
292  $worksheet->write($a_row, 6, $a_set["comment"]);
293  $worksheet->write($a_row, 7, ilLPObjSettings::_mode2Text($a_set["u_mode"]));
294 
295  /*
296  // path
297  $path = $this->buildPath($a_set["ref_ids"]);
298  if($path)
299  {
300  $col = 7;
301  foreach($path as $path_item)
302  {
303  $worksheet->write($a_row, $col, strip_tags($path_item));
304  $col++;
305  }
306  }
307  */
308 
309  }
310 
311  protected function fillHeaderCSV($a_csv)
312  {
313  $a_csv->addColumn($this->lng->txt("type"));
314  $a_csv->addColumn($this->lng->txt("trac_title"));
315  $a_csv->addColumn($this->lng->txt("status"));
316  $a_csv->addColumn($this->lng->txt("trac_status_changed"));
317  $a_csv->addColumn($this->lng->txt("trac_percentage"));
318  $a_csv->addColumn($this->lng->txt("trac_mark"));
319  $a_csv->addColumn($this->lng->txt("comment"));
320  $a_csv->addColumn($this->lng->txt("trac_mode"));
321  // $a_csv->addColumn($this->lng->txt("path"));
322  $a_csv->addRow();
323  }
324 
325  protected function fillRowCSV($a_csv, $a_set)
326  {
327  $a_csv->addColumn($this->lng->txt($a_set["type"]));
328  $a_csv->addColumn($a_set["title"]);
329  $a_csv->addColumn(ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
330 
332  $a_csv->addColumn(ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
334 
335  $a_csv->addColumn(sprintf("%d%%", $a_set["percentage"]));
336  $a_csv->addColumn($a_set["mark"]);
337  $a_csv->addColumn($a_set["comment"]);
338  $a_csv->addColumn(ilLPObjSettings::_mode2Text($a_set["u_mode"]));
339 
340  /*
341  // path
342  $path = $this->buildPath($a_set["ref_ids"]);
343  if($path)
344  {
345  $col = 7;
346  foreach($path as $path_item)
347  {
348  $a_csv->addColumn(strip_tags($path_item));
349  $col++;
350  }
351  }
352  */
353 
354  $a_csv->addRow();
355  }
356 }
357 
358 ?>