ILIAS  release_8 Revision v8.24
class.ilTrUserObjectsPropsTableGUI.php
Go to the documentation of this file.
1<?php
26{
27 protected string $type;
28 protected int $ref_id;
29 protected int $obj_id;
30 protected int $user_id;
31
34
38 public function __construct(
39 ?object $a_parent_obj,
40 string $a_parent_cmd,
41 int $a_user_id,
42 int $a_obj_id,
43 int $a_ref_id,
44 bool $a_print_view = false
45 ) {
46 global $DIC;
47
48 $this->setId("truop");
49 $this->user_id = $a_user_id;
50 $this->obj_id = $a_obj_id;
51 $this->type = ilObject::_lookupType($this->obj_id);
52 $this->ref_id = $a_ref_id;
53
54 parent::__construct($a_parent_obj, $a_parent_cmd);
55 $this->setLimit(9999);
56
57 $this->parseTitle($this->obj_id, "details", $this->user_id);
58
59 if ($a_print_view) {
60 $this->setPrintMode(true);
61 }
62
63 $this->addColumn($this->lng->txt("title"), "title");
64
65 foreach ($this->getSelectedColumns() as $c) {
66 $l = $c;
67 if (in_array(
68 $l,
69 array("last_access",
70 "first_access",
71 "read_count",
72 "spent_seconds",
73 "mark",
74 "status",
75 "percentage"
76 )
77 )) {
78 $l = "trac_" . $l;
79 }
80 if ($l == "u_comment") {
81 $l = "trac_comment";
82 }
83 $this->addColumn($this->lng->txt($l), $c);
84 }
85
86 if (!$this->getPrintMode()) {
87 $this->addColumn($this->lng->txt("actions"), "");
88 }
89
90 $this->setExternalSorting(true);
91 $this->setExternalSegmentation(true);
92 $this->setEnableHeader(true);
93 $this->setFormAction(
94 $this->ctrl->getFormActionByClass(get_class($this))
95 );
96 $this->setRowTemplate(
97 "tpl.user_objects_props_row.html",
98 "Services/Tracking"
99 );
100 $this->setEnableTitle(true);
101 $this->setDefaultOrderField("title");
102 $this->setDefaultOrderDirection("asc");
103 $this->setShowTemplates(true);
104 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
105 $this->initFilter();
106 $this->getItems();
107 }
108
109 public function getSelectableColumns(): array
110 {
111 // default fields
112 $cols = array();
113
114 $tracking = new ilObjUserTracking();
115 if ($tracking->hasExtendedData(
117 )) {
118 $cols["first_access"] = array(
119 "txt" => $this->lng->txt("trac_first_access"),
120 "default" => true
121 );
122 $cols["last_access"] = array(
123 "txt" => $this->lng->txt("trac_last_access"),
124 "default" => true
125 );
126 }
127 if ($tracking->hasExtendedData(
129 )) {
130 $cols["read_count"] = array(
131 "txt" => $this->lng->txt("trac_read_count"),
132 "default" => true
133 );
134 }
135 if ($tracking->hasExtendedData(
137 )) {
138 $cols["spent_seconds"] = array(
139 "txt" => $this->lng->txt("trac_spent_seconds"),
140 "default" => true
141 );
142 }
143
144 // #15334 - parent object does not matter, sub-objects may have percentage
145 $cols["percentage"] = array(
146 "txt" => $this->lng->txt("trac_percentage"),
147 "default" => true
148 );
149
150 $cols["status"] = array(
151 "txt" => $this->lng->txt("trac_status"),
152 "default" => true
153 );
154 $cols["mark"] = array(
155 "txt" => $this->lng->txt("trac_mark"),
156 "default" => true
157 );
158 $cols["u_comment"] = array(
159 "txt" => $this->lng->txt("trac_comment"),
160 "default" => false
161 );
162
163 return $cols;
164 }
165
166 public function getItems()
167 {
169 $additional_fields = $this->getSelectedColumns();
170
172 $this->user_id,
173 $this->obj_id,
174 $this->ref_id,
179 $this->filter,
180 $additional_fields,
181 $this->filter["view_mode"] ?? false
182 );
183
184 if (count($tr_data["set"]) == 0 && $this->getOffset() > 0) {
185 $this->resetOffset();
187 $this->user_id,
188 $this->obj_id,
189 $this->ref_id,
194 $this->filter,
195 $additional_fields,
196 $this->filter["view_mode"] ?? false
197 );
198 }
199
200 // #13807
201 foreach ($tr_data["set"] as $idx => $row) {
202 if (($row["ref_id"] ?? 0) &&
204 'read_learning_progress',
205 $row['ref_id']
206 )) {
207 foreach (array_keys($row) as $col_id) {
208 if (!in_array(
209 $col_id,
210 array("type",
211 "obj_id",
212 "ref_id",
213 "title",
214 "sort_title"
215 )
216 )) {
217 $tr_data["set"][$idx][$col_id] = null;
218 }
219 }
220 $tr_data["set"][$idx]["privacy_conflict"] = true;
221 }
222 }
223
224 $this->setMaxCount($tr_data["cnt"]);
225
226 if ($this->getOrderField() == "title") {
227 // sort alphabetically, move parent object to 1st position
228 $set = array();
229 $parent = false;
230 foreach ($tr_data["set"] as $idx => $row) {
231 if ($row['obj_id'] == $this->obj_id) {
232 $parent = $row;
233 } elseif (isset($row["sort_title"])) {
234 $set[strtolower($row["sort_title"]) . "__" . $idx] = $row;
235 } else {
236 $set[strtolower($row["title"]) . "__" . $idx] = $row;
237 }
238 }
239 unset($tr_data["set"]);
240 if ($this->getOrderDirection() == "asc") {
241 ksort($set);
242 } else {
243 krsort($set);
244 }
245 $set = array_values($set);
246 if ($parent) {
247 array_unshift($set, $parent);
248 }
249
250 $this->setData($set);
251 } else {
252 $this->setData($tr_data["set"]);
253 }
254 }
255
256 public function initFilter(): void
257 {
258 // for scorm and objectives this filter does not make sense / is not implemented
259 $olp = ilObjectLP::getInstance($this->obj_id);
260 $collection = $olp->getCollectionInstance();
261 if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
262
263 // show collection only/all
264 $ti = new ilRadioGroupInputGUI(
265 $this->lng->txt("trac_view_mode"),
266 "view_mode"
267 );
268 $ti->addOption(
269 new ilRadioOption($this->lng->txt("trac_view_mode_all"), "")
270 );
271 $ti->addOption(
272 new ilRadioOption(
273 $this->lng->txt("trac_view_mode_collection"),
274 "coll"
275 )
276 );
277 $this->addFilterItem($ti);
278 $ti->readFromSession();
279 $this->filter["view_mode"] = $ti->getValue();
280 }
281 }
282
283 protected function fillRow(array $a_set): void
284 {
285 global $DIC;
287
288 if (!$this->isPercentageAvailable($a_set["obj_id"])) {
289 $a_set["percentage"] = null;
290 }
291
292 foreach ($this->getSelectedColumns() as $c) {
293 if (!(bool) ($a_set["privacy_conflict"] ?? null)) {
294 $val = (trim(($a_set[$c] ?? '')) == "")
295 ? " "
296 : $a_set[$c];
297
298 if (($a_set[$c] ?? '') != "" || $c == "status") {
299 switch ($c) {
300 case "first_access":
302 new ilDateTime(
303 $a_set[$c],
305 )
306 );
307 break;
308
309 case "last_access":
311 new ilDateTime($a_set[$c], IL_CAL_UNIX)
312 );
313 break;
314
315 case "status":
316 $val = $icons->renderIconForStatus($a_set[$c] ?? ilLPStatusIcons::ICON_VARIANT_LONG);
317
318 if (($a_set["ref_id"] ?? 0) &&
319 $a_set["type"] != "lobj" &&
320 $a_set["type"] != "sco" &&
321 $a_set["type"] != "st" &&
322 $a_set["type"] != "mob") {
323 $timing = $this->showTimingsWarning(
324 $a_set["ref_id"],
325 $this->user_id
326 );
327 if ($timing) {
328 if ($timing !== true) {
329 $timing = ": " . ilDatePresentation::formatDate(
330 new ilDate(
331 $timing,
333 )
334 );
335 } else {
336 $timing = "";
337 }
338 $this->tpl->setCurrentBlock('warning_img');
339 $this->tpl->setVariable(
340 'WARNING_IMG',
342 'time_warn.svg'
343 )
344 );
345 $this->tpl->setVariable(
346 'WARNING_ALT',
347 $this->lng->txt(
348 'trac_time_passed'
349 ) . $timing
350 );
351 $this->tpl->parseCurrentBlock();
352 }
353 }
354 break;
355
356 case "spent_seconds":
358 $a_set["type"]
359 )) {
360 $val = "-";
361 } else {
363 $a_set[$c],
364 ($a_set[$c] < 3600 ? true : false)
365 ); // #14858
366 }
367 break;
368
369 case "percentage":
370 $val = $a_set[$c] . "%";
371 break;
372
373 }
374 }
375 if ($c == "mark" &&
376 !ilObjectLP::supportsMark($this->type)) {
377 $val = "-";
378 }
379 if ($c == "spent_seconds" &&
380 !ilObjectLP::supportsSpentSeconds($this->type)) {
381 $val = "-";
382 }
383 if ($c == "percentage" &&
384 !$this->isPercentageAvailable($a_set["obj_id"])) {
385 $val = "-";
386 }
387 } else {
388 $val = "&nbsp;";
389 }
390
391 $this->tpl->setCurrentBlock("user_field");
392 $this->tpl->setVariable("VAL_UF", $val);
393 $this->tpl->parseCurrentBlock();
394 }
395
396 if ($a_set["privacy_conflict"] ?? null) {
397 $this->tpl->setCurrentBlock("permission_bl");
398 $this->tpl->setVariable(
399 "TXT_NO_PERMISSION",
400 $this->lng->txt("status_no_permission")
401 );
402 $this->tpl->parseCurrentBlock();
403 }
404
405 if ($a_set["title"] == "") {
406 $a_set["title"] = "--" . $this->lng->txt("none") . "--";
407 }
408
409 $this->tpl->setVariable(
410 "ICON",
411 ilObject::_getIcon(0, "tiny", $a_set["type"])
412 );
413 $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
414
415 if (in_array(
416 $a_set['type'],
417 array('fold', 'grp')
418 ) && $a_set['obj_id'] != $this->obj_id) {
419 if ($a_set['type'] == 'fold') {
420 $object_gui = 'ilobjfoldergui';
421 } else {
422 $object_gui = 'ilobjgroupgui';
423 }
424 $this->tpl->setCurrentBlock('title_linked');
425
426 $base_class = '';
427 if ($this->http->wrapper()->query()->has('baseClass')) {
428 $base_class = $this->http->wrapper()->query()->retrieve(
429 'baseClass',
430 $this->refinery->kindlyTo()->string()
431 );
432 }
433 // link structure gets too complicated
434 if ($base_class != "ilDashboardGUI" && $base_class != "ilAdministrationGUI") {
435 $old = $this->ctrl->getParameterArrayByClass(
436 'illplistofobjectsgui'
437 );
438 $this->ctrl->setParameterByClass(
439 'illplistofobjectsgui',
440 'ref_id',
441 $a_set["ref_id"]
442 );
443 $this->ctrl->setParameterByClass(
444 'illplistofobjectsgui',
445 'details_id',
446 $a_set["ref_id"]
447 );
448 $this->ctrl->setParameterByClass(
449 'illplistofobjectsgui',
450 'user_id',
451 $this->user_id
452 );
453 $url = $this->ctrl->getLinkTargetByClass(
454 array('ilrepositorygui',
455 $object_gui,
456 'illearningprogressgui',
457 'illplistofobjectsgui'
458 ),
459 'userdetails'
460 );
461 $this->ctrl->setParameterByClass(
462 'illplistofobjectsgui',
463 'ref_id',
464 $old["ref_id"] ?? null
465 );
466 $this->ctrl->setParameterByClass(
467 'illplistofobjectsgui',
468 'details_id',
469 $old["details_id"]
470 );
471 $this->ctrl->setParameterByClass(
472 'illplistofobjectsgui',
473 'user_id',
474 $old["user_id"]
475 );
476 } else {
477 $url = "#";
478 }
479
480 $this->tpl->setVariable("URL_TITLE", $url);
481 $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
482 $this->tpl->parseCurrentBlock();
483 } else {
484 $this->tpl->setCurrentBlock('title_plain');
485 $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
486 $this->tpl->parseCurrentBlock();
487 }
488
489 // #16453 / #17163
490 if (($a_set['ref_id'] ?? 0)) {
491 $path = new ilPathGUI();
492 $path = $path->getPath($this->ref_id, $a_set['ref_id']);
493 if ($path) {
494 $this->tpl->setVariable(
495 'COLL_PATH',
496 $this->lng->txt('path') . ': ' . $path
497 );
498 }
499 }
500
501 // #13807 / #17069
502 if (($a_set["ref_id"] ?? 0) &&
504 'edit_learning_progress',
505 $a_set['ref_id']
506 )) {
507 if (!in_array(
508 $a_set["type"],
509 array("sco", "lobj")
510 ) && !$this->getPrintMode()) {
511 $this->tpl->setCurrentBlock("item_command");
512 $this->ctrl->setParameterByClass(
513 "illplistofobjectsgui",
514 "userdetails_id",
515 $a_set["ref_id"]
516 );
517 $this->tpl->setVariable(
518 "HREF_COMMAND",
519 $this->ctrl->getLinkTargetByClass(
520 "illplistofobjectsgui",
521 'edituser'
522 )
523 );
524 $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('edit'));
525 $this->ctrl->setParameterByClass(
526 "illplistofobjectsgui",
527 "userdetails_id",
528 ""
529 );
530 $this->tpl->parseCurrentBlock();
531 }
532 }
533 }
534
535 protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
536 {
537 $a_excel->setCell($a_row, 0, $this->lng->txt("type"));
538 $a_excel->setCell($a_row, 1, $this->lng->txt("title"));
539
540 $labels = $this->getSelectableColumns();
541 $cnt = 2;
542 foreach ($this->getSelectedColumns() as $c) {
543 $a_excel->setCell($a_row, $cnt++, $labels[$c]["txt"]);
544 }
545
546 $a_excel->setBold(
547 "A" . $a_row . ":" . $a_excel->getColumnCoord($cnt - 1) . $a_row
548 );
549 }
550
551 protected function fillRowExcel(
552 ilExcel $a_excel,
553 int &$a_row,
554 array $a_set
555 ): void {
556 $a_excel->setCell($a_row, 0, $this->lng->txt($a_set["type"]));
557 $a_excel->setCell($a_row, 1, $a_set["title"]);
558
559 $cnt = 2;
560 foreach ($this->getSelectedColumns() as $c) {
561 if ($c != 'status') {
562 $val = $this->parseValue($c, $a_set[$c], $this->type);
563 } else {
565 (int) $a_set[$c]
566 );
567 }
568 $a_excel->setCell($a_row, $cnt++, $val);
569 }
570 }
571
572 protected function fillHeaderCSV(ilCSVWriter $a_csv): void
573 {
574 $a_csv->addColumn($this->lng->txt("type"));
575 $a_csv->addColumn($this->lng->txt("title"));
576
577 $labels = $this->getSelectableColumns();
578 foreach ($this->getSelectedColumns() as $c) {
579 $a_csv->addColumn($labels[$c]["txt"]);
580 }
581
582 $a_csv->addRow();
583 }
584
585 protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
586 {
587 $a_csv->addColumn($this->lng->txt($a_set["type"]));
588 $a_csv->addColumn($a_set["title"]);
589
590 foreach ($this->getSelectedColumns() as $c) {
591 if ($c != 'status') {
592 $val = $this->parseValue($c, $a_set[$c], $this->type);
593 } else {
595 (int) $a_set[$c]
596 );
597 }
598 $a_csv->addColumn($val);
599 }
600
601 $a_csv->addRow();
602 }
603}
const IL_CAL_UNIX
const IL_CAL_DATETIME
addColumn(string $a_col)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
Class for single dates.
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
TableGUI class for learning progress.
showTimingsWarning(int $a_ref_id, int $a_user_id)
parseValue(string $id, ?string $value, string $type)
isPercentageAvailable(int $a_obj_id)
parseTitle(int $a_obj_id, string $action, int $a_user_id=0)
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
static supportsSpentSeconds(string $obj_type)
static supportsMark(string $obj_type)
static getInstance(int $obj_id)
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
Creates a path for a start and endnode.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
determineOffsetAndOrder(bool $a_omit_offset=false)
setExportFormats(array $formats)
Set available export formats.
setExternalSegmentation(bool $a_val)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setEnableTitle(bool $a_enabletitle)
setShowTemplates(bool $a_value)
setFormAction(string $a_form_action, bool $a_multipart=false)
resetOffset(bool $a_in_determination=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setPrintMode(bool $a_value=false)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
setMaxCount(int $a_max_count)
set max.
static getObjectsDataForUser(int $a_user_id, int $a_parent_obj_id, int $a_parent_ref_id, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999, ?array $a_filters=null, ?array $a_additional_fields=null, bool $use_collection=true)
Get all object-based tracking data for user and parent object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
__construct(?object $a_parent_obj, string $a_parent_cmd, int $a_user_id, int $a_obj_id, int $a_ref_id, bool $a_print_view=false)
Constructor.
fillRow(array $a_set)
Standard Version of Fill Row.
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
Excel Version of Fill Row.
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
Excel Version of Fill Header.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:32
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url
$cols
Definition: xhr_table.php:11