ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTrSummaryTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
5
16{
17
21 protected $dic;
22
26 public function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_print_mode = false)
27 {
28 global $DIC;
29
30 $ilCtrl = $DIC['ilCtrl'];
31 $objDefinition = $DIC['objDefinition'];
32
33 $this->setId("trsmy");
34 $this->dic = $DIC;
35 $this->ref_id = $a_ref_id;
36 $this->obj_id = ilObject::_lookupObjId($a_ref_id);
37 $this->is_root = ($a_ref_id == ROOT_FOLDER_ID);
38
39 if (!$this->is_root) {
40 // #17084 - are we multi-object or not?
41 // we cannot parse type filter (too complicated)
42 $type = ilObject::_lookupType($this->obj_id);
43 if (!$objDefinition->isContainer($type)) {
44 $this->type = $type;
45 include_once './Services/Object/classes/class.ilObjectLP.php';
46 $this->olp = ilObjectLP::getInstance($this->obj_id);
47 }
48 }
49
50 parent::__construct($a_parent_obj, $a_parent_cmd);
51
52 if ($a_print_mode) {
53 $this->setPrintMode(true);
54 }
55
56 $this->parseTitle($this->obj_id, "trac_summary");
57 $this->setLimit(9999);
58 $this->setShowTemplates(true);
59 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
60
61 $this->addColumn($this->lng->txt("title"), "title");
62 $this->setDefaultOrderField("title");
63
64 $labels = $this->getSelectableColumns();
65 foreach ($this->getSelectedColumns() as $c) {
66 $this->addColumn($labels[$c]["txt"], $c);
67 }
68
69 if ($this->dic->rbac()->system()->checkAccess('write', $this->ref_id)) {
70 $this->addColumn($this->lng->txt("path"));
71 $this->addColumn($this->lng->txt("action"));
72 }
73
74
75 // $this->setExternalSorting(true);
76 $this->setEnableHeader(true);
77 $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
78 $this->setRowTemplate("tpl.trac_summary_row.html", "Services/Tracking");
79 $this->initFilter();
80
81 $this->getItems($a_parent_obj->getObjId(), $a_ref_id);
82 }
83
84 public function getSelectableColumns()
85 {
86 global $DIC;
87
88 $lng = $DIC['lng'];
89 $ilSetting = $DIC['ilSetting'];
90
91 $lng_map = array("user_total" => "users", "first_access_min" => "trac_first_access",
92 "last_access_max" => "trac_last_access", "mark" => "trac_mark", "status" => "trac_status",
93 'status_changed_max' => 'trac_status_changed',
94 "spent_seconds_avg" => "trac_spent_seconds", "percentage_avg" => "trac_percentage",
95 "read_count_sum" => "trac_read_count", "read_count_avg" => "trac_read_count",
96 "read_count_spent_seconds_avg" => "trac_read_count_spent_seconds"
97 );
98
99
100 $all = array("user_total");
101 $default = array();
102
103 // show only if extended data was activated in lp settings
104 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
105 $tracking = new ilObjUserTracking();
106 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) {
107 $all[] = "read_count_sum";
108 $all[] = "read_count_avg";
109 $default[] = "read_count_sum";
110 }
111 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
112 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds($this->type)) {
113 $all[] = "spent_seconds_avg";
114 $default[] = "spent_seconds_avg";
115 }
116 }
117 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT) &&
118 $tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
119 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds($this->type)) {
120 $all[] = "read_count_spent_seconds_avg";
121 // $default[] = "read_count_spent_seconds_avg";
122 }
123 }
124
125
126 if ($this->is_root || !$this->type || $this->isPercentageAvailable($this->obj_id)) {
127 $all[] = "percentage_avg";
128 }
129
130 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
131 $all[] = "status";
132 $all[] = 'status_changed_max';
133 }
134
135 if ($this->is_root || !$this->type || ilObjectLP::supportsMark($this->type)) {
136 $all[] = "mark";
137 }
138
139 $privacy = array("gender", "city", "country", "sel_country");
140 foreach ($privacy as $field) {
141 if ($ilSetting->get("usr_settings_course_export_" . $field)) {
142 $all[] = $field;
143 }
144 }
145
146 $all[] = "language";
147
148 $default[] = "percentage_avg";
149 $default[] = "status";
150 $default[] = "mark";
151
152 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
153 $all[] = "first_access_min";
154 $all[] = "last_access_max";
155 }
156
157 $all[] = "create_date_min";
158 $all[] = "create_date_max";
159
160 $columns = array();
161 foreach ($all as $column) {
162 $l = $column;
163
164 $prefix = false;
165 if (substr($l, -3) == "avg") {
166 $prefix = "&#216; ";
167 } elseif (substr($l, -3) == "sum" || $l == "user_total") {
168 $prefix = "&#8721; ";
169 }
170
171 if (isset($lng_map[$l])) {
172 $l = $lng_map[$l];
173 }
174
175 $txt = $prefix . $lng->txt($l);
176
177 if (in_array($column, array("read_count_avg", "spent_seconds_avg", "percentage_avg"))) {
178 $txt .= " / " . $lng->txt("user");
179 }
180
181 $columns[$column] = array(
182 "txt" => $txt,
183 "default" => (in_array($column, $default) ? true :false)
184 );
185 }
186 return $columns;
187 }
188
192 public function initFilter()
193 {
194 global $DIC;
195
196 $lng = $DIC['lng'];
197 $ilSetting = $DIC['ilSetting'];
198
199 if ($this->is_root) {
200 return parent::initBaseFilter(true, false);
201 }
202
203 // show only if extended data was activated in lp settings
204 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
205 $tracking = new ilObjUserTracking();
206
207 $item = $this->addFilterItemByMetaType(
208 "user_total",
210 true,
211 "&#8721; " . $lng->txt("users")
212 );
213 $this->filter["user_total"] = $item->getValue();
214
215 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) {
216 $item = $this->addFilterItemByMetaType(
217 "read_count",
219 true,
220 "&#8721; " . $lng->txt("trac_read_count")
221 );
222 $this->filter["read_count"] = $item->getValue();
223 }
224
225 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
226 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds($this->type)) {
227 $item = $this->addFilterItemByMetaType(
228 "spent_seconds",
230 true,
231 "&#216; " . $lng->txt("trac_spent_seconds") . " / " . $lng->txt("user")
232 );
233 $this->filter["spent_seconds"]["from"] = $item->getCombinationItem("from")->getValueInSeconds();
234 $this->filter["spent_seconds"]["to"] = $item->getCombinationItem("to")->getValueInSeconds();
235 }
236 }
237
238 if ($this->is_root || !$this->type || $this->isPercentageAvailable($this->obj_id)) {
239 $item = $this->addFilterItemByMetaType(
240 "percentage",
242 true,
243 "&#216; " . $lng->txt("trac_percentage") . " / " . $lng->txt("user")
244 );
245 $this->filter["percentage"] = $item->getValue();
246 }
247
248 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
249 include_once "Services/Tracking/classes/class.ilLPStatus.php";
250 $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT, true);
251 $item->setOptions(array("" => $lng->txt("trac_all"),
256 $this->filter["status"] = $item->getValue();
257 if ($this->filter["status"]) {
258 $this->filter["status"]--;
259 }
260
261 $item = $this->addFilterItemByMetaType("trac_status_changed", ilTable2GUI::FILTER_DATE_RANGE, true);
262 $this->filter["status_changed"] = $item->getDate();
263 }
264
265 if ($this->is_root || !$this->type || ilObjectLP::supportsMark($this->type)) {
266 $item = $this->addFilterItemByMetaType(
267 "mark",
269 true,
270 $lng->txt("trac_mark")
271 );
272 $this->filter["mark"] = $item->getValue();
273 }
274
275 if ($ilSetting->get("usr_settings_course_export_gender")) {
276 $item = $this->addFilterItemByMetaType("gender", ilTable2GUI::FILTER_SELECT, true);
277 $item->setOptions(array(
278 "" => $lng->txt("trac_all"),
279 "n" => $lng->txt("gender_n"),
280 "m" => $lng->txt("gender_m"),
281 "f" => $lng->txt("gender_f"),
282 ));
283 $this->filter["gender"] = $item->getValue();
284 }
285
286 if ($ilSetting->get("usr_settings_course_export_city")) {
287 $item = $this->addFilterItemByMetaType("city", ilTable2GUI::FILTER_TEXT, true);
288 $this->filter["city"] = $item->getValue();
289 }
290
291 if ($ilSetting->get("usr_settings_course_export_country")) {
292 $item = $this->addFilterItemByMetaType("country", ilTable2GUI::FILTER_TEXT, true);
293 $this->filter["country"] = $item->getValue();
294 }
295
296 if ($ilSetting->get("usr_settings_course_export_sel_country")) {
297 $item = $this->addFilterItemByMetaType("sel_country", ilTable2GUI::FILTER_SELECT, true);
298 $item->setOptions(array("" => $lng->txt("trac_all")) + $this->getSelCountryCodes());
299 $this->filter["sel_country"] = $item->getValue();
300 }
301
302 $item = $this->addFilterItemByMetaType("language", ilTable2GUI::FILTER_LANGUAGE, true);
303 $this->filter["language"] = $item->getValue();
304
305 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
306 $item = $this->addFilterItemByMetaType("trac_first_access", ilTable2GUI::FILTER_DATETIME_RANGE, true);
307 $this->filter["first_access"] = $item->getDate();
308
309 $item = $this->addFilterItemByMetaType("trac_last_access", ilTable2GUI::FILTER_DATETIME_RANGE, true);
310 $this->filter["last_access"] = $item->getDate();
311 }
312
313 $item = $this->addFilterItemByMetaType("registration_filter", ilTable2GUI::FILTER_DATE_RANGE, true);
314 $this->filter["registration"] = $item->getDate();
315 }
316
317 public function getSelCountryCodes()
318 {
319 global $DIC;
320
321 $lng = $DIC['lng'];
322
323 include_once("./Services/Utilities/classes/class.ilCountry.php");
324 $options = array();
325 foreach (ilCountry::getCountryCodes() as $c) {
326 $options[$c] = $lng->txt("meta_c_" . $c);
327 }
328 asort($options);
329 return $options;
330 }
331
338 public function getItems($a_object_id, $a_ref_id)
339 {
340 global $DIC;
341
342 $lng = $DIC['lng'];
343 $rbacsystem = $DIC['rbacsystem'];
344
345 include_once("./Services/Tracking/classes/class.ilTrQuery.php");
346
347 // show only selected subobjects for lp mode
348 $preselected_obj_ids = $filter = null;
349
351 if (
352 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL ||
353 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION ||
354 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR
355 ) {
356 $collection = $olp->getCollectionInstance();
357 $preselected_obj_ids[$a_object_id][] = $a_ref_id;
358 foreach ($collection->getItems() as $item => $item_info) {
359 $tmp_lp = ilObjectLP::getInstance(ilObject::_lookupObjId($item_info));
360 if ($tmp_lp->isActive()) {
361 $preselected_obj_ids[ilObject::_lookupObjId($item_info)][] = $item_info;
362 }
363 }
364 $filter = $this->getCurrentFilter();
365 } elseif ($this->is_root) {
366 // using search to get all relevant objects
367 // #8498/#8499: restrict to objects with at least "read_learning_progress" access
368 $preselected_obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read_learning_progress");
369 } else {
370 // using summary filters
371 $filter = $this->getCurrentFilter();
372 }
373
374
375
377 $a_object_id,
378 $a_ref_id,
383 $filter,
384 $this->getSelectedColumns(),
385 $preselected_obj_ids
386 );
387
388 // build status to image map
389 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
390 include_once("./Services/Tracking/classes/class.ilLPStatus.php");
391 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
395 $status_map = array();
396 foreach ($valid_status as $status) {
399 $status_map[$status] = ilUtil::img($path, $text);
400 }
401
402 // language map
403 $lng->loadLanguageModule("meta");
404 $languages = array();
405 foreach ($lng->getInstalledLanguages() as $lang_key) {
406 $languages[$lang_key] = $lng->txt("meta_l_" . $lang_key);
407 }
408
409 $rows = array();
410 foreach ($data["set"] as $idx => $result) {
411 // sessions have no title
412 if ($result["title"] == "" && $result["type"] == "sess") {
413 include_once "Modules/Session/classes/class.ilObjSession.php";
414 $sess = new ilObjSession($result["obj_id"], false);
415 $data["set"][$idx]["title"] = $sess->getFirstAppointment()->appointmentToString();
416 }
417
418 $data["set"][$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($result["obj_id"], $result["type"]);
419
420 // #13807
421 if ($result["ref_ids"]) {
422 $valid = false;
423 foreach ($result["ref_ids"] as $check_ref_id) {
424 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
425 if (ilLearningProgressAccess::checkPermission('read_learning_progress', $check_ref_id)) {
426 $valid = true;
427 break;
428 }
429 }
430 if (!$valid) {
431 foreach (array_keys($data["set"][$idx]) as $col_id) {
432 if (!in_array($col_id, array("type", "title", "obj_id", "ref_id", "offline"))) {
433 $data["set"][$idx][$col_id] = null;
434 }
435 }
436 $data["set"][$idx]["privacy_conflict"] = true;
437 continue;
438 }
439 }
440
441 // percentages
442 $users_no = $result["user_total"];
443 $data["set"][$idx]["country"] = $this->getItemsPercentages($result["country"], $users_no);
444 $data["set"][$idx]["gender"] = $this->getItemsPercentages($result["gender"], $users_no, array(
445 "n" => $lng->txt("gender_n"),
446 "m" => $lng->txt("gender_m"),
447 "f" => $lng->txt("gender_f"),
448 ));
449 $data["set"][$idx]["city"] = $this->getItemsPercentages($result["city"], $users_no);
450 $data["set"][$idx]["sel_country"] = $this->getItemsPercentages($result["sel_country"], $users_no, $this->getSelCountryCodes());
451 $data["set"][$idx]["mark"] = $this->getItemsPercentages($result["mark"], $users_no);
452 $data["set"][$idx]["language"] = $this->getItemsPercentages($result["language"], $users_no, $languages);
453
454 // if we encounter any invalid status codes, e.g. null, map them to not attempted instead
455 foreach ($result["status"] as $status_code => $status_counter) {
456 // null is cast to ""
457 if ($status_code === "" || !in_array($status_code, $valid_status)) {
458 $result["status"][ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM] += $status_counter;
459 unset($result["status"][$status_code]);
460 }
461 }
462 $data["set"][$idx]["status"] = $this->getItemsPercentagesStatus($result["status"], $users_no, $status_map);
463
464 if (!$this->isPercentageAvailable($result["obj_id"])) {
465 $data["set"][$idx]["percentage_avg"] = null;
466 }
467 }
468
469 $this->setMaxCount($data["cnt"]);
470 $this->setData($data["set"]);
471 }
472
482 protected function getItemsPercentages(array $data = null, $overall, array $value_map = null, $limit = 3)
483 {
484 global $DIC;
485
486 $lng = $DIC['lng'];
487
488 if (!$overall) {
489 return false;
490 }
491
492 $result = array();
493
494 if ($data) {
495 // if we have only 1 item more than the limit, "others" makes no sense
496 if (sizeof($data) == $limit + 1) {
497 $limit++;
498 }
499
500 $counter = $others_counter = $others_sum = 0;
501 foreach ($data as $id => $count) {
502 $counter++;
503 if ($counter <= $limit) {
504 $caption = $id;
505
506 if ($value_map && isset($value_map[$id])) {
507 $caption = $value_map[$id];
508 }
509
510 if ($caption == "") {
511 $caption = $lng->txt("none");
512 }
513
514 $perc = round($count / $overall * 100);
515 $result[] = array(
516 "caption" => $caption,
517 "absolute" => $count, // ." ".($count > 1 ? $lng->txt("users") : $lng->txt("user")),
518 "percentage" => $perc
519 );
520 } else {
521 $others_sum += $count;
522 $others_counter++;
523 }
524 }
525
526 if ($others_counter) {
527 $perc = round($others_sum / $overall * 100);
528 $result[] = array(
529 "caption" => $others_counter . " " . $lng->txt("trac_others"),
530 "absolute" => $others_sum, // ." ".($others_sum > 1 ? $lng->txt("users") : $lng->txt("user")),
531 "percentage" => $perc
532 );
533 }
534 }
535
536 return $result;
537 }
538
547 protected function getItemsPercentagesStatus(array $data = null, $overall, array $value_map = null)
548 {
549 global $DIC;
550
551 $lng = $DIC['lng'];
552
553 $result = array();
554 foreach ($value_map as $id => $caption) {
555 $count = 0;
556 if (isset($data[$id])) {
557 $count = $data[$id];
558 }
559 $perc = round($count / $overall * 100);
560
561 $result[] = array(
562 "caption" => $caption,
563 "absolute" => $count,
564 "percentage" => $perc
565 );
566 }
567
568 return $result;
569 }
570
571 protected function parseValue($id, $value, $type)
572 {
573 global $DIC;
574
575 $lng = $DIC['lng'];
576
577 // get rid of aggregation
578 $pos = strrpos($id, "_");
579 if ($pos !== false) {
580 $function = strtoupper(substr($id, $pos + 1));
581 if (in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT"))) {
582 $id = substr($id, 0, $pos);
583 }
584 }
585
586 if (trim($value) == "") {
587 if ($id == "title") {
588 return "--" . $lng->txt("none") . "--";
589 }
590 return "";
591 }
592 switch ($id) {
593 case 'status_changed':
594 case "first_access":
595 case "create_date":
597 break;
598
599 case "last_access":
601 break;
602
603 case "spent_seconds":
604 case "read_count_spent_seconds":
606 $value = "-";
607 } else {
608 $value = ilDatePresentation::secondsToString($value, ($value < 3600 ? true : false)); // #14858
609 }
610 break;
611
612 case "percentage":
613 if (false /* $this->isPercentageAvailable() */) {
614 $value = "-";
615 } else {
616 $value = $value . "%";
617 }
618 break;
619
620 case "mark":
622 $value = "-";
623 }
624 break;
625 }
626
627 return $value;
628 }
629
633 protected function fillRow($a_set)
634 {
635 global $DIC;
636
637 $lng = $DIC['lng'];
638 $ilCtrl = $DIC['ilCtrl'];
639
640 $this->tpl->setVariable("ICON", ilObject::_getIcon($a_set["obj_id"], "tiny", $a_set["type"]));
641 $this->tpl->setVariable("ICON_ALT", $lng->txt($a_set["type"]));
642 $this->tpl->setVariable("TITLE", $a_set["title"]);
643
644 if ($a_set["offline"] || $a_set["privacy_conflict"]) {
645 $mess = array();
646 if ($a_set["offline"]) {
647 $mess[] = $lng->txt("offline");
648 }
649 if ($a_set["privacy_conflict"]) {
650 $mess[] = $lng->txt("status_no_permission");
651 }
652 $this->tpl->setCurrentBlock("status_bl");
653 $this->tpl->setVariable("TEXT_STATUS", implode(", ", $mess));
654 $this->tpl->parseCurrentBlock();
655 }
656
657 foreach ($this->getSelectedColumns() as $c) {
658 switch ($c) {
659 case "country":
660 case "gender":
661 case "city":
662 case "language":
663 case "status":
664 case "mark":
665 case "sel_country":
666 $this->renderPercentages($c, $a_set[$c]);
667 break;
668
669 case "percentage_avg":
670 if ((int) $a_set[$c] === 0 || !$this->isPercentageAvailable($a_set["obj_id"])) {
671 $this->tpl->setVariable(strtoupper($c), "");
672 break;
673 }
674
675 // no break
676 default:
677 $value = $this->parseValue($c, $a_set[$c], $a_set["type"]);
678 $this->tpl->setVariable(strtoupper($c), $value);
679 break;
680 }
681 }
682
683 if ($this->is_root) {
684 $path = $this->buildPath($a_set["ref_ids"], false, true);
685 if ($path) {
686 $this->tpl->setCurrentBlock("item_path");
687 foreach ($path as $ref_id => $path_item) {
688 $this->tpl->setVariable("PATH_ITEM", $path_item);
689
690 if (!$this->anonymized) {
691 $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
692 $this->tpl->setVariable("URL_DETAILS", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
693 $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
694 $this->tpl->setVariable("TXT_DETAILS", $lng->txt('trac_participants'));
695 } else {
696 $this->tpl->setVariable("URL_DETAILS", ilLink::_getLink($ref_id, $a_set["type"]));
697 $this->tpl->setVariable("TXT_DETAILS", $lng->txt('view'));
698 }
699
700 $this->tpl->parseCurrentBlock();
701 }
702 }
703
704 $this->tpl->setCurrentBlock("item_command");
705 $ilCtrl->setParameterByClass(get_class($this), 'hide', $a_set["obj_id"]);
706 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this), 'hide'));
707 $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
708 $this->tpl->parseCurrentBlock();
709
710 $this->tpl->touchBlock("path_action");
711 } elseif ($a_set["ref_ids"]) { // #18446
712 // #16453
713 include_once './Services/Tree/classes/class.ilPathGUI.php';
714 $path = new ilPathGUI();
715 $path = $path->getPath($this->ref_id, array_pop($a_set["ref_ids"]));
716 if ($path) {
717 $this->tpl->setVariable('COLL_PATH', $this->lng->txt('path') . ': ' . $path);
718 }
719 }
720 }
721
722 protected function renderPercentages($id, $data)
723 {
724 if ($data) {
725 foreach ($data as $item) {
726 $this->tpl->setCurrentBlock($id . "_row");
727 $this->tpl->setVariable("CAPTION", $item["caption"]);
728 $this->tpl->setVariable("ABSOLUTE", $item["absolute"]);
729 $this->tpl->setVariable("PERCENTAGE", $item["percentage"]);
730 $this->tpl->parseCurrentBlock();
731 }
732 } else {
733 $this->tpl->touchBlock($id);
734 ;
735 }
736 }
737
738 protected function isArrayColumn($a_name)
739 {
740 if (in_array($a_name, array("country", "gender", "city", "language", "status", "mark", 'sel_country'))) {
741 return true;
742 }
743 return false;
744 }
745
746 public function numericOrdering($a_field)
747 {
748 $pos = strrpos($a_field, "_");
749 if ($pos !== false) {
750 $function = strtoupper(substr($a_field, $pos + 1));
751 if (in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT", "TOTAL"))) {
752 return true;
753 }
754 }
755 return false;
756 }
757
758 protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
759 {
760 $a_excel->setCell($a_row, 0, $this->lng->txt("title"));
761
762 $labels = $this->getSelectableColumns();
763 $cnt = 1;
764 foreach ($this->getSelectedColumns() as $c) {
765 $label = $labels[$c]["txt"];
766 $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
767 $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
768
769 if (!$this->isArrayColumn($c)) {
770 $a_excel->setCell($a_row, $cnt, $label);
771 $cnt++;
772 } else {
773 if ($c != "status") {
774 $a_excel->setCell($a_row, $cnt, $label . " #1");
775 $a_excel->setCell($a_row, ++$cnt, $label . " #1");
776 $a_excel->setCell($a_row, ++$cnt, $label . " #1 %");
777 $a_excel->setCell($a_row, ++$cnt, $label . " #2");
778 $a_excel->setCell($a_row, ++$cnt, $label . " #2");
779 $a_excel->setCell($a_row, ++$cnt, $label . " #2 %");
780 $a_excel->setCell($a_row, ++$cnt, $label . " #3");
781 $a_excel->setCell($a_row, ++$cnt, $label . " #3");
782 $a_excel->setCell($a_row, ++$cnt, $label . " #3 %");
783 $a_excel->setCell($a_row, ++$cnt, $label . " " . $this->lng->txt("trac_others"));
784 $a_excel->setCell($a_row, ++$cnt, $label . " " . $this->lng->txt("trac_others"));
785 $a_excel->setCell($a_row, ++$cnt, $label . " " . $this->lng->txt("trac_others") . " %");
786 } else {
787 // build status to image map
788 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
789 include_once("./Services/Tracking/classes/class.ilLPStatus.php");
790 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
794 $cnt--;
795 foreach ($valid_status as $status) {
797 $a_excel->setCell($a_row, ++$cnt, $text);
798 $a_excel->setCell($a_row, ++$cnt, $text . " %");
799 }
800 }
801 $cnt++;
802 }
803 }
804
805 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($cnt) . $a_row);
806 }
807
808 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
809 {
810 $a_excel->setCell($a_row, 0, $a_set["title"]);
811
812 $cnt = 1;
813 foreach ($this->getSelectedColumns() as $c) {
814 if (!$this->isArrayColumn($c)) {
815 $val = $this->parseValue($c, $a_set[$c], $a_set["type"]);
816 $a_excel->setCell($a_row, $cnt, $val);
817 $cnt++;
818 } else {
819 foreach ((array) $a_set[$c] as $idx => $value) {
820 if ($c == "status") {
821 $a_excel->setCell($a_row, $cnt, (int) $value["absolute"]);
822 $a_excel->setCell($a_row, ++$cnt, $value["percentage"] . "%");
823 } else {
824 $a_excel->setCell($a_row, $cnt, $value["caption"]);
825 $a_excel->setCell($a_row, ++$cnt, (int) $value["absolute"]);
826 $a_excel->setCell($a_row, ++$cnt, $value["percentage"] . "%");
827 }
828 $cnt++;
829 }
830 if (sizeof($a_set[$c]) < 4 && $c != "status") {
831 for ($loop = 4; $loop > sizeof($a_set[$c]); $loop--) {
832 $a_excel->setCell($a_row, $cnt, "");
833 $a_excel->setCell($a_row, ++$cnt, "");
834 $a_excel->setCell($a_row, ++$cnt, "");
835 $cnt++;
836 }
837 }
838 }
839 }
840 }
841
842 protected function fillHeaderCSV($a_csv)
843 {
844 $a_csv->addColumn($this->lng->txt("title"));
845
846 $labels = $this->getSelectableColumns();
847 foreach ($this->getSelectedColumns() as $c) {
848 $label = $labels[$c]["txt"];
849 $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
850 $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
851
852 if (!$this->isArrayColumn($c)) {
853 $a_csv->addColumn($label);
854 } else {
855 if ($c != "status") {
856 $a_csv->addColumn($label . " #1");
857 $a_csv->addColumn($label . " #1");
858 $a_csv->addColumn($label . " #1 %");
859 $a_csv->addColumn($label . " #2");
860 $a_csv->addColumn($label . " #2");
861 $a_csv->addColumn($label . " #2 %");
862 $a_csv->addColumn($label . " #3");
863 $a_csv->addColumn($label . " #3");
864 $a_csv->addColumn($label . " #3 %");
865 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others"));
866 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others"));
867 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others") . " %");
868 } else {
869 // build status to image map
870 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
871 include_once("./Services/Tracking/classes/class.ilLPStatus.php");
872 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
876 foreach ($valid_status as $status) {
878 $a_csv->addColumn($text);
879 $a_csv->addColumn($text . " %");
880 }
881 }
882 }
883 }
884
885 $a_csv->addRow();
886 }
887
888 protected function fillRowCSV($a_csv, $a_set)
889 {
890 $a_csv->addColumn($a_set["title"]);
891
892 foreach ($this->getSelectedColumns() as $c) {
893 if (!$this->isArrayColumn($c)) {
894 $val = $this->parseValue($c, $a_set[$c], $a_set["type"]);
895 $a_csv->addColumn($val);
896 } else {
897 foreach ((array) $a_set[$c] as $idx => $value) {
898 if ($c != "status") {
899 $a_csv->addColumn($value["caption"]);
900 }
901 $a_csv->addColumn((int) $value["absolute"]);
902 $a_csv->addColumn($value["percentage"]);
903 }
904 if (sizeof($a_set[$c]) < 4 && $c != "status") {
905 for ($loop = 4; $loop > sizeof($a_set[$c]); $loop--) {
906 $a_csv->addColumn("");
907 $a_csv->addColumn("");
908 $a_csv->addColumn("");
909 }
910 }
911 }
912 }
913
914 $a_csv->addRow();
915 }
916}
$result
if(! $in) $columns
Definition: Utf8Test.php:45
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
static getCountryCodes()
Get country codes (DIN EN 3166-1)
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
setBold($a_coords)
Set cell(s) to bold.
getColumnCoord($a_col)
Get column "name" from number.
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($as_query=false)
parseTitle($a_obj_id, $action, $a_user_id=false)
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.
static checkPermission($a_permission, $a_ref_id, $a_user_id=null)
wrapper for rbac access checks
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
static _getImagePathForStatus($a_status)
Get image path for status.
static isObjectOffline($a_obj_id, $a_type=null)
static supportsMark($a_obj_type)
static supportsSpentSeconds($a_obj_type)
static getInstance($a_obj_id)
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
Creates a path for a start and endnode.
getSelectedColumns()
Get selected columns.
setEnableHeader($a_enableheader)
Set Enable Header.
setExportFormats(array $formats)
Set available export formats.
setPrintMode($a_value=false)
Toogle print mode.
setData($a_data)
set table data @access public
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
getOffset()
Get offset.
const FILTER_DURATION_RANGE
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setShowTemplates($a_value)
Toggle templates.
const FILTER_DATETIME_RANGE
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
static getObjectsSummaryForObject( $a_parent_obj_id, $a_parent_ref_id, $a_order_field="", $a_order_dir="", $a_offset=0, $a_limit=9999, array $a_filters=null, array $a_additional_fields=null, $a_preselected_obj_ids=null)
Get all aggregated tracking data for parent object.
getItemsPercentages(array $data=null, $overall, array $value_map=null, $limit=3)
Render data as needed for summary list (based on grouped values)
numericOrdering($a_field)
Should this field be sorted numeric?
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
Excel Version of Fill Row.
getSelectableColumns()
Get selectable columns.
getItems($a_object_id, $a_ref_id)
Build summary item rows for given object and filter(s.
fillHeaderExcel(ilExcel $a_excel, &$a_row)
Excel Version of Fill Header.
fillHeaderCSV($a_csv)
CSV Version of Fill Header.
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_print_mode=false)
Constructor.
parseValue($id, $value, $type)
fillRow($a_set)
Fill table row.
getItemsPercentagesStatus(array $data=null, $overall, array $value_map=null)
Render status data as needed for summary list (based on grouped values)
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$valid
$txt
Definition: error.php:13
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
$type
$DIC
Definition: xapitoken.php:46
$rows
Definition: xhr_table.php:10