ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTrSummaryTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
27{
28 protected ?ilObjectLP $olp = null;
29 protected bool $is_root;
30 protected bool $is_in_course = false;
31 protected bool $is_in_group = false;
32 protected int $ref_id;
33 protected ?string $type = null;
34 protected int $obj_id;
35
38
42 public function __construct(
43 ?object $a_parent_obj,
44 string $a_parent_cmd,
45 int $a_ref_id,
46 bool $a_print_mode = false
47 ) {
48 global $DIC;
49 $this->objDefinition = $DIC['objDefinition'];
50 $this->rbacsystem = $DIC->rbac()->system();
51 $this->access = $DIC->access();
52 $this->ref_id = $a_ref_id;
53 $this->obj_id = ilObject::_lookupObjId($a_ref_id);
54 $this->is_root = ($a_ref_id == ROOT_FOLDER_ID);
55
56 $this->setId("trsmy");
57
58 if (!$this->is_root) {
59 // #17084 - are we multi-object or not?
60 // we cannot parse type filter (too complicated)
61 $type = ilObject::_lookupType($this->obj_id);
62 if (!$this->objDefinition->isContainer($type)) {
63 $this->type = $type;
64 $this->olp = ilObjectLP::getInstance($this->obj_id);
65 }
66 }
67
68 if (
69 !$this->is_root &&
70 $DIC->repositoryTree()->checkForParentType($this->ref_id, 'grp')
71 ) {
72 $this->is_in_group = true;
73 } elseif (
74 !$this->is_root &&
75 $DIC->repositoryTree()->checkForParentType($this->ref_id, 'crs')
76 ) {
77 $this->is_in_course = true;
78 }
79
80 parent::__construct($a_parent_obj, $a_parent_cmd);
81
82 if ($a_print_mode) {
83 $this->setPrintMode(true);
84 }
85
86 $this->parseTitle($this->obj_id, "trac_summary");
87 $this->setLimit(9999);
88 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
89
90 $this->addColumn($this->lng->txt("title"), "title");
91 $this->setDefaultOrderField("title");
92
93 $labels = $this->getSelectableColumns();
94 foreach ($this->getSelectedColumns() as $c) {
95 // see bug #35119; these column list percentage lists and are not sortable
96 if (in_array($c, ["status", "mark", "language", "country", "gender", "city", "sel_country"])) {
97 $this->addColumn($labels[$c]["txt"]);
98 } else {
99 $this->addColumn($labels[$c]["txt"], $c);
100 }
101 }
102
103 if ($this->is_root) {
104 $this->addColumn($this->lng->txt("path"));
105 $this->addColumn($this->lng->txt("action"));
106 }
107
108 // $this->setExternalSorting(true);
109 $this->setEnableHeader(true);
110 $this->setFormAction(
111 $this->ctrl->getFormActionByClass(get_class($this))
112 );
113 $this->setRowTemplate("tpl.trac_summary_row.html", "components/ILIAS/Tracking");
114 $this->initFilter();
115
116 $this->getItems($a_parent_obj->getObjId(), $a_ref_id);
117 }
118
119 public function getSelectableColumns(): array
120 {
121 $lng_map = array("user_total" => "users",
122 "first_access_min" => "trac_first_access",
123 "last_access_max" => "trac_last_access",
124 "mark" => "trac_mark",
125 "status" => "trac_status",
126 'status_changed_max' => 'trac_status_changed',
127 "spent_seconds_avg" => "trac_spent_seconds",
128 "percentage_avg" => "trac_percentage",
129 "read_count_sum" => "trac_read_count",
130 "read_count_avg" => "trac_read_count",
131 "read_count_spent_seconds_avg" => "trac_read_count_spent_seconds"
132 );
133
134 $all = array("user_total");
135 $default = array();
136
137 // show only if extended data was activated in lp settings
138 $tracking = new ilObjUserTracking();
139 if ($tracking->hasExtendedData(
141 )) {
142 $all[] = "read_count_sum";
143 $all[] = "read_count_avg";
144 $default[] = "read_count_sum";
145 }
146 if ($tracking->hasExtendedData(
148 )) {
149 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds(
150 $this->type
151 )) {
152 $all[] = "spent_seconds_avg";
153 $default[] = "spent_seconds_avg";
154 }
155 }
156 if ($tracking->hasExtendedData(
158 ) &&
159 $tracking->hasExtendedData(
161 )) {
162 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds(
163 $this->type
164 )) {
165 $all[] = "read_count_spent_seconds_avg";
166 // $default[] = "read_count_spent_seconds_avg";
167 }
168 }
169
170 if ($this->is_root || !$this->type || $this->isPercentageAvailable(
171 $this->obj_id
172 )) {
173 $all[] = "percentage_avg";
174 }
175
176 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
177 $all[] = "status";
178 $all[] = 'status_changed_max';
179 }
180
181 if ($this->is_root || !$this->type || ilObjectLP::supportsMark(
182 $this->type
183 )) {
184 $all[] = "mark";
185 }
186
187 $privacy = array("gender", "city", "country", "sel_country");
188 foreach ($privacy as $field) {
189 if (
190 ($this->is_in_course && $this->setting->get("usr_settings_course_export_" . $field)) ||
191 ($this->is_in_group && $this->setting->get("usr_settings_group_export_" . $field))
192 ) {
193 $all[] = $field;
194 }
195 }
196
197 $all[] = "language";
198
199 $default[] = "percentage_avg";
200 $default[] = "status";
201 $default[] = "mark";
202
203 if ($tracking->hasExtendedData(
205 )) {
206 $all[] = "first_access_min";
207 $all[] = "last_access_max";
208 }
209
210 $all[] = "create_date_min";
211 $all[] = "create_date_max";
212
213 $columns = array();
214 foreach ($all as $column) {
215 $l = $column;
216
217 $prefix = false;
218 if (substr($l, -3) == "avg") {
219 $prefix = "&#216; ";
220 } elseif (substr($l, -3) == "sum" || $l == "user_total") {
221 $prefix = "&#8721; ";
222 }
223
224 if (isset($lng_map[$l])) {
225 $l = $lng_map[$l];
226 }
227
228 $txt = $prefix . $this->lng->txt($l);
229
230 if (in_array(
231 $column,
232 array("read_count_avg",
233 "spent_seconds_avg",
234 "percentage_avg"
235 )
236 )) {
237 $txt .= " / " . $this->lng->txt("user");
238 }
239
240 $columns[$column] = array(
241 "txt" => $txt,
242 "default" => (in_array($column, $default) ? true : false)
243 );
244 }
245 return $columns;
246 }
247
248 public function initFilter(): void
249 {
250 if ($this->is_root) {
251 parent::initBaseFilter(true, false);
252 return;
253 }
254
255 // show only if extended data was activated in lp settings
256 $tracking = new ilObjUserTracking();
257
258 $item = $this->addFilterItemByMetaType(
259 "user_total",
261 true,
262 "&#8721; " . $this->lng->txt("users")
263 );
264 $this->filter["user_total"] = $item->getValue();
265
266 if ($tracking->hasExtendedData(
268 )) {
269 $item = $this->addFilterItemByMetaType(
270 "read_count_sum",
272 true,
273 "&#8721; " . $this->lng->txt("trac_read_count")
274 );
275 $this->filter["read_count"] = $item->getValue();
276 }
277
278 if ($tracking->hasExtendedData(
280 )) {
281 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds(
282 $this->type
283 )) {
284 $item = $this->addFilterItemByMetaType(
285 "spent_seconds",
287 true,
288 "&#216; " . $this->lng->txt(
289 "trac_spent_seconds"
290 ) . " / " . $this->lng->txt("user")
291 );
292 $this->filter["spent_seconds"]["from"] = $item->getCombinationItem(
293 "from"
294 )->getValueInSeconds();
295 $this->filter["spent_seconds"]["to"] = $item->getCombinationItem(
296 "to"
297 )->getValueInSeconds();
298 }
299 }
300
301 if ($this->is_root || !$this->type || $this->isPercentageAvailable(
302 $this->obj_id
303 )) {
304 $item = $this->addFilterItemByMetaType(
305 "percentage",
307 true,
308 "&#216; " . $this->lng->txt(
309 "trac_percentage"
310 ) . " / " . $this->lng->txt("user")
311 );
312 $this->filter["percentage"] = $item->getValue();
313 }
314
315 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
316 $item = $this->addFilterItemByMetaType(
317 "status",
319 true
320 );
321 $item->setOptions(
322 array("" => $this->lng->txt("trac_all"),
323 ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM + 1 => $this->lng->txt(
325 ),
326 ilLPStatus::LP_STATUS_IN_PROGRESS_NUM + 1 => $this->lng->txt(
328 ),
329 ilLPStatus::LP_STATUS_COMPLETED_NUM + 1 => $this->lng->txt(
331 ),
332 ilLPStatus::LP_STATUS_FAILED_NUM + 1 => $this->lng->txt(
334 )
335 )
336 );
337 $this->filter["status"] = $item->getValue();
338 if ($this->filter["status"]) {
339 $this->filter["status"]--;
340 }
341
342 $item = $this->addFilterItemByMetaType(
343 "status_changed_max",
345 true,
346 $this->lng->txt("trac_status_changed")
347 );
348 $this->filter["status_changed"] = $item->getDate();
349 }
350
351 if ($this->is_root || !$this->type || ilObjectLP::supportsMark(
352 $this->type
353 )) {
354 $item = $this->addFilterItemByMetaType(
355 "mark",
357 true,
358 $this->lng->txt("trac_mark")
359 );
360 $this->filter["mark"] = $item->getValue();
361 }
362
363 if ($this->setting->get("usr_settings_course_export_gender")) {
364 $item = $this->addFilterItemByMetaType(
365 "gender",
367 true
368 );
369 $item->setOptions(
370 array(
371 "" => $this->lng->txt("trac_all"),
372 "n" => $this->lng->txt("gender_n"),
373 "m" => $this->lng->txt("gender_m"),
374 "f" => $this->lng->txt("gender_f"),
375 )
376 );
377 $this->filter["gender"] = $item->getValue();
378 }
379
380 if ($this->setting->get("usr_settings_course_export_city")) {
381 $item = $this->addFilterItemByMetaType(
382 "city",
384 true
385 );
386 $this->filter["city"] = $item->getValue();
387 }
388
389 if ($this->setting->get("usr_settings_course_export_country")) {
390 $item = $this->addFilterItemByMetaType(
391 "country",
393 true
394 );
395 $this->filter["country"] = $item->getValue();
396 }
397
398 if ($this->setting->get("usr_settings_course_export_sel_country")) {
399 $item = $this->addFilterItemByMetaType(
400 "sel_country",
402 true
403 );
404 $item->setOptions(
405 array("" => $this->lng->txt(
406 "trac_all"
407 )
408 ) + $this->getSelCountryCodes()
409 );
410 $this->filter["sel_country"] = $item->getValue();
411 }
412
413 $item = $this->addFilterItemByMetaType(
414 "language",
416 true
417 );
418 $this->filter["language"] = $item->getValue();
419
420 if ($tracking->hasExtendedData(
422 )) {
423 $item = $this->addFilterItemByMetaType(
424 "first_access_min",
426 true,
427 $this->lng->txt("trac_first_access")
428 );
429 $this->filter["first_access"] = $item->getDate();
430
431 $item = $this->addFilterItemByMetaType(
432 "last_access_max",
434 true,
435 $this->lng->txt("trac_last_access")
436 );
437 $this->filter["last_access"] = $item->getDate();
438 }
439
440 $item = $this->addFilterItemByMetaType(
441 "registration_filter",
443 true
444 );
445 $this->filter["registration"] = $item->getDate();
446 }
447
448 public function getSelCountryCodes(): array
449 {
450 $options = array();
451 foreach (ilCountry::getCountryCodes() as $c) {
452 $options[$c] = $this->lng->txt("meta_c_" . $c);
453 }
454 asort($options);
455 return $options;
456 }
457
461 public function getItems(int $a_object_id, int $a_ref_id): void
462 {
463 // show only selected subobjects for lp mode
464 $preselected_obj_ids = $filter = null;
465
467 if (
472 ) {
473 $collection = $olp->getCollectionInstance();
474 $preselected_obj_ids[$a_object_id][] = $a_ref_id;
475 foreach ($collection->getItems() as $item => $item_info) {
476 $tmp_lp = ilObjectLP::getInstance(
477 ilObject::_lookupObjId($item_info)
478 );
479 if ($tmp_lp->isActive()) {
480 $preselected_obj_ids[ilObject::_lookupObjId(
481 $item_info
482 )][] = $item_info;
483 }
484 }
485 $filter = $this->getCurrentFilter();
486 } elseif ($this->is_root) {
487 // using search to get all relevant objects
488 // #8498/#8499: restrict to objects with at least "read_learning_progress" access
489 $preselected_obj_ids = $this->searchObjects(
490 $this->getCurrentFilter(true),
491 "read_learning_progress"
492 );
493 } else {
494 // using summary filters
495 $filter = $this->getCurrentFilter();
496 }
497
499 $a_object_id,
500 $a_ref_id,
505 $filter,
506 $this->getSelectedColumns(),
507 $preselected_obj_ids
508 );
509
510 // build status to image map
511 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
515 );
516 $status_map = array();
518 foreach ($valid_status as $status) {
519 $status_map[$status] = $status_icons->renderIconForStatus($status);
520 }
521
522 // language map
523 $this->lng->loadLanguageModule("meta");
524 $languages = array();
525 foreach ($this->lng->getInstalledLanguages() as $lang_key) {
526 $languages[$lang_key] = $this->lng->txt("meta_l_" . $lang_key);
527 }
528
529 $rows = array();
530 foreach ($data["set"] as $idx => $result) {
531 // sessions have no title
532 if ($result["title"] == "" && $result["type"] == "sess") {
533 $sess = new ilObjSession($result["obj_id"], false);
534 $data["set"][$idx]["title"] = $sess->getFirstAppointment(
535 )->appointmentToString();
536 }
537
538 $data["set"][$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline(
539 $result["obj_id"],
540 $result["type"]
541 );
542
543 // #13807
544 if ($result["ref_ids"]) {
545 $valid = false;
546 foreach ($result["ref_ids"] as $check_ref_id) {
548 'read_learning_progress',
549 $check_ref_id
550 )) {
551 $valid = true;
552 break;
553 }
554 }
555 if (!$valid) {
556 foreach (array_keys($data["set"][$idx]) as $col_id) {
557 if (!in_array(
558 $col_id,
559 array("type",
560 "title",
561 "obj_id",
562 "ref_id",
563 "offline"
564 )
565 )) {
566 $data["set"][$idx][$col_id] = null;
567 }
568 }
569 $data["set"][$idx]["privacy_conflict"] = true;
570 continue;
571 }
572 }
573
574 // percentages
575 $users_no = $result["user_total"];
576 $data["set"][$idx]["country"] = $this->getItemsPercentages(
577 $result["country"],
578 $users_no
579 );
580 $data["set"][$idx]["gender"] = $this->getItemsPercentages(
581 $result["gender"],
582 $users_no,
583 array(
584 "n" => $this->lng->txt("gender_n"),
585 "m" => $this->lng->txt("gender_m"),
586 "f" => $this->lng->txt("gender_f"),
587 )
588 );
589 $data["set"][$idx]["city"] = $this->getItemsPercentages(
590 $result["city"],
591 $users_no
592 );
593 $data["set"][$idx]["sel_country"] = $this->getItemsPercentages(
594 $result["sel_country"],
595 $users_no,
596 $this->getSelCountryCodes()
597 );
598 $data["set"][$idx]["mark"] = $this->getItemsPercentages(
599 $result["mark"],
600 $users_no
601 );
602 $data["set"][$idx]["language"] = $this->getItemsPercentages(
603 $result["language"],
604 $users_no,
605 $languages
606 );
607
608 // if we encounter any invalid status codes, e.g. null, map them to not attempted instead
609 foreach ($result["status"] as $status_code => $status_counter) {
610 // null is cast to ""
611 if ($status_code === "" || !in_array(
612 $status_code,
613 $valid_status
614 )) {
615 $result['status'][ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM] =
616 $result['status'][ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM] ?? 0 + $status_counter;
617 unset($result["status"][$status_code]);
618 }
619 }
620 $data["set"][$idx]["status"] = $this->getItemsPercentagesStatus(
621 $result["status"],
622 $users_no,
623 $status_map
624 );
625
626 if (!$this->isPercentageAvailable($result["obj_id"])) {
627 $data["set"][$idx]["percentage_avg"] = null;
628 }
629 }
630
631 $this->setMaxCount($data["cnt"]);
632 $this->setData($data["set"]);
633 }
634
638 protected function getItemsPercentages(
639 $data = null,
640 int $overall = 0,
641 ?array $value_map = null,
642 $limit = 3
643 ): array {
644 if (!$overall) {
645 return [];
646 }
647
648 $result = [];
649
650 if ($data) {
651 if (is_array($data) && count($data) < $limit) {
652 $limit = count($data);
653 }
654 if (is_array($data) && (count($data) == $limit + 1)) {
655 ++$limit;
656 }
657 $counter = $others_counter = 0;
658 $others_sum = $overall;
659 $all_sum = 0;
660 foreach ($data as $id => $count) {
661 $counter++;
662 $all_sum += $count;
663 if ($counter <= $limit) {
664 $caption = $id;
665
666 if ($value_map && isset($value_map[$id])) {
667 $caption = $value_map[$id];
668 }
669 if ($caption == "") {
670 $caption = $this->lng->txt("none");
671 }
672 if (
673 $counter == $limit &&
674 $all_sum < $overall
675 ) {
676 ++$others_counter;
677 continue;
678 }
679 $perc = round($count / $overall * 100);
680 $result[] = array(
681 "caption" => $caption,
682 "absolute" => $count,
683 // ." ".($count > 1 ? $lng->txt("users") : $lng->txt("user")),
684 "percentage" => $perc
685 );
686 $others_sum -= $count;
687 } else {
688 $others_counter++;
689 }
690 }
691
692 if ($others_counter) {
693 $perc = round($others_sum / $overall * 100);
694 $result[] = array(
695 "caption" => $others_counter . " " . $this->lng->txt(
696 "trac_others"
697 ),
698 "absolute" => $others_sum,
699 // ." ".($others_sum > 1 ? $lng->txt("users") : $lng->txt("user")),
700 "percentage" => $perc
701 );
702 }
703 }
704
705 return $result;
706 }
707
711 protected function getItemsPercentagesStatus(
712 $data = null,
713 int $overall = 0,
714 ?array $value_map = null
715 ): array {
716 $result = array();
717 foreach ($value_map as $id => $caption) {
718 $count = 0;
719 if (isset($data[$id])) {
720 $count = $data[$id];
721 }
722 $perc = round($count / $overall * 100);
723
724 $result[] = array(
725 "caption" => $caption,
726 "absolute" => $count,
727 "percentage" => $perc
728 );
729 }
730
731 return $result;
732 }
733
734 protected function parseValue(
735 string $id,
736 ?string $value,
737 string $type
738 ): string {
739 // get rid of aggregation
740 $pos = strrpos($id, "_");
741 if ($pos !== false) {
742 $function = strtoupper(substr($id, $pos + 1));
743 if (in_array(
744 $function,
745 array("MIN", "MAX", "SUM", "AVG", "COUNT")
746 )) {
747 $id = substr($id, 0, $pos);
748 }
749 }
750
751 if (trim((string) $value) == "") {
752 if ($id == "title") {
753 return "--" . $this->lng->txt("none") . "--";
754 }
755 return "";
756 }
757 switch ($id) {
758 case 'status_changed':
759 case "first_access":
760 case "create_date":
762 new ilDateTime($value, IL_CAL_DATETIME)
763 );
764 break;
765
766 case "last_access":
768 new ilDateTime($value, IL_CAL_UNIX)
769 );
770 break;
771
772 case "spent_seconds":
773 case "read_count_spent_seconds":
775 $value = "-";
776 } else {
778 (int) $value,
779 $value < 3600
780 ); // #14858
781 }
782 break;
783
784 case "percentage":
785 if (false /* $this->isPercentageAvailable() */) {
786 $value = "-";
787 } else {
788 $value = $value . "%";
789 }
790 break;
791
792 case "mark":
793 if (!ilObjectLP::supportsMark($type)) {
794 $value = "-";
795 }
796 break;
797 }
798
799 return $value;
800 }
801
805 protected function fillRow(array $a_set): void
806 {
807 $this->tpl->setVariable(
808 "ICON",
810 (int) $a_set["obj_id"],
811 "tiny",
812 $a_set["type"]
813 )
814 );
815 $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
816 $this->tpl->setVariable("TITLE", $a_set["title"]);
817
818 if ($a_set["offline"] || ($a_set["privacy_conflict"] ?? null)) {
819 $mess = array();
820 if ($a_set["offline"]) {
821 $mess[] = $this->lng->txt("offline");
822 }
823 if ($a_set["privacy_conflict"] ?? null) {
824 $mess[] = $this->lng->txt("status_no_permission");
825 }
826 $this->tpl->setCurrentBlock("status_bl");
827 $this->tpl->setVariable("TEXT_STATUS", implode(", ", $mess));
828 $this->tpl->parseCurrentBlock();
829 }
830
831 foreach ($this->getSelectedColumns() as $c) {
832 switch ($c) {
833 case "country":
834 case "gender":
835 case "city":
836 case "language":
837 case "status":
838 case "mark":
839 case "sel_country":
840 $this->renderPercentages($c, $a_set[$c]);
841 break;
842
843 case "percentage_avg":
844 if ((int) $a_set[$c] === 0 || !$this->isPercentageAvailable(
845 $a_set["obj_id"]
846 )) {
847 $this->tpl->setVariable(strtoupper($c), "");
848 break;
849 }
850
851 // no break
852 default:
853 $value = $this->parseValue($c, $a_set[$c], $a_set["type"]);
854 $this->tpl->setVariable(strtoupper($c), $value);
855 break;
856 }
857 }
858
859 if ($this->is_root) {
860 $path = $this->buildPath($a_set["ref_ids"]);
861 if ($path) {
862 $this->tpl->setCurrentBlock("item_path");
863 foreach ($path as $ref_id => $path_item) {
864 $this->tpl->setVariable("PATH_ITEM", $path_item);
865
866 if (!$this->anonymized) {
867 $this->ctrl->setParameterByClass(
868 $this->ctrl->getCmdClass(),
869 'details_id',
870 $ref_id
871 );
872 $this->tpl->setVariable(
873 "URL_DETAILS",
874 $this->ctrl->getLinkTargetByClass(
875 $this->ctrl->getCmdClass(),
876 'details'
877 )
878 );
879 $this->ctrl->setParameterByClass(
880 $this->ctrl->getCmdClass(),
881 'details_id',
882 ''
883 );
884 $this->tpl->setVariable(
885 "TXT_DETAILS",
886 $this->lng->txt(
887 'trac_participants'
888 )
889 );
890 } else {
891 $this->tpl->setVariable(
892 "URL_DETAILS",
893 ilLink::_getLink(
894 $ref_id,
895 $a_set["type"]
896 )
897 );
898 $this->tpl->setVariable(
899 "TXT_DETAILS",
900 $this->lng->txt('view')
901 );
902 }
903
904 $this->tpl->parseCurrentBlock();
905 }
906 }
907
908 $this->tpl->setCurrentBlock("item_command");
909 $this->ctrl->setParameterByClass(
910 get_class($this),
911 'hide',
912 $a_set["obj_id"]
913 );
914 $this->tpl->setVariable(
915 "HREF_COMMAND",
916 $this->ctrl->getLinkTargetByClass(
917 get_class($this),
918 'hide'
919 )
920 );
921 $this->tpl->setVariable(
922 "TXT_COMMAND",
923 $this->lng->txt('trac_hide')
924 );
925 $this->tpl->parseCurrentBlock();
926
927 $this->tpl->touchBlock("path_action");
928 } elseif ($a_set["ref_ids"]) { // #18446
929 // #16453
930 $path = new ilPathGUI();
931 $path = $path->getPath(
932 $this->ref_id,
933 (int) array_pop($a_set["ref_ids"])
934 );
935 if ($path) {
936 $this->tpl->setVariable(
937 'COLL_PATH',
938 $this->lng->txt('path') . ': ' . $path
939 );
940 }
941 }
942 }
943
944 protected function renderPercentages(string $id, array $data): void
945 {
946 if ($data) {
947 foreach ($data as $item) {
948 $this->tpl->setCurrentBlock($id . "_row");
949 $this->tpl->setVariable("CAPTION", $item["caption"]);
950 $this->tpl->setVariable("ABSOLUTE", $item["absolute"]);
951 $this->tpl->setVariable("PERCENTAGE", $item["percentage"]);
952 $this->tpl->parseCurrentBlock();
953 }
954 } else {
955 $this->tpl->touchBlock($id);
956 }
957 }
958
959 protected function isArrayColumn(string $a_name): bool
960 {
961 if (in_array(
962 $a_name,
963 array("country",
964 "gender",
965 "city",
966 "language",
967 "status",
968 "mark",
969 'sel_country'
970 )
971 )) {
972 return true;
973 }
974 return false;
975 }
976
977 public function numericOrdering(string $a_field): bool
978 {
979 $pos = strrpos($a_field, "_");
980 if ($pos !== false) {
981 $function = strtoupper(substr($a_field, $pos + 1));
982 if (in_array(
983 $function,
984 array("MIN", "MAX", "SUM", "AVG", "COUNT", "TOTAL")
985 )) {
986 return true;
987 }
988 }
989 return false;
990 }
991
992 public function isStatusShown(): bool
993 {
994 return in_array('status', $this->getSelectedColumns());
995 }
996
997 protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
998 {
999 $a_excel->setCell($a_row, 0, $this->lng->txt("title"));
1000
1001 $labels = $this->getSelectableColumns();
1002 $cnt = 1;
1003 foreach ($this->getSelectedColumns() as $c) {
1004 $label = $labels[$c]["txt"];
1005 $label = str_replace(
1006 "&#216;",
1007 $this->lng->txt("trac_average"),
1008 $label
1009 );
1010 $label = str_replace(
1011 "&#8721;",
1012 $this->lng->txt("trac_sum"),
1013 $label
1014 );
1015
1016 if (!$this->isArrayColumn($c)) {
1017 $a_excel->setCell($a_row, $cnt, $label);
1018 $cnt++;
1019 } else {
1020 if ($c != "status") {
1021 $a_excel->setCell($a_row, $cnt, $label . " #1");
1022 $a_excel->setCell($a_row, ++$cnt, $label . " #1");
1023 $a_excel->setCell($a_row, ++$cnt, $label . " #1 %");
1024 $a_excel->setCell($a_row, ++$cnt, $label . " #2");
1025 $a_excel->setCell($a_row, ++$cnt, $label . " #2");
1026 $a_excel->setCell($a_row, ++$cnt, $label . " #2 %");
1027 $a_excel->setCell($a_row, ++$cnt, $label . " #3");
1028 $a_excel->setCell($a_row, ++$cnt, $label . " #3");
1029 $a_excel->setCell($a_row, ++$cnt, $label . " #3 %");
1030 $a_excel->setCell(
1031 $a_row,
1032 ++$cnt,
1033 $label . " " . $this->lng->txt(
1034 "trac_others"
1035 )
1036 );
1037 $a_excel->setCell(
1038 $a_row,
1039 ++$cnt,
1040 $label . " " . $this->lng->txt(
1041 "trac_others"
1042 )
1043 );
1044 $a_excel->setCell(
1045 $a_row,
1046 ++$cnt,
1047 $label . " " . $this->lng->txt(
1048 "trac_others"
1049 ) . " %"
1050 );
1051 } else {
1052 // build status to image map
1053 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
1057 );
1058 $cnt--;
1059 foreach ($valid_status as $status) {
1061 $status
1062 );
1063 $a_excel->setCell($a_row, ++$cnt, $text);
1064 $a_excel->setCell($a_row, ++$cnt, $text . " %");
1065 }
1066 }
1067 $cnt++;
1068 }
1069 }
1070
1071 $a_excel->setBold(
1072 "A" . $a_row . ":" . $a_excel->getColumnCoord($cnt) . $a_row
1073 );
1074 }
1075
1076 protected function fillRowExcel(
1077 ilExcel $a_excel,
1078 int &$a_row,
1079 array $a_set
1080 ): void {
1081 $a_excel->setCell($a_row, 0, $a_set["title"]);
1082
1083 $cnt = 1;
1084 foreach ($this->getSelectedColumns() as $c) {
1085 if (!$this->isArrayColumn($c)) {
1086 $val = $this->parseValue($c, $a_set[$c], $a_set["type"]);
1087 $a_excel->setCell($a_row, $cnt, $val);
1088 $cnt++;
1089 } else {
1090 foreach ((array) $a_set[$c] as $idx => $value) {
1091 if ($c == "status") {
1092 $a_excel->setCell(
1093 $a_row,
1094 $cnt,
1095 (int) $value["absolute"]
1096 );
1097 $a_excel->setCell(
1098 $a_row,
1099 ++$cnt,
1100 $value["percentage"] . "%"
1101 );
1102 } else {
1103 $a_excel->setCell($a_row, $cnt, $value["caption"]);
1104 $a_excel->setCell(
1105 $a_row,
1106 ++$cnt,
1107 (int) $value["absolute"]
1108 );
1109 $a_excel->setCell(
1110 $a_row,
1111 ++$cnt,
1112 $value["percentage"] . "%"
1113 );
1114 }
1115 $cnt++;
1116 }
1117 if (sizeof($a_set[$c]) < 4 && $c != "status") {
1118 for ($loop = 4; $loop > sizeof($a_set[$c]); $loop--) {
1119 $a_excel->setCell($a_row, $cnt, "");
1120 $a_excel->setCell($a_row, ++$cnt, "");
1121 $a_excel->setCell($a_row, ++$cnt, "");
1122 $cnt++;
1123 }
1124 }
1125 }
1126 }
1127 }
1128
1129 protected function fillHeaderCSV(ilCSVWriter $a_csv): void
1130 {
1131 $a_csv->addColumn($this->lng->txt("title"));
1132
1133 $labels = $this->getSelectableColumns();
1134 foreach ($this->getSelectedColumns() as $c) {
1135 $label = $labels[$c]["txt"];
1136 $label = str_replace(
1137 "&#216;",
1138 $this->lng->txt("trac_average"),
1139 $label
1140 );
1141 $label = str_replace(
1142 "&#8721;",
1143 $this->lng->txt("trac_sum"),
1144 $label
1145 );
1146
1147 if (!$this->isArrayColumn($c)) {
1148 $a_csv->addColumn($label);
1149 } else {
1150 if ($c != "status") {
1151 $a_csv->addColumn($label . " #1");
1152 $a_csv->addColumn($label . " #1");
1153 $a_csv->addColumn($label . " #1 %");
1154 $a_csv->addColumn($label . " #2");
1155 $a_csv->addColumn($label . " #2");
1156 $a_csv->addColumn($label . " #2 %");
1157 $a_csv->addColumn($label . " #3");
1158 $a_csv->addColumn($label . " #3");
1159 $a_csv->addColumn($label . " #3 %");
1160 $a_csv->addColumn(
1161 $label . " " . $this->lng->txt("trac_others")
1162 );
1163 $a_csv->addColumn(
1164 $label . " " . $this->lng->txt("trac_others")
1165 );
1166 $a_csv->addColumn(
1167 $label . " " . $this->lng->txt("trac_others") . " %"
1168 );
1169 } else {
1170 // build status to image map
1171 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
1175 );
1176 foreach ($valid_status as $status) {
1178 $status
1179 );
1180 $a_csv->addColumn($text);
1181 $a_csv->addColumn($text . " %");
1182 }
1183 }
1184 }
1185 }
1186
1187 $a_csv->addRow();
1188 }
1189
1190 protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
1191 {
1192 $a_csv->addColumn($a_set["title"]);
1193
1194 foreach ($this->getSelectedColumns() as $c) {
1195 if (!$this->isArrayColumn($c)) {
1196 $val = $this->parseValue($c, $a_set[$c], $a_set["type"]);
1197 $a_csv->addColumn($val);
1198 } else {
1199 foreach ((array) $a_set[$c] as $idx => $value) {
1200 if ($c != "status") {
1201 $a_csv->addColumn($value["caption"]);
1202 }
1203 $a_csv->addColumn((string) $value["absolute"]);
1204 $a_csv->addColumn($value["percentage"]);
1205 }
1206 if (sizeof($a_set[$c]) < 4 && $c != "status") {
1207 for ($loop = 4; $loop > sizeof($a_set[$c]); $loop--) {
1208 $a_csv->addColumn("");
1209 $a_csv->addColumn("");
1210 $a_csv->addColumn("");
1211 }
1212 }
1213 }
1214 }
1215
1216 $a_csv->addRow();
1217 }
1218}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
const IL_CAL_UNIX
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addColumn(string $a_col)
static getCountryCodes()
Get country codes (DIN EN 3166-1)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
@classDescription Date and time handling
setBold(string $a_coords)
Set cell(s) to bold.
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
getColumnCoord(int $a_col)
Get column "name" from number.
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
TableGUI class for learning progress.
getCurrentFilter(bool $as_query=false)
isPercentageAvailable(int $a_obj_id)
parseTitle(int $a_obj_id, string $action, int $a_user_id=0)
searchObjects(array $filter, string $permission, ?array $preset_obj_ids=null, bool $a_check_lp_activation=true)
Search objects that match current filters.
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
static isObjectOffline(int $a_obj_id, string $a_type='')
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
Base class for object lp connectors.
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.
static _lookupObjId(int $ref_id)
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setExportFormats(array $formats)
Set available export formats.
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setFormAction(string $a_form_action, bool $a_multipart=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)
const FILTER_DURATION_RANGE
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
const FILTER_NUMBER_RANGE
const FILTER_DATETIME_RANGE
setMaxCount(int $a_max_count)
set max.
static getObjectsSummaryForObject(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, ?array $a_preselected_obj_ids=null)
Get all aggregated tracking data for parent object :TODO: sorting, offset, limit, objectives,...
getItemsPercentages( $data=null, int $overall=0, ?array $value_map=null, $limit=3)
Render data as needed for summary list (based on grouped values)
renderPercentages(string $id, array $data)
getItems(int $a_object_id, int $a_ref_id)
Build summary item rows for given object and filter(s.
getSelectableColumns()
Get selectable columns.
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
__construct(?object $a_parent_obj, string $a_parent_cmd, int $a_ref_id, bool $a_print_mode=false)
Constructor.
numericOrdering(string $a_field)
Should this field be sorted numeric?
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.
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
getItemsPercentagesStatus( $data=null, int $overall=0, ?array $value_map=null)
Render status data as needed for summary list (based on grouped values)
parseValue(string $id, ?string $value, string $type)
fillRow(array $a_set)
Fill table row.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
const ROOT_FOLDER_ID
Definition: constants.php:32
$c
Definition: deliver.php:25
$valid
$txt
Definition: error.php:31
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$counter