ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_once("./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
5require_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 switch($this->lp_context)
144 {
146 $obj_ids = $this->searchObjects($this->getCurrentFilter(true), null);
147 break;
148
149 default:
150 $obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read");
151
152 // check for LP relevance
153 include_once "Services/Object/classes/class.ilObjectLP.php";
154 foreach(ilObjectLP::getLPMemberships($this->tracked_user->getId(), $obj_ids, null, true) as $obj_id => $status)
155 {
156 if(!$status)
157 {
158 unset($obj_ids[$obj_id]);
159 }
160 }
161 break;
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(), $this->parent_obj_id, $obj_ids);
175 break;
176
180 $data = ilTrQuery::getSubItemsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids);
181 break;
182
183 default:
184 $data = ilTrQuery::getObjectsStatusForUser($this->tracked_user->getId(), $obj_ids);
185 foreach($data as $idx => $item)
186 {
187 if(!$item["status"] && !$this->filter["status"] && !$this->details)
188 {
189 unset($data[$idx]);
190 }
191 else
192 {
193 $data[$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($item["obj_id"], $item["type"]);
194 }
195 }
196 break;
197 }
198
199 // #15334
200 foreach($data as $idx => $row)
201 {
202 if(!$this->isPercentageAvailable($row["obj_id"]))
203 {
204 // #17000 - enable proper (numeric) sorting
205 $data[$idx]["percentage"] = -1;
206 }
207 }
208
209 $this->setData($data);
210 }
211 }
212
216 protected function fillRow($a_set)
217 {
218 global $ilCtrl;
219
220 if(!$this->details)
221 {
222 $this->tpl->setCurrentBlock("column_checkbox");
223 $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
224 $this->tpl->parseCurrentBlock();
225 }
226
227 $this->tpl->setVariable("ICON_SRC", ilObject::_getIcon("", "tiny", $a_set["type"]));
228 $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
229 $this->tpl->setVariable("TITLE_TEXT", $a_set["title"]);
230
231 if($a_set["offline"])
232 {
233 $this->tpl->setCurrentBlock("offline");
234 $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
235 $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline"));
236 $this->tpl->parseCurrentBlock();
237 }
238
239 $this->tpl->setVariable("STATUS_ALT", ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
240 $this->tpl->setVariable("STATUS_IMG", ilLearningProgressBaseGUI::_getImagePathForStatus($a_set["status"]));
241
242 if($this->mode == ilLPObjSettings::LP_MODE_SCORM)
243 {
244 $this->tpl->setVariable('SCORE_VAL', $a_set["score"]);
245 }
246 else if($this->has_object_subitems)
247 {
248 $this->tpl->setCurrentBlock("status_details");
249
250 $this->tpl->setVariable('STATUS_CHANGED_VAL', ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
251
252 $olp = ilObjectLP::getInstance($a_set["obj_id"]);
253 $this->tpl->setVariable("MODE_TEXT", $olp->getModeText($a_set["u_mode"]));
254 $this->tpl->setVariable("MARK_VALUE", $a_set["mark"]);
255 $this->tpl->setVariable("COMMENT_TEXT", $a_set["comment"]);
256
257 if($a_set["percentage"] < 0)
258 {
259 $this->tpl->setVariable("PERCENTAGE_VALUE", "");
260 }
261 else
262 {
263 $this->tpl->setVariable("PERCENTAGE_VALUE", sprintf("%d%%", $a_set["percentage"]));
264 }
265
266 // path
267 $path = $this->buildPath($a_set["ref_ids"]);
268 if($path)
269 {
270 $this->tpl->setCurrentBlock("item_path");
271 foreach($path as $path_item)
272 {
273 $this->tpl->setVariable("PATH_ITEM", $path_item);
274 $this->tpl->parseCurrentBlock();
275 }
276 }
277
278 $this->tpl->parseCurrentBlock();
279 }
280
281 // not for objectives/scos
282 if(!$this->mode)
283 {
284 // tlt warning
285 if($a_set["status"] != ilLPStatus::LP_STATUS_COMPLETED_NUM && $a_set["ref_ids"])
286 {
287 $ref_id = $a_set["ref_ids"];
288 $ref_id = array_shift($ref_id);
289 $timing = $this->showTimingsWarning($ref_id, $this->tracked_user->getId());
290 if($timing)
291 {
292 if($timing !== true)
293 {
294 $timing = ": ".ilDatePresentation::formatDate(new ilDate($timing, IL_CAL_UNIX));
295 }
296 else
297 {
298 $timing = "";
299 }
300 $this->tpl->setCurrentBlock('warning_img');
301 $this->tpl->setVariable('WARNING_IMG', ilUtil::getImagePath('time_warn.svg'));
302 $this->tpl->setVariable('WARNING_ALT', $this->lng->txt('trac_time_passed').$timing);
303 $this->tpl->parseCurrentBlock();
304 }
305 }
306
307 // hide / unhide?!
308 if(!$this->details)
309 {
310 $this->tpl->setCurrentBlock("item_command");
311 $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
312 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
313 $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
314 $this->tpl->parseCurrentBlock();
315
316 $olp = ilObjectLP::getInstance($a_set["obj_id"]);
317 if($olp->getCollectionInstance() && $a_set["ref_ids"])
318 {
319 $ref_id = $a_set["ref_ids"];
320 $ref_id = array_shift($ref_id);
321 $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
322 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
323 $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
324 $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_subitems'));
325 $this->tpl->parseCurrentBlock();
326 }
327
328 $this->tpl->setCurrentBlock("column_action");
329 $this->tpl->parseCurrentBlock();
330 }
331 }
332 }
333
334 protected function fillHeaderExcel($worksheet, &$a_row)
335 {
336 $worksheet->write($a_row, 0, $this->lng->txt("type"));
337 $worksheet->write($a_row, 1, $this->lng->txt("trac_title"));
338 $worksheet->write($a_row, 2, $this->lng->txt("status"));
339 $worksheet->write($a_row, 3, $this->lng->txt("trac_status_changed"));
340 $worksheet->write($a_row, 4, $this->lng->txt("trac_percentage"));
341 $worksheet->write($a_row, 5, $this->lng->txt("trac_mark"));
342 $worksheet->write($a_row, 6, $this->lng->txt("comment"));
343 $worksheet->write($a_row, 7, $this->lng->txt("trac_mode"));
344 // $worksheet->write($a_row, 7, $this->lng->txt("path"));
345 }
346
347 protected function fillRowExcel($worksheet, &$a_row, $a_set)
348 {
349 $worksheet->write($a_row, 0, $this->lng->txt($a_set["type"]));
350 $worksheet->write($a_row, 1, $a_set["title"]);
351 $worksheet->write($a_row, 2, ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
352
354 $worksheet->write($a_row, 3, ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
356
357 $worksheet->write($a_row, 4, sprintf("%d%%", $a_set["percentage"]));
358 $worksheet->write($a_row, 5, $a_set["mark"]);
359 $worksheet->write($a_row, 6, $a_set["comment"]);
360 $worksheet->write($a_row, 7, ilLPObjSettings::_mode2Text($a_set["u_mode"]));
361
362 /*
363 // path
364 $path = $this->buildPath($a_set["ref_ids"]);
365 if($path)
366 {
367 $col = 7;
368 foreach($path as $path_item)
369 {
370 $worksheet->write($a_row, $col, strip_tags($path_item));
371 $col++;
372 }
373 }
374 */
375
376 }
377
378 protected function fillHeaderCSV($a_csv)
379 {
380 $a_csv->addColumn($this->lng->txt("type"));
381 $a_csv->addColumn($this->lng->txt("trac_title"));
382 $a_csv->addColumn($this->lng->txt("status"));
383 $a_csv->addColumn($this->lng->txt("trac_status_changed"));
384 $a_csv->addColumn($this->lng->txt("trac_percentage"));
385 $a_csv->addColumn($this->lng->txt("trac_mark"));
386 $a_csv->addColumn($this->lng->txt("comment"));
387 $a_csv->addColumn($this->lng->txt("trac_mode"));
388 // $a_csv->addColumn($this->lng->txt("path"));
389 $a_csv->addRow();
390 }
391
392 protected function fillRowCSV($a_csv, $a_set)
393 {
394 $a_csv->addColumn($this->lng->txt($a_set["type"]));
395 $a_csv->addColumn($a_set["title"]);
396 $a_csv->addColumn(ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
397
399 $a_csv->addColumn(ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'],IL_CAL_DATETIME)));
401
402 $a_csv->addColumn(sprintf("%d%%", $a_set["percentage"]));
403 $a_csv->addColumn($a_set["mark"]);
404 $a_csv->addColumn($a_set["comment"]);
405 $a_csv->addColumn(ilLPObjSettings::_mode2Text($a_set["u_mode"]));
406
407 /*
408 // path
409 $path = $this->buildPath($a_set["ref_ids"]);
410 if($path)
411 {
412 $col = 7;
413 foreach($path as $path_item)
414 {
415 $a_csv->addColumn(strip_tags($path_item));
416 $col++;
417 }
418 }
419 */
420
421 $a_csv->addRow();
422 }
423}
424
425?>
const IL_CAL_UNIX
const IL_CAL_DATETIME
static resetToDefaults()
reset to defaults
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
Class for single dates.
static _mode2Text($a_mode)
TableGUI class for learning progress.
fillRow($a_set)
Fill table row.
fillHeaderExcel($worksheet, &$a_row)
Excel Version of Fill Header.
numericOrdering($a_field)
Should this field be sorted numeric?
__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.
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
fillRowExcel($worksheet, &$a_row, $a_set)
Excel Version of Fill Row.
fillHeaderCSV($a_csv)
CSV Version of Fill Header.
const LP_STATUS_COMPLETED_NUM
TableGUI class for learning progress.
getCurrentFilter($as_query=false)
showTimingsWarning($a_ref_id, $a_user_id)
buildPath($ref_ids)
Build path with deep-link.
searchObjects(array $filter, $permission, array $preset_obj_ids=null, $a_check_lp_activation=true)
Search objects that match current filters.
_getImagePathForStatus($a_status)
Get image path for status.
_getStatusText($a_status, $a_lng=null)
Get status alt text.
static isObjectOffline($a_obj_id, $a_type=null)
static getLPMemberships($a_usr_id, array $a_obj_ids, $a_parent_ref_id=null, $a_mapped_ref_ids=false)
Get all objects where given user is member (from LP POV)
static getInstance($a_obj_id)
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setEnableHeader($a_enableheader)
Set Enable Header.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setExportFormats(array $formats)
Set available export formats.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
initFilter()
Init filter.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setEnableNumInfo($a_val)
Set enable num info.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setShowTemplates($a_value)
Toggle templates.
getSubItemsStatusForUser($a_user_id, $a_parent_obj_id, array $a_item_ids)
getSCOsStatusForUser($a_user_id, $a_parent_obj_id, array $a_sco_ids)
getObjectsStatusForUser($a_user_id, array $obj_refs)
getObjectivesStatusForUser($a_user_id, $a_obj_id, array $a_objective_ids)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22
global $ilUser
Definition: imgupload.php:15