ILIAS  eassessment Revision 61809
 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(ilSearchSettings::getInstance()->getMaxHits());
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_percentage"), "percentage", "7%");
48  $this->addColumn($this->lng->txt("trac_mark"), "", "5%");
49  $this->addColumn($this->lng->txt("comment"), "", "10%");
50  $this->addColumn($this->lng->txt("trac_mode"), "", "20%");
51  $this->addColumn($this->lng->txt("path"), "", "20%");
52  $this->addColumn($this->lng->txt("actions"), "", "5%");
53 
54  $this->setTitle(sprintf($this->lng->txt("trac_learning_progress_of"), $user->getFullName()));
55  $this->initFilter();
56 
57  $this->setSelectAllCheckbox("item_id");
58  $this->addMultiCommand("hideSelected", $lng->txt("trac_hide_selected"));
59  }
60  else
61  {
62  if(!$personal_only)
63  {
64  $this->parseTitle($a_parent_obj->details_obj_id, "trac_subitems");
65  }
66  else
67  {
68  $this->parseTitle($a_parent_obj->details_obj_id, "trac_progress");
69  }
70 
71  $this->addColumn($this->lng->txt("trac_title"), "title", "31%");
72  $this->addColumn($this->lng->txt("status"), "status", "7%");
73 
74  if($this->mode != LP_MODE_SCORM && $this->mode != LP_MODE_OBJECTIVES)
75  {
76  $this->addColumn($this->lng->txt("trac_percentage"), "percentage", "7%");
77  $this->addColumn($this->lng->txt("trac_mark"), "", "5%");
78  $this->addColumn($this->lng->txt("comment"), "", "10%");
79  $this->addColumn($this->lng->txt("trac_mode"), "", "20%");
80  $this->addColumn($this->lng->txt("path"), "", "20%");
81  }
82  }
83 
84  $this->setEnableHeader(true);
85  $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
86  $this->setRowTemplate("tpl.lp_progress_list_row.html", "Services/Tracking");
87  $this->setEnableHeader(true);
88  $this->setEnableNumInfo(true);
89  $this->setEnableTitle(true);
90  $this->setDefaultOrderField("title");
91  $this->setDefaultOrderDirection("asc");
92  $this->setShowTemplates(true);
93 
94  if($this->mode != LP_MODE_SCORM && $this->mode != LP_MODE_OBJECTIVES)
95  {
96  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
97  }
98 
99  // area selector gets in the way
100  if($this->tracked_user)
101  {
102  $this->getItems();
103  }
104  }
105 
106  function getItems()
107  {
108  $obj_ids = $this->obj_ids;
109  if(!$obj_ids && !$this->details)
110  {
111  $obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read");
112  }
113  if($obj_ids)
114  {
115  include_once("./Services/Tracking/classes/class.ilTrQuery.php");
116  switch($this->mode)
117  {
118  case LP_MODE_SCORM:
119  $data = ilTrQuery::getSCOsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids);
120  break;
121 
122  case LP_MODE_OBJECTIVES:
123  $data = ilTrQuery::getObjectivesStatusForUser($this->tracked_user->getId(), $obj_ids);
124  break;
125 
126  default:
127  $data = ilTrQuery::getObjectsStatusForUser($this->tracked_user->getId(), $obj_ids);
128  break;
129  }
130  $this->setData($data);
131  }
132  }
133 
137  protected function fillRow($a_set)
138  {
139  global $ilObjDataCache, $ilCtrl;
140 
141  if(!$this->details)
142  {
143  $this->tpl->setCurrentBlock("column_checkbox");
144  $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
145  $this->tpl->parseCurrentBlock();
146  }
147 
148  $this->tpl->setVariable("ICON_SRC", ilUtil::getTypeIconPath($a_set["type"], $a_set["obj_id"], "tiny"));
149  $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
150  $this->tpl->setVariable("TITLE_TEXT", $a_set["title"]);
151 
152  $this->tpl->setVariable("STATUS_ALT", ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
153  $this->tpl->setVariable("STATUS_IMG", ilLearningProgressBaseGUI::_getImagePathForStatus($a_set["status"]));
154 
155  if($this->mode != LP_MODE_SCORM && $this->mode != LP_MODE_OBJECTIVES)
156  {
157  $this->tpl->setCurrentBlock("status_details");
158  $this->tpl->setVariable("MODE_TEXT", ilLPObjSettings::_mode2Text($a_set["u_mode"]));
159  $this->tpl->setVariable("MARK_VALUE", $a_set["mark"]);
160  $this->tpl->setVariable("COMMENT_TEXT", $a_set["comment"]);
161 
162  if(!$this->isPercentageAvailable($a_set["obj_id"]) || (int)$a_set["percentage"] === 0)
163  {
164  $this->tpl->setVariable("PERCENTAGE_VALUE", "");
165  }
166  else
167  {
168  $this->tpl->setVariable("PERCENTAGE_VALUE", sprintf("%d%%", $a_set["percentage"]));
169  }
170 
171  // path
172  $path = $this->buildPath($a_set["ref_ids"]);
173  if($path)
174  {
175  $this->tpl->setCurrentBlock("item_path");
176  foreach($path as $path_item)
177  {
178  $this->tpl->setVariable("PATH_ITEM", $path_item);
179  $this->tpl->parseCurrentBlock();
180  }
181  }
182 
183  $this->tpl->parseCurrentBlock();
184  }
185 
186  // not for objectives/scos
187  if(!$this->mode)
188  {
189  // tlt warning
190  if($a_set["status"] != LP_STATUS_COMPLETED_NUM && $a_set["ref_ids"])
191  {
192  $ref_id = $a_set["ref_ids"];
193  $ref_id = array_shift($ref_id);
194  $timing = $this->showTimingsWarning($ref_id, $this->tracked_user->getId());
195  if($timing)
196  {
197  if($timing !== true)
198  {
199  $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX));
200  }
201  else
202  {
203  $timing = "";
204  }
205  $this->tpl->setCurrentBlock('warning_img');
206  $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.gif'));
207  $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing);
208  $this->tpl->parseCurrentBlock();
209  }
210  }
211 
212  // hide / unhide?!
213  if(!$this->details)
214  {
215  $this->tpl->setCurrentBlock("item_command");
216  $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
217  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
218  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
219  $this->tpl->parseCurrentBlock();
220 
221  if(ilLPObjSettings::_isContainer($a_set["u_mode"]) && $a_set["ref_ids"])
222  {
223  $ref_id = $a_set["ref_ids"];
224  $ref_id = array_shift($ref_id);
225  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
226  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
227  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
228  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_subitems'));
229  $this->tpl->parseCurrentBlock();
230  }
231 
232  $this->tpl->setCurrentBlock("column_action");
233  $this->tpl->parseCurrentBlock();
234  }
235  }
236  }
237 
238  protected function fillHeaderExcel($worksheet, &$a_row)
239  {
240  $worksheet->write($a_row, 0, $this->lng->txt("type"));
241  $worksheet->write($a_row, 1, $this->lng->txt("trac_title"));
242  $worksheet->write($a_row, 2, $this->lng->txt("status"));
243  $worksheet->write($a_row, 3, $this->lng->txt("trac_percentage"));
244  $worksheet->write($a_row, 4, $this->lng->txt("trac_mark"));
245  $worksheet->write($a_row, 5, $this->lng->txt("comment"));
246  $worksheet->write($a_row, 6, $this->lng->txt("trac_mode"));
247  // $worksheet->write($a_row, 7, $this->lng->txt("path"));
248  }
249 
250  protected function fillRowExcel($worksheet, &$a_row, $a_set)
251  {
252  $worksheet->write($a_row, 0, $this->lng->txt($a_set["type"]));
253  $worksheet->write($a_row, 1, $a_set["title"]);
254  $worksheet->write($a_row, 2, ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
255  $worksheet->write($a_row, 3, sprintf("%d%%", $a_set["percentage"]));
256  $worksheet->write($a_row, 4, $a_set["mark"]);
257  $worksheet->write($a_row, 5, $a_set["comment"]);
258  $worksheet->write($a_row, 6, ilLPObjSettings::_mode2Text($a_set["u_mode"]));
259 
260  /*
261  // path
262  $path = $this->buildPath($a_set["ref_ids"]);
263  if($path)
264  {
265  $col = 7;
266  foreach($path as $path_item)
267  {
268  $worksheet->write($a_row, $col, strip_tags($path_item));
269  $col++;
270  }
271  }
272  */
273 
274  }
275 
276  protected function fillHeaderCSV($a_csv)
277  {
278  $a_csv->addColumn($this->lng->txt("type"));
279  $a_csv->addColumn($this->lng->txt("trac_title"));
280  $a_csv->addColumn($this->lng->txt("status"));
281  $a_csv->addColumn($this->lng->txt("trac_percentage"));
282  $a_csv->addColumn($this->lng->txt("trac_mark"));
283  $a_csv->addColumn($this->lng->txt("comment"));
284  $a_csv->addColumn($this->lng->txt("trac_mode"));
285  // $a_csv->addColumn($this->lng->txt("path"));
286  $a_csv->addRow();
287  }
288 
289  protected function fillRowCSV($a_csv, $a_set)
290  {
291  $a_csv->addColumn($this->lng->txt($a_set["type"]));
292  $a_csv->addColumn($a_set["title"]);
293  $a_csv->addColumn(ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
294  $a_csv->addColumn(sprintf("%d%%", $a_set["percentage"]));
295  $a_csv->addColumn($a_set["mark"]);
296  $a_csv->addColumn($a_set["comment"]);
297  $a_csv->addColumn(ilLPObjSettings::_mode2Text($a_set["u_mode"]));
298 
299  /*
300  // path
301  $path = $this->buildPath($a_set["ref_ids"]);
302  if($path)
303  {
304  $col = 7;
305  foreach($path as $path_item)
306  {
307  $a_csv->addColumn(strip_tags($path_item));
308  $col++;
309  }
310  }
311  */
312 
313  $a_csv->addRow();
314  }
315 }
316 
317 ?>