ILIAS  release_4-3 Revision
 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)
76  {
77  $this->lng->loadLanguageModule('content');
78  $this->addColumn($this->lng->txt('cont_score'),'score','10%');
79  }
80  else if($this->mode != LP_MODE_OBJECTIVES)
81  {
82  $this->addColumn($this->lng->txt('trac_status_changed'),'status_changed','10%');
83  $this->addColumn($this->lng->txt("trac_percentage"), "percentage", "7%");
84  $this->addColumn($this->lng->txt("trac_mark"), "", "5%");
85  $this->addColumn($this->lng->txt("comment"), "", "10%");
86  $this->addColumn($this->lng->txt("trac_mode"), "", "20%");
87  $this->addColumn($this->lng->txt("path"), "", "20%");
88  }
89  }
90 
91  $this->setEnableHeader(true);
92  $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
93  $this->setRowTemplate("tpl.lp_progress_list_row.html", "Services/Tracking");
94  $this->setEnableHeader(true);
95  $this->setEnableNumInfo(true);
96  $this->setEnableTitle(true);
97  $this->setDefaultOrderField("title");
98  $this->setDefaultOrderDirection("asc");
99  $this->setShowTemplates(true);
100 
101  if($this->mode != LP_MODE_SCORM && $this->mode != LP_MODE_OBJECTIVES)
102  {
103  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
104  }
105 
106  // area selector gets in the way
107  if($this->tracked_user)
108  {
109  $this->getItems();
110  }
111  }
112 
113  function getItems()
114  {
115  $obj_ids = $this->obj_ids;
116  if(!$obj_ids && !$this->details)
117  {
118  // restrict courses/groups to objects where current user is member
119  $membership_ids = null;
120  if($this->filter["type"] == "crs" || $this->filter["type"] == "grp")
121  {
122  include_once "Services/Membership/classes/class.ilParticipants.php";
123  $membership_ids = ilParticipants::_getMembershipByType($this->tracked_user->getId(),
124  $this->filter["type"]);
125  }
126  if($membership_ids === null || sizeof($membership_ids))
127  {
128  $obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read",
129  $membership_ids);
130  }
131  }
132  if($obj_ids)
133  {
134  include_once("./Services/Tracking/classes/class.ilTrQuery.php");
135  switch($this->mode)
136  {
137  case LP_MODE_SCORM:
138  $data = ilTrQuery::getSCOsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids);
139  break;
140 
141  case LP_MODE_OBJECTIVES:
142  $data = ilTrQuery::getObjectivesStatusForUser($this->tracked_user->getId(), $obj_ids);
143  break;
144 
145  default:
146  $data = ilTrQuery::getObjectsStatusForUser($this->tracked_user->getId(), $obj_ids);
147  foreach($data as $idx => $item)
148  {
149  if(!$item["status"] && !$this->filter["status"])
150  {
151  unset($data[$idx]);
152  }
153  else
154  {
155  $data[$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($item["obj_id"], $item["type"]);
156  }
157  }
158  break;
159  }
160  $this->setData($data);
161  }
162  }
163 
167  protected function fillRow($a_set)
168  {
169  global $ilCtrl;
170 
171  if(!$this->details)
172  {
173  $this->tpl->setCurrentBlock("column_checkbox");
174  $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
175  $this->tpl->parseCurrentBlock();
176  }
177 
178  $this->tpl->setVariable("ICON_SRC", ilObject::_getIcon("", "tiny", $a_set["type"]));
179  $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
180  $this->tpl->setVariable("TITLE_TEXT", $a_set["title"]);
181 
182  if($a_set["offline"])
183  {
184  $this->tpl->setCurrentBlock("offline");
185  $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
186  $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline"));
187  $this->tpl->parseCurrentBlock();
188  }
189 
190  $this->tpl->setVariable("STATUS_ALT", ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
191  $this->tpl->setVariable("STATUS_IMG", ilLearningProgressBaseGUI::_getImagePathForStatus($a_set["status"]));
192 
193  if($this->mode == LP_MODE_SCORM)
194  {
195  $this->tpl->setVariable('SCORE_VAL', $a_set["score"]);
196  }
197  else if($this->mode != LP_MODE_OBJECTIVES)
198  {
199  $this->tpl->setCurrentBlock("status_details");
200 
201  $this->tpl->setVariable('STATUS_CHANGED_VAL', ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
202 
203  $this->tpl->setVariable("MODE_TEXT", ilLPObjSettings::_mode2Text($a_set["u_mode"]));
204  $this->tpl->setVariable("MARK_VALUE", $a_set["mark"]);
205  $this->tpl->setVariable("COMMENT_TEXT", $a_set["comment"]);
206 
207  if(!$this->isPercentageAvailable($a_set["obj_id"]) || (int)$a_set["percentage"] === 0)
208  {
209  $this->tpl->setVariable("PERCENTAGE_VALUE", "");
210  }
211  else
212  {
213  $this->tpl->setVariable("PERCENTAGE_VALUE", sprintf("%d%%", $a_set["percentage"]));
214  }
215 
216  // path
217  $path = $this->buildPath($a_set["ref_ids"]);
218  if($path)
219  {
220  $this->tpl->setCurrentBlock("item_path");
221  foreach($path as $path_item)
222  {
223  $this->tpl->setVariable("PATH_ITEM", $path_item);
224  $this->tpl->parseCurrentBlock();
225  }
226  }
227 
228  $this->tpl->parseCurrentBlock();
229  }
230 
231  // not for objectives/scos
232  if(!$this->mode)
233  {
234  // tlt warning
235  if($a_set["status"] != LP_STATUS_COMPLETED_NUM && $a_set["ref_ids"])
236  {
237  $ref_id = $a_set["ref_ids"];
238  $ref_id = array_shift($ref_id);
239  $timing = $this->showTimingsWarning($ref_id, $this->tracked_user->getId());
240  if($timing)
241  {
242  if($timing !== true)
243  {
244  $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX));
245  }
246  else
247  {
248  $timing = "";
249  }
250  $this->tpl->setCurrentBlock('warning_img');
251  $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.png'));
252  $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing);
253  $this->tpl->parseCurrentBlock();
254  }
255  }
256 
257  // hide / unhide?!
258  if(!$this->details)
259  {
260  $this->tpl->setCurrentBlock("item_command");
261  $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
262  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
263  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
264  $this->tpl->parseCurrentBlock();
265 
266  if(ilLPObjSettings::_isContainer($a_set["u_mode"]) && $a_set["ref_ids"])
267  {
268  $ref_id = $a_set["ref_ids"];
269  $ref_id = array_shift($ref_id);
270  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
271  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
272  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
273  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_subitems'));
274  $this->tpl->parseCurrentBlock();
275  }
276 
277  $this->tpl->setCurrentBlock("column_action");
278  $this->tpl->parseCurrentBlock();
279  }
280  }
281  }
282 
283  protected function fillHeaderExcel($worksheet, &$a_row)
284  {
285  $worksheet->write($a_row, 0, $this->lng->txt("type"));
286  $worksheet->write($a_row, 1, $this->lng->txt("trac_title"));
287  $worksheet->write($a_row, 2, $this->lng->txt("status"));
288  $worksheet->write($a_row, 3, $this->lng->txt("trac_status_changed"));
289  $worksheet->write($a_row, 4, $this->lng->txt("trac_percentage"));
290  $worksheet->write($a_row, 5, $this->lng->txt("trac_mark"));
291  $worksheet->write($a_row, 6, $this->lng->txt("comment"));
292  $worksheet->write($a_row, 7, $this->lng->txt("trac_mode"));
293  // $worksheet->write($a_row, 7, $this->lng->txt("path"));
294  }
295 
296  protected function fillRowExcel($worksheet, &$a_row, $a_set)
297  {
298  $worksheet->write($a_row, 0, $this->lng->txt($a_set["type"]));
299  $worksheet->write($a_row, 1, $a_set["title"]);
300  $worksheet->write($a_row, 2, ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
301 
303  $worksheet->write($a_row, 3, ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
305 
306  $worksheet->write($a_row, 4, sprintf("%d%%", $a_set["percentage"]));
307  $worksheet->write($a_row, 5, $a_set["mark"]);
308  $worksheet->write($a_row, 6, $a_set["comment"]);
309  $worksheet->write($a_row, 7, ilLPObjSettings::_mode2Text($a_set["u_mode"]));
310 
311  /*
312  // path
313  $path = $this->buildPath($a_set["ref_ids"]);
314  if($path)
315  {
316  $col = 7;
317  foreach($path as $path_item)
318  {
319  $worksheet->write($a_row, $col, strip_tags($path_item));
320  $col++;
321  }
322  }
323  */
324 
325  }
326 
327  protected function fillHeaderCSV($a_csv)
328  {
329  $a_csv->addColumn($this->lng->txt("type"));
330  $a_csv->addColumn($this->lng->txt("trac_title"));
331  $a_csv->addColumn($this->lng->txt("status"));
332  $a_csv->addColumn($this->lng->txt("trac_status_changed"));
333  $a_csv->addColumn($this->lng->txt("trac_percentage"));
334  $a_csv->addColumn($this->lng->txt("trac_mark"));
335  $a_csv->addColumn($this->lng->txt("comment"));
336  $a_csv->addColumn($this->lng->txt("trac_mode"));
337  // $a_csv->addColumn($this->lng->txt("path"));
338  $a_csv->addRow();
339  }
340 
341  protected function fillRowCSV($a_csv, $a_set)
342  {
343  $a_csv->addColumn($this->lng->txt($a_set["type"]));
344  $a_csv->addColumn($a_set["title"]);
345  $a_csv->addColumn(ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
346 
348  $a_csv->addColumn(ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
350 
351  $a_csv->addColumn(sprintf("%d%%", $a_set["percentage"]));
352  $a_csv->addColumn($a_set["mark"]);
353  $a_csv->addColumn($a_set["comment"]);
354  $a_csv->addColumn(ilLPObjSettings::_mode2Text($a_set["u_mode"]));
355 
356  /*
357  // path
358  $path = $this->buildPath($a_set["ref_ids"]);
359  if($path)
360  {
361  $col = 7;
362  foreach($path as $path_item)
363  {
364  $a_csv->addColumn(strip_tags($path_item));
365  $col++;
366  }
367  }
368  */
369 
370  $a_csv->addRow();
371  }
372 }
373 
374 ?>