ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 require_once("./Services/Tracking/classes/class.ilLearningProgressGUI.php");
6 
17 {
21  function __construct($a_parent_obj, $a_parent_cmd, $a_user = "", $obj_ids = NULL, $details = false, $mode = null, $personal_only = false, $a_parent_id = null, $a_parent_ref_id = null, $lp_context = null)
22  {
23  global $ilCtrl, $lng, $ilUser;
24 
25  $this->tracked_user = $a_user;
26  $this->obj_ids = $obj_ids;
27  $this->details = $details;
28  $this->mode = $mode;
29  $this->parent_obj_id = $a_parent_id;
30  $this->lp_context = $lp_context;
31 
32  if($a_parent_id)
33  {
34  // #15042 - needed for export meta
35  $this->obj_id = $this->parent_obj_id;
36  $this->ref_id = $a_parent_ref_id;
37  }
38 
39  $this->setId("lpprgtbl");
40 
41  parent::__construct($a_parent_obj, $a_parent_cmd);
42 
43  $this->setLimit(9999);
44 
45  if(!$this->details)
46  {
47  $this->has_object_subitems = true;
48 
49  $user = $this->tracked_user;
50  if(!$user)
51  {
52  $user = $ilUser;
53  }
54 
55  $this->addColumn("", "", "1", true);
56  $this->addColumn($this->lng->txt("trac_title"), "title", "26%");
57  $this->addColumn($this->lng->txt("status"), "status", "7%");
58  $this->addColumn($this->lng->txt('trac_status_changed'),'status_changed','10%');
59  $this->addColumn($this->lng->txt("trac_percentage"), "percentage", "7%");
60  $this->addColumn($this->lng->txt("trac_mark"), "", "5%");
61  $this->addColumn($this->lng->txt("comment"), "", "10%");
62  $this->addColumn($this->lng->txt("trac_mode"), "", "20%");
63  $this->addColumn($this->lng->txt("path"), "", "20%");
64  $this->addColumn($this->lng->txt("actions"), "", "5%");
65 
66  $this->setTitle(sprintf($this->lng->txt("trac_learning_progress_of"), $user->getFullName()));
67  $this->initFilter();
68 
69  $this->setSelectAllCheckbox("item_id");
70  $this->addMultiCommand("hideSelected", $lng->txt("trac_hide_selected"));
71 
72  $this->setShowTemplates(true);
73  }
74  else
75  {
76  include_once './Services/Object/classes/class.ilObjectLP.php';
77  $olp = ilObjectLP::getInstance($this->parent_obj_id);
78  $collection = $olp->getCollectionInstance();
79  $this->has_object_subitems = ($collection instanceof ilLPCollectionOfRepositoryObjects);
80 
81  /*
82  if(!$personal_only)
83  {
84  $this->parseTitle($a_parent_obj->details_obj_id, "trac_subitems");
85  }
86  else
87  {
88  $this->parseTitle($a_parent_obj->details_obj_id, "trac_progress");
89  }
90  */
91  $this->setTitle($this->lng->txt("details")); // #15247
92 
93  $this->addColumn($this->lng->txt("trac_title"), "title", "31%");
94  $this->addColumn($this->lng->txt("status"), "status", "7%");
95 
96  if($this->mode == ilLPObjSettings::LP_MODE_SCORM)
97  {
98  $this->lng->loadLanguageModule('content');
99  $this->addColumn($this->lng->txt('cont_score'),'score','10%');
100  }
101  else if($this->has_object_subitems)
102  {
103  $this->addColumn($this->lng->txt('trac_status_changed'),'status_changed','10%');
104  $this->addColumn($this->lng->txt("trac_percentage"), "percentage", "7%");
105  $this->addColumn($this->lng->txt("trac_mark"), "", "5%");
106  $this->addColumn($this->lng->txt("comment"), "", "10%");
107  $this->addColumn($this->lng->txt("trac_mode"), "", "20%");
108  $this->addColumn($this->lng->txt("path"), "", "20%");
109  }
110  }
111 
112  $this->setEnableHeader(true);
113  $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
114  $this->setRowTemplate("tpl.lp_progress_list_row.html", "Services/Tracking");
115  $this->setEnableHeader(true);
116  $this->setEnableNumInfo(false);
117  $this->setEnableTitle(true);
118  $this->setDefaultOrderField("title");
119  $this->setDefaultOrderDirection("asc");
120 
121  if($this->has_object_subitems)
122  {
123  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
124  }
125 
126  // area selector gets in the way
127  if($this->tracked_user)
128  {
129  $this->getItems();
130  }
131  }
132 
133  function numericOrdering($a_field)
134  {
135  return ($a_field == "percentage"); // #15041
136  }
137 
138  function getItems()
139  {
140  $obj_ids = $this->obj_ids;
141  if(!$obj_ids && !$this->details)
142  {
143  // restrict courses/groups to objects where current user is member
144  $membership_ids = null;
145  if($this->filter["type"] == "crs" || $this->filter["type"] == "grp")
146  {
147  include_once "Services/Membership/classes/class.ilParticipants.php";
148  $membership_ids = ilParticipants::_getMembershipByType($this->tracked_user->getId(),
149  $this->filter["type"]);
150  }
151  if($membership_ids === null || sizeof($membership_ids))
152  {
153  switch($this->lp_context)
154  {
156  $obj_ids = $this->searchObjects($this->getCurrentFilter(true),null,$membership_ids);
157  break;
158  default:
159  $obj_ids = $this->searchObjects($this->getCurrentFilter(true),"read",$membership_ids);
160  break;
161  }
162  }
163  }
164  if($obj_ids)
165  {
166  include_once("./Services/Tracking/classes/class.ilTrQuery.php");
167  switch($this->mode)
168  {
170  $data = ilTrQuery::getSCOsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids);
171  break;
172 
174  $data = ilTrQuery::getObjectivesStatusForUser($this->tracked_user->getId(), $obj_ids);
175  break;
176 
179  $data = ilTrQuery::getSubItemsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids);
180  break;
181 
182  default:
183  $data = ilTrQuery::getObjectsStatusForUser($this->tracked_user->getId(), $obj_ids);
184  foreach($data as $idx => $item)
185  {
186  if(!$item["status"] && !$this->filter["status"] && !$this->details)
187  {
188  unset($data[$idx]);
189  }
190  else
191  {
192  $data[$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($item["obj_id"], $item["type"]);
193  }
194  }
195  break;
196  }
197  $this->setData($data);
198  }
199  }
200 
204  protected function fillRow($a_set)
205  {
206  global $ilCtrl;
207 
208  if(!$this->details)
209  {
210  $this->tpl->setCurrentBlock("column_checkbox");
211  $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
212  $this->tpl->parseCurrentBlock();
213  }
214 
215  $this->tpl->setVariable("ICON_SRC", ilObject::_getIcon("", "tiny", $a_set["type"]));
216  $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
217  $this->tpl->setVariable("TITLE_TEXT", $a_set["title"]);
218 
219  if($a_set["offline"])
220  {
221  $this->tpl->setCurrentBlock("offline");
222  $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
223  $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline"));
224  $this->tpl->parseCurrentBlock();
225  }
226 
227  $this->tpl->setVariable("STATUS_ALT", ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
228  $this->tpl->setVariable("STATUS_IMG", ilLearningProgressBaseGUI::_getImagePathForStatus($a_set["status"]));
229 
230  if($this->mode == ilLPObjSettings::LP_MODE_SCORM)
231  {
232  $this->tpl->setVariable('SCORE_VAL', $a_set["score"]);
233  }
234  else if($this->has_object_subitems)
235  {
236  $this->tpl->setCurrentBlock("status_details");
237 
238  $this->tpl->setVariable('STATUS_CHANGED_VAL', ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
239 
240  $olp = ilObjectLP::getInstance($a_set["obj_id"]);
241  $this->tpl->setVariable("MODE_TEXT", $olp->getModeText($a_set["u_mode"]));
242  $this->tpl->setVariable("MARK_VALUE", $a_set["mark"]);
243  $this->tpl->setVariable("COMMENT_TEXT", $a_set["comment"]);
244 
245  if(!$this->isPercentageAvailable($a_set["obj_id"]) /* || (int)$a_set["percentage"] === 0 */) // #15334
246  {
247  $this->tpl->setVariable("PERCENTAGE_VALUE", "");
248  }
249  else
250  {
251  $this->tpl->setVariable("PERCENTAGE_VALUE", sprintf("%d%%", $a_set["percentage"]));
252  }
253 
254  // path
255  $path = $this->buildPath($a_set["ref_ids"]);
256  if($path)
257  {
258  $this->tpl->setCurrentBlock("item_path");
259  foreach($path as $path_item)
260  {
261  $this->tpl->setVariable("PATH_ITEM", $path_item);
262  $this->tpl->parseCurrentBlock();
263  }
264  }
265 
266  $this->tpl->parseCurrentBlock();
267  }
268 
269  // not for objectives/scos
270  if(!$this->mode)
271  {
272  // tlt warning
273  if($a_set["status"] != ilLPStatus::LP_STATUS_COMPLETED_NUM && $a_set["ref_ids"])
274  {
275  $ref_id = $a_set["ref_ids"];
276  $ref_id = array_shift($ref_id);
277  $timing = $this->showTimingsWarning($ref_id, $this->tracked_user->getId());
278  if($timing)
279  {
280  if($timing !== true)
281  {
282  $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX));
283  }
284  else
285  {
286  $timing = "";
287  }
288  $this->tpl->setCurrentBlock('warning_img');
289  $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.svg'));
290  $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing);
291  $this->tpl->parseCurrentBlock();
292  }
293  }
294 
295  // hide / unhide?!
296  if(!$this->details)
297  {
298  $this->tpl->setCurrentBlock("item_command");
299  $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
300  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
301  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
302  $this->tpl->parseCurrentBlock();
303 
304  $olp = ilObjectLP::getInstance($a_set["obj_id"]);
305  if($olp->getCollectionInstance() && $a_set["ref_ids"])
306  {
307  $ref_id = $a_set["ref_ids"];
308  $ref_id = array_shift($ref_id);
309  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
310  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
311  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
312  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_subitems'));
313  $this->tpl->parseCurrentBlock();
314  }
315 
316  $this->tpl->setCurrentBlock("column_action");
317  $this->tpl->parseCurrentBlock();
318  }
319  }
320  }
321 
322  protected function fillHeaderExcel($worksheet, &$a_row)
323  {
324  $worksheet->write($a_row, 0, $this->lng->txt("type"));
325  $worksheet->write($a_row, 1, $this->lng->txt("trac_title"));
326  $worksheet->write($a_row, 2, $this->lng->txt("status"));
327  $worksheet->write($a_row, 3, $this->lng->txt("trac_status_changed"));
328  $worksheet->write($a_row, 4, $this->lng->txt("trac_percentage"));
329  $worksheet->write($a_row, 5, $this->lng->txt("trac_mark"));
330  $worksheet->write($a_row, 6, $this->lng->txt("comment"));
331  $worksheet->write($a_row, 7, $this->lng->txt("trac_mode"));
332  // $worksheet->write($a_row, 7, $this->lng->txt("path"));
333  }
334 
335  protected function fillRowExcel($worksheet, &$a_row, $a_set)
336  {
337  $worksheet->write($a_row, 0, $this->lng->txt($a_set["type"]));
338  $worksheet->write($a_row, 1, $a_set["title"]);
339  $worksheet->write($a_row, 2, ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
340 
342  $worksheet->write($a_row, 3, ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
344 
345  $worksheet->write($a_row, 4, sprintf("%d%%", $a_set["percentage"]));
346  $worksheet->write($a_row, 5, $a_set["mark"]);
347  $worksheet->write($a_row, 6, $a_set["comment"]);
348  $worksheet->write($a_row, 7, ilLPObjSettings::_mode2Text($a_set["u_mode"]));
349 
350  /*
351  // path
352  $path = $this->buildPath($a_set["ref_ids"]);
353  if($path)
354  {
355  $col = 7;
356  foreach($path as $path_item)
357  {
358  $worksheet->write($a_row, $col, strip_tags($path_item));
359  $col++;
360  }
361  }
362  */
363 
364  }
365 
366  protected function fillHeaderCSV($a_csv)
367  {
368  $a_csv->addColumn($this->lng->txt("type"));
369  $a_csv->addColumn($this->lng->txt("trac_title"));
370  $a_csv->addColumn($this->lng->txt("status"));
371  $a_csv->addColumn($this->lng->txt("trac_status_changed"));
372  $a_csv->addColumn($this->lng->txt("trac_percentage"));
373  $a_csv->addColumn($this->lng->txt("trac_mark"));
374  $a_csv->addColumn($this->lng->txt("comment"));
375  $a_csv->addColumn($this->lng->txt("trac_mode"));
376  // $a_csv->addColumn($this->lng->txt("path"));
377  $a_csv->addRow();
378  }
379 
380  protected function fillRowCSV($a_csv, $a_set)
381  {
382  $a_csv->addColumn($this->lng->txt($a_set["type"]));
383  $a_csv->addColumn($a_set["title"]);
384  $a_csv->addColumn(ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
385 
387  $a_csv->addColumn(ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
389 
390  $a_csv->addColumn(sprintf("%d%%", $a_set["percentage"]));
391  $a_csv->addColumn($a_set["mark"]);
392  $a_csv->addColumn($a_set["comment"]);
393  $a_csv->addColumn(ilLPObjSettings::_mode2Text($a_set["u_mode"]));
394 
395  /*
396  // path
397  $path = $this->buildPath($a_set["ref_ids"]);
398  if($path)
399  {
400  $col = 7;
401  foreach($path as $path_item)
402  {
403  $a_csv->addColumn(strip_tags($path_item));
404  $col++;
405  }
406  }
407  */
408 
409  $a_csv->addRow();
410  }
411 }
412 
413 ?>
const LP_STATUS_COMPLETED_NUM
getObjectivesStatusForUser($a_user_id, array $a_objective_ids)
getSCOsStatusForUser($a_user_id, $a_parent_obj_id, array $a_sco_ids)
initFilter()
Init filter.
buildPath($ref_ids)
Build path with deep-link.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExportFormats(array $formats)
Set available export formats.
const IL_CAL_DATETIME
setShowTemplates($a_value)
Toggle templates.
setEnableNumInfo($a_val)
Set enable num info.
fillRowExcel($worksheet, &$a_row, $a_set)
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
_getImagePathForStatus($a_status)
Get image path for status.
static resetToDefaults()
reset to defaults
static setUseRelativeDates($a_status)
set use relative dates
const IL_CAL_UNIX
setId($a_val)
Set id.
TableGUI class for learning progress.
_getStatusText($a_status)
Get status alt text.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setLimit($a_limit=0, $a_default_limit=0)
set max.
Class for single dates.
TableGUI class for learning progress.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static isObjectOffline($a_obj_id, $a_type=null)
fillHeaderExcel($worksheet, &$a_row)
fillRow($a_set)
Fill table row.
addMultiCommand($a_cmd, $a_text)
Add Command button.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
searchObjects(array $filter, $permission, array $preset_obj_ids=null)
Search objects that match current filters.
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:40
showTimingsWarning($a_ref_id, $a_user_id)
$path
Definition: index.php:22
getObjectsStatusForUser($a_user_id, array $obj_refs)
setEnableHeader($a_enableheader)
Set Enable Header.
__construct($a_parent_obj, $a_parent_cmd, $a_user="", $obj_ids=NULL, $details=false, $mode=null, $personal_only=false, $a_parent_id=null, $a_parent_ref_id=null, $lp_context=null)
Constructor.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
getCurrentFilter($as_query=false)
setEnableTitle($a_enabletitle)
Set Enable Title.
static getInstance($a_obj_id)
getSubItemsStatusForUser($a_user_id, $a_parent_obj_id, array $a_item_ids)
static _mode2Text($a_mode)