ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
20 public function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_print_mode = false)
21 {
22 global $ilCtrl, $objDefinition;
23
24 $this->setId("trsmy");
25
26 $this->ref_id = $a_ref_id;
27 $this->obj_id = ilObject::_lookupObjId($a_ref_id);
28 $this->is_root = ($a_ref_id == ROOT_FOLDER_ID);
29
30 if (!$this->is_root) {
31 // #17084 - are we multi-object or not?
32 // we cannot parse type filter (too complicated)
33 $type = ilObject::_lookupType($this->obj_id);
34 if (!$objDefinition->isContainer($type)) {
35 $this->type = $type;
36 include_once './Services/Object/classes/class.ilObjectLP.php';
37 $this->olp = ilObjectLP::getInstance($this->obj_id);
38 }
39 }
40
41 parent::__construct($a_parent_obj, $a_parent_cmd);
42
43 if ($a_print_mode) {
44 $this->setPrintMode(true);
45 }
46
47 $this->parseTitle($this->obj_id, "trac_summary");
48 $this->setLimit(9999);
49 $this->setShowTemplates(true);
50 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
51
52 $this->addColumn($this->lng->txt("title"), "title");
53 $this->setDefaultOrderField("title");
54
55 $labels = $this->getSelectableColumns();
56 foreach ($this->getSelectedColumns() as $c) {
57 $this->addColumn($labels[$c]["txt"], $c);
58 }
59
60 if ($this->is_root) {
61 $this->addColumn($this->lng->txt("path"));
62 $this->addColumn($this->lng->txt("action"));
63 }
64
65
66 // $this->setExternalSorting(true);
67 $this->setEnableHeader(true);
68 $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
69 $this->setRowTemplate("tpl.trac_summary_row.html", "Services/Tracking");
70 $this->initFilter();
71
72 $this->getItems($a_parent_obj->getObjId(), $a_ref_id);
73 }
74
75 public function getSelectableColumns()
76 {
77 global $lng, $ilSetting;
78
79 $lng_map = array("user_total" => "users", "first_access_min" => "trac_first_access",
80 "last_access_max" => "trac_last_access", "mark" => "trac_mark", "status" => "trac_status",
81 'status_changed_max' => 'trac_status_changed',
82 "spent_seconds_avg" => "trac_spent_seconds", "percentage_avg" => "trac_percentage",
83 "read_count_sum" => "trac_read_count", "read_count_avg" => "trac_read_count",
84 "read_count_spent_seconds_avg" => "trac_read_count_spent_seconds"
85 );
86
87
88 $all = array("user_total");
89 $default = array();
90
91 // show only if extended data was activated in lp settings
92 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
93 $tracking = new ilObjUserTracking();
94 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) {
95 $all[] = "read_count_sum";
96 $all[] = "read_count_avg";
97 $default[] = "read_count_sum";
98 }
99 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
100 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds($this->type)) {
101 $all[] = "spent_seconds_avg";
102 $default[] = "spent_seconds_avg";
103 }
104 }
105 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT) &&
106 $tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
107 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds($this->type)) {
108 $all[] = "read_count_spent_seconds_avg";
109 // $default[] = "read_count_spent_seconds_avg";
110 }
111 }
112
113
114 if ($this->is_root || !$this->type || $this->isPercentageAvailable($this->obj_id)) {
115 $all[] = "percentage_avg";
116 }
117
118 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
119 $all[] = "status";
120 $all[] = 'status_changed_max';
121 }
122
123 if ($this->is_root || !$this->type || ilObjectLP::supportsMark($this->type)) {
124 $all[] = "mark";
125 }
126
127 $privacy = array("gender", "city", "country", "sel_country");
128 foreach ($privacy as $field) {
129 if ($ilSetting->get("usr_settings_course_export_" . $field)) {
130 $all[] = $field;
131 }
132 }
133
134 $all[] = "language";
135
136 $default[] = "percentage_avg";
137 $default[] = "status";
138 $default[] = "mark";
139
140 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
141 $all[] = "first_access_min";
142 $all[] = "last_access_max";
143 }
144
145 $all[] = "create_date_min";
146 $all[] = "create_date_max";
147
148 $columns = array();
149 foreach ($all as $column) {
150 $l = $column;
151
152 $prefix = false;
153 if (substr($l, -3) == "avg") {
154 $prefix = "&#216; ";
155 } elseif (substr($l, -3) == "sum" || $l == "user_total") {
156 $prefix = "&#8721; ";
157 }
158
159 if (isset($lng_map[$l])) {
160 $l = $lng_map[$l];
161 }
162
163 $txt = $prefix . $lng->txt($l);
164
165 if (in_array($column, array("read_count_avg", "spent_seconds_avg", "percentage_avg"))) {
166 $txt .= " / " . $lng->txt("user");
167 }
168
169 $columns[$column] = array(
170 "txt" => $txt,
171 "default" => (in_array($column, $default) ? true :false)
172 );
173 }
174 return $columns;
175 }
176
180 public function initFilter()
181 {
182 global $lng, $ilSetting;
183
184 if ($this->is_root) {
185 return parent::initBaseFilter(true, false);
186 }
187
188 // show only if extended data was activated in lp settings
189 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
190 $tracking = new ilObjUserTracking();
191
192 $item = $this->addFilterItemByMetaType(
193 "user_total",
195 true,
196 "&#8721; " . $lng->txt("users")
197 );
198 $this->filter["user_total"] = $item->getValue();
199
200 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) {
201 $item = $this->addFilterItemByMetaType(
202 "read_count",
204 true,
205 "&#8721; " . $lng->txt("trac_read_count")
206 );
207 $this->filter["read_count"] = $item->getValue();
208 }
209
210 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
211 if ($this->is_root || !$this->type || ilObjectLP::supportsSpentSeconds($this->type)) {
212 $item = $this->addFilterItemByMetaType(
213 "spent_seconds",
215 true,
216 "&#216; " . $lng->txt("trac_spent_seconds") . " / " . $lng->txt("user")
217 );
218 $this->filter["spent_seconds"]["from"] = $item->getCombinationItem("from")->getValueInSeconds();
219 $this->filter["spent_seconds"]["to"] = $item->getCombinationItem("to")->getValueInSeconds();
220 }
221 }
222
223 if ($this->is_root || !$this->type || $this->isPercentageAvailable($this->obj_id)) {
224 $item = $this->addFilterItemByMetaType(
225 "percentage",
227 true,
228 "&#216; " . $lng->txt("trac_percentage") . " / " . $lng->txt("user")
229 );
230 $this->filter["percentage"] = $item->getValue();
231 }
232
233 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
234 include_once "Services/Tracking/classes/class.ilLPStatus.php";
235 $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT, true);
236 $item->setOptions(array("" => $lng->txt("trac_all"),
241 $this->filter["status"] = $item->getValue();
242 if ($this->filter["status"]) {
243 $this->filter["status"]--;
244 }
245
246 $item = $this->addFilterItemByMetaType("trac_status_changed", ilTable2GUI::FILTER_DATE_RANGE, true);
247 $this->filter["status_changed"] = $item->getDate();
248 }
249
250 if ($this->is_root || !$this->type || ilObjectLP::supportsMark($this->type)) {
251 $item = $this->addFilterItemByMetaType(
252 "mark",
254 true,
255 $lng->txt("trac_mark")
256 );
257 $this->filter["mark"] = $item->getValue();
258 }
259
260 if ($ilSetting->get("usr_settings_course_export_gender")) {
261 $item = $this->addFilterItemByMetaType("gender", ilTable2GUI::FILTER_SELECT, true);
262 $item->setOptions(array(
263 "" => $lng->txt("trac_all"),
264 "n" => $lng->txt("gender_n"),
265 "m" => $lng->txt("gender_m"),
266 "f" => $lng->txt("gender_f"),
267 ));
268 $this->filter["gender"] = $item->getValue();
269 }
270
271 if ($ilSetting->get("usr_settings_course_export_city")) {
272 $item = $this->addFilterItemByMetaType("city", ilTable2GUI::FILTER_TEXT, true);
273 $this->filter["city"] = $item->getValue();
274 }
275
276 if ($ilSetting->get("usr_settings_course_export_country")) {
277 $item = $this->addFilterItemByMetaType("country", ilTable2GUI::FILTER_TEXT, true);
278 $this->filter["country"] = $item->getValue();
279 }
280
281 if ($ilSetting->get("usr_settings_course_export_sel_country")) {
282 $item = $this->addFilterItemByMetaType("sel_country", ilTable2GUI::FILTER_SELECT, true);
283 $item->setOptions(array("" => $lng->txt("trac_all"))+$this->getSelCountryCodes());
284 $this->filter["sel_country"] = $item->getValue();
285 }
286
287 $item = $this->addFilterItemByMetaType("language", ilTable2GUI::FILTER_LANGUAGE, true);
288 $this->filter["language"] = $item->getValue();
289
290 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
291 $item = $this->addFilterItemByMetaType("trac_first_access", ilTable2GUI::FILTER_DATETIME_RANGE, true);
292 $this->filter["first_access"] = $item->getDate();
293
294 $item = $this->addFilterItemByMetaType("trac_last_access", ilTable2GUI::FILTER_DATETIME_RANGE, true);
295 $this->filter["last_access"] = $item->getDate();
296 }
297
298 $item = $this->addFilterItemByMetaType("registration_filter", ilTable2GUI::FILTER_DATE_RANGE, true);
299 $this->filter["registration"] = $item->getDate();
300 }
301
302 public function getSelCountryCodes()
303 {
304 global $lng;
305
306 include_once("./Services/Utilities/classes/class.ilCountry.php");
307 $options = array();
308 foreach (ilCountry::getCountryCodes() as $c) {
309 $options[$c] = $lng->txt("meta_c_" . $c);
310 }
311 asort($options);
312 return $options;
313 }
314
321 public function getItems($a_object_id, $a_ref_id)
322 {
323 global $lng, $rbacsystem;
324
325 include_once("./Services/Tracking/classes/class.ilTrQuery.php");
326
327 // show only selected subobjects for lp mode
328 $preselected_obj_ids = $filter = null;
329
331 if (
332 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL ||
333 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION ||
334 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR
335 ) {
336 $collection = $olp->getCollectionInstance();
337 $preselected_obj_ids[$a_object_id][] = $a_ref_id;
338 foreach ($collection->getItems() as $item => $item_info) {
339 $tmp_lp = ilObjectLP::getInstance(ilObject::_lookupObjId($item_info));
340 if ($tmp_lp->isActive()) {
341 $preselected_obj_ids[ilObject::_lookupObjId($item_info)][] = $item_info;
342 }
343 }
344 $filter = $this->getCurrentFilter();
345 } elseif ($this->is_root) {
346 // using search to get all relevant objects
347 // #8498/#8499: restrict to objects with at least "read_learning_progress" access
348 $preselected_obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read_learning_progress");
349 } else {
350 // using summary filters
351 $filter = $this->getCurrentFilter();
352 }
353
354
355
357 $a_object_id,
358 $a_ref_id,
363 $filter,
364 $this->getSelectedColumns(),
365 $preselected_obj_ids
366 );
367
368 // build status to image map
369 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
370 include_once("./Services/Tracking/classes/class.ilLPStatus.php");
371 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
375 $status_map = array();
376 foreach ($valid_status as $status) {
379 $status_map[$status] = ilUtil::img($path, $text);
380 }
381
382 // language map
383 $lng->loadLanguageModule("meta");
384 $languages = array();
385 foreach ($lng->getInstalledLanguages() as $lang_key) {
386 $languages[$lang_key] = $lng->txt("meta_l_" . $lang_key);
387 }
388
389 $rows = array();
390 foreach ($data["set"] as $idx => $result) {
391 // sessions have no title
392 if ($result["title"] == "" && $result["type"] == "sess") {
393 include_once "Modules/Session/classes/class.ilObjSession.php";
394 $sess = new ilObjSession($result["obj_id"], false);
395 $data["set"][$idx]["title"] = $sess->getFirstAppointment()->appointmentToString();
396 }
397
398 $data["set"][$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($result["obj_id"], $result["type"]);
399
400 // #13807
401 if ($result["ref_ids"]) {
402 $valid = false;
403 foreach ($result["ref_ids"] as $check_ref_id) {
404 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
405 if (ilLearningProgressAccess::checkPermission('read_learning_progress', $check_ref_id)) {
406 $valid = true;
407 break;
408 }
409 }
410 if (!$valid) {
411 foreach (array_keys($data["set"][$idx]) as $col_id) {
412 if (!in_array($col_id, array("type", "title", "obj_id", "ref_id", "offline"))) {
413 $data["set"][$idx][$col_id] = null;
414 }
415 }
416 $data["set"][$idx]["privacy_conflict"] = true;
417 continue;
418 }
419 }
420
421 // percentages
422 $users_no = $result["user_total"];
423 $data["set"][$idx]["country"] = $this->getItemsPercentages($result["country"], $users_no);
424 $data["set"][$idx]["gender"] = $this->getItemsPercentages($result["gender"], $users_no, array(
425 "n"=>$lng->txt("gender_n"),
426 "m"=>$lng->txt("gender_m"),
427 "f"=>$lng->txt("gender_f"),
428 ));
429 $data["set"][$idx]["city"] = $this->getItemsPercentages($result["city"], $users_no);
430 $data["set"][$idx]["sel_country"] = $this->getItemsPercentages($result["sel_country"], $users_no, $this->getSelCountryCodes());
431 $data["set"][$idx]["mark"] = $this->getItemsPercentages($result["mark"], $users_no);
432 $data["set"][$idx]["language"] = $this->getItemsPercentages($result["language"], $users_no, $languages);
433
434 // if we encounter any invalid status codes, e.g. null, map them to not attempted instead
435 foreach ($result["status"] as $status_code => $status_counter) {
436 // null is cast to ""
437 if ($status_code === "" || !in_array($status_code, $valid_status)) {
438 $result["status"][ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM] += $status_counter;
439 unset($result["status"][$status_code]);
440 }
441 }
442 $data["set"][$idx]["status"] = $this->getItemsPercentagesStatus($result["status"], $users_no, $status_map);
443
444 if (!$this->isPercentageAvailable($result["obj_id"])) {
445 $data["set"][$idx]["percentage_avg"] = null;
446 }
447 }
448
449 $this->setMaxCount($data["cnt"]);
450 $this->setData($data["set"]);
451 }
452
462 protected function getItemsPercentages(array $data = null, $overall, array $value_map = null, $limit = 3)
463 {
464 global $lng;
465
466 if (!$overall) {
467 return false;
468 }
469
470 $result = array();
471
472 if ($data) {
473 // if we have only 1 item more than the limit, "others" makes no sense
474 if (sizeof($data) == $limit+1) {
475 $limit++;
476 }
477
478 $counter = $others_counter = $others_sum = 0;
479 foreach ($data as $id => $count) {
480 $counter++;
481 if ($counter <= $limit) {
482 $caption = $id;
483
484 if ($value_map && isset($value_map[$id])) {
485 $caption = $value_map[$id];
486 }
487
488 if ($caption == "") {
489 $caption = $lng->txt("none");
490 }
491
492 $perc = round($count/$overall*100);
493 $result[] = array(
494 "caption" => $caption,
495 "absolute" => $count, // ." ".($count > 1 ? $lng->txt("users") : $lng->txt("user")),
496 "percentage" => $perc
497 );
498 } else {
499 $others_sum += $count;
500 $others_counter++;
501 }
502 }
503
504 if ($others_counter) {
505 $perc = round($others_sum/$overall*100);
506 $result[] = array(
507 "caption" => $otherss_counter . " " . $lng->txt("trac_others"),
508 "absolute" => $others_sum, // ." ".($others_sum > 1 ? $lng->txt("users") : $lng->txt("user")),
509 "percentage" => $perc
510 );
511 }
512 }
513
514 return $result;
515 }
516
525 protected function getItemsPercentagesStatus(array $data = null, $overall, array $value_map = null)
526 {
527 global $lng;
528
529 $result = array();
530 foreach ($value_map as $id => $caption) {
531 $count = 0;
532 if (isset($data[$id])) {
533 $count = $data[$id];
534 }
535 $perc = round($count/$overall*100);
536
537 $result[] = array(
538 "caption" => $caption,
539 "absolute" => $count,
540 "percentage" => $perc
541 );
542 }
543
544 return $result;
545 }
546
547 protected function parseValue($id, $value, $type)
548 {
549 global $lng;
550
551 // get rid of aggregation
552 $pos = strrpos($id, "_");
553 if ($pos !== false) {
554 $function = strtoupper(substr($id, $pos+1));
555 if (in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT"))) {
556 $id = substr($id, 0, $pos);
557 }
558 }
559
560 if (trim($value) == "") {
561 if ($id == "title") {
562 return "--" . $lng->txt("none") . "--";
563 }
564 return "";
565 }
566 switch ($id) {
567 case 'status_changed':
568 case "first_access":
569 case "create_date":
571 break;
572
573 case "last_access":
575 break;
576
577 case "spent_seconds":
578 case "read_count_spent_seconds":
580 $value = "-";
581 } else {
582 $value = ilDatePresentation::secondsToString($value, ($value < 3600 ? true : false)); // #14858
583 }
584 break;
585
586 case "percentage":
587 if (false /* $this->isPercentageAvailable() */) {
588 $value = "-";
589 } else {
590 $value = $value . "%";
591 }
592 break;
593
594 case "mark":
596 $value = "-";
597 }
598 break;
599 }
600
601 return $value;
602 }
603
607 protected function fillRow($a_set)
608 {
609 global $lng, $ilCtrl;
610
611 $this->tpl->setVariable("ICON", ilObject::_getIcon("", "tiny", $a_set["type"]));
612 $this->tpl->setVariable("ICON_ALT", $lng->txt($a_set["type"]));
613 $this->tpl->setVariable("TITLE", $a_set["title"]);
614
615 if ($a_set["offline"] || $a_set["privacy_conflict"]) {
616 $mess = array();
617 if ($a_set["offline"]) {
618 $mess[] = $lng->txt("offline");
619 }
620 if ($a_set["privacy_conflict"]) {
621 $mess[] = $lng->txt("status_no_permission");
622 }
623 $this->tpl->setCurrentBlock("status_bl");
624 $this->tpl->setVariable("TEXT_STATUS", implode(", ", $mess));
625 $this->tpl->parseCurrentBlock();
626 }
627
628 foreach ($this->getSelectedColumns() as $c) {
629 switch ($c) {
630 case "country":
631 case "gender":
632 case "city":
633 case "language":
634 case "status":
635 case "mark":
636 case "sel_country":
637 $this->renderPercentages($c, $a_set[$c]);
638 break;
639
640 case "percentage_avg":
641 if ((int) $a_set[$c] === 0 || !$this->isPercentageAvailable($a_set["obj_id"])) {
642 $this->tpl->setVariable(strtoupper($c), "");
643 break;
644 }
645
646 // no break
647 default:
648 $value = $this->parseValue($c, $a_set[$c], $a_set["type"]);
649 $this->tpl->setVariable(strtoupper($c), $value);
650 break;
651 }
652 }
653
654 if ($this->is_root) {
655 $path = $this->buildPath($a_set["ref_ids"], false, true);
656 if ($path) {
657 $this->tpl->setCurrentBlock("item_path");
658 foreach ($path as $ref_id => $path_item) {
659 $this->tpl->setVariable("PATH_ITEM", $path_item);
660
661 if (!$this->anonymized) {
662 $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
663 $this->tpl->setVariable("URL_DETAILS", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
664 $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
665 $this->tpl->setVariable("TXT_DETAILS", $lng->txt('trac_participants'));
666 } else {
667 $this->tpl->setVariable("URL_DETAILS", ilLink::_getLink($ref_id, $a_set["type"]));
668 $this->tpl->setVariable("TXT_DETAILS", $lng->txt('view'));
669 }
670
671 $this->tpl->parseCurrentBlock();
672 }
673 }
674
675 $this->tpl->setCurrentBlock("item_command");
676 $ilCtrl->setParameterByClass(get_class($this), 'hide', $a_set["obj_id"]);
677 $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this), 'hide'));
678 $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
679 $this->tpl->parseCurrentBlock();
680
681 $this->tpl->touchBlock("path_action");
682 } elseif ($a_set["ref_ids"]) { // #18446
683 // #16453
684 include_once './Services/Tree/classes/class.ilPathGUI.php';
685 $path = new ilPathGUI();
686 $path = $path->getPath($this->ref_id, array_pop($a_set["ref_ids"]));
687 if ($path) {
688 $this->tpl->setVariable('COLL_PATH', $this->lng->txt('path') . ': ' . $path);
689 }
690 }
691 }
692
693 protected function renderPercentages($id, $data)
694 {
695 if ($data) {
696 foreach ($data as $item) {
697 $this->tpl->setCurrentBlock($id . "_row");
698 $this->tpl->setVariable("CAPTION", $item["caption"]);
699 $this->tpl->setVariable("ABSOLUTE", $item["absolute"]);
700 $this->tpl->setVariable("PERCENTAGE", $item["percentage"]);
701 $this->tpl->parseCurrentBlock();
702 }
703 } else {
704 $this->tpl->touchBlock($id);
705 ;
706 }
707 }
708
709 protected function isArrayColumn($a_name)
710 {
711 if (in_array($a_name, array("country", "gender", "city", "language", "status", "mark", 'sel_country'))) {
712 return true;
713 }
714 return false;
715 }
716
717 public function numericOrdering($a_field)
718 {
719 $pos = strrpos($a_field, "_");
720 if ($pos !== false) {
721 $function = strtoupper(substr($a_field, $pos+1));
722 if (in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT", "TOTAL"))) {
723 return true;
724 }
725 }
726 return false;
727 }
728
729 protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
730 {
731 $a_excel->setCell($a_row, 0, $this->lng->txt("title"));
732
733 $labels = $this->getSelectableColumns();
734 $cnt = 1;
735 foreach ($this->getSelectedColumns() as $c) {
736 $label = $labels[$c]["txt"];
737 $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
738 $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
739
740 if (!$this->isArrayColumn($c)) {
741 $a_excel->setCell($a_row, $cnt, $label);
742 $cnt++;
743 } else {
744 if ($c != "status") {
745 $a_excel->setCell($a_row, $cnt, $label . " #1");
746 $a_excel->setCell($a_row, ++$cnt, $label . " #1");
747 $a_excel->setCell($a_row, ++$cnt, $label . " #1 %");
748 $a_excel->setCell($a_row, ++$cnt, $label . " #2");
749 $a_excel->setCell($a_row, ++$cnt, $label . " #2");
750 $a_excel->setCell($a_row, ++$cnt, $label . " #2 %");
751 $a_excel->setCell($a_row, ++$cnt, $label . " #3");
752 $a_excel->setCell($a_row, ++$cnt, $label . " #3");
753 $a_excel->setCell($a_row, ++$cnt, $label . " #3 %");
754 $a_excel->setCell($a_row, ++$cnt, $label . " " . $this->lng->txt("trac_others"));
755 $a_excel->setCell($a_row, ++$cnt, $label . " " . $this->lng->txt("trac_others"));
756 $a_excel->setCell($a_row, ++$cnt, $label . " " . $this->lng->txt("trac_others") . " %");
757 } else {
758 // build status to image map
759 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
760 include_once("./Services/Tracking/classes/class.ilLPStatus.php");
761 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
765 $cnt--;
766 foreach ($valid_status as $status) {
768 $a_excel->setCell($a_row, ++$cnt, $text);
769 $a_excel->setCell($a_row, ++$cnt, $text . " %");
770 }
771 }
772 $cnt++;
773 }
774 }
775
776 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($cnt) . $a_row);
777 }
778
779 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
780 {
781 $a_excel->setCell($a_row, 0, $a_set["title"]);
782
783 $cnt = 1;
784 foreach ($this->getSelectedColumns() as $c) {
785 if (!$this->isArrayColumn($c)) {
786 $val = $this->parseValue($c, $a_set[$c], $a_set["type"]);
787 $a_excel->setCell($a_row, $cnt, $val);
788 $cnt++;
789 } else {
790 foreach ((array) $a_set[$c] as $idx => $value) {
791 if ($c == "status") {
792 $a_excel->setCell($a_row, $cnt, (int) $value["absolute"]);
793 $a_excel->setCell($a_row, ++$cnt, $value["percentage"] . "%");
794 } else {
795 $a_excel->setCell($a_row, $cnt, $value["caption"]);
796 $a_excel->setCell($a_row, ++$cnt, (int) $value["absolute"]);
797 $a_excel->setCell($a_row, ++$cnt, $value["percentage"] . "%");
798 }
799 $cnt++;
800 }
801 if (sizeof($a_set[$c]) < 4 && $c != "status") {
802 for ($loop = 4; $loop > sizeof($a_set[$c]); $loop--) {
803 $a_excel->setCell($a_row, $cnt, "");
804 $a_excel->setCell($a_row, ++$cnt, "");
805 $a_excel->setCell($a_row, ++$cnt, "");
806 $cnt++;
807 }
808 }
809 }
810 }
811 }
812
813 protected function fillHeaderCSV($a_csv)
814 {
815 $a_csv->addColumn($this->lng->txt("title"));
816
817 $labels = $this->getSelectableColumns();
818 foreach ($this->getSelectedColumns() as $c) {
819 $label = $labels[$c]["txt"];
820 $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
821 $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
822
823 if (!$this->isArrayColumn($c)) {
824 $a_csv->addColumn($label);
825 } else {
826 if ($c != "status") {
827 $a_csv->addColumn($label . " #1");
828 $a_csv->addColumn($label . " #1");
829 $a_csv->addColumn($label . " #1 %");
830 $a_csv->addColumn($label . " #2");
831 $a_csv->addColumn($label . " #2");
832 $a_csv->addColumn($label . " #2 %");
833 $a_csv->addColumn($label . " #3");
834 $a_csv->addColumn($label . " #3");
835 $a_csv->addColumn($label . " #3 %");
836 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others"));
837 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others"));
838 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others") . " %");
839 } else {
840 // build status to image map
841 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
842 include_once("./Services/Tracking/classes/class.ilLPStatus.php");
843 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
847 foreach ($valid_status as $status) {
849 $a_csv->addColumn($text);
850 $a_csv->addColumn($text . " %");
851 }
852 }
853 }
854 }
855
856 $a_csv->addRow();
857 }
858
859 protected function fillRowCSV($a_csv, $a_set)
860 {
861 $a_csv->addColumn($a_set["title"]);
862
863 foreach ($this->getSelectedColumns() as $c) {
864 if (!$this->isArrayColumn($c)) {
865 $val = $this->parseValue($c, $a_set[$c], $a_set["type"]);
866 $a_csv->addColumn($val);
867 } else {
868 foreach ((array) $a_set[$c] as $idx => $value) {
869 if ($c != "status") {
870 $a_csv->addColumn($value["caption"]);
871 }
872 $a_csv->addColumn((int) $value["absolute"]);
873 $a_csv->addColumn($value["percentage"]);
874 }
875 if (sizeof($a_set[$c]) < 4 && $c != "status") {
876 for ($loop = 4; $loop > sizeof($a_set[$c]); $loop--) {
877 $a_csv->addColumn("");
878 $a_csv->addColumn("");
879 $a_csv->addColumn("");
880 }
881 }
882 }
883 }
884
885 $a_csv->addRow();
886 }
887}
$column
Definition: 39dropdown.php:62
$result
if(! $in) $columns
Definition: Utf8Test.php:45
global $l
Definition: afr.php:30
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$function
Definition: cas.php:28
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)
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 _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
const FILTER_NUMBER_RANGE
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="", $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
$counter
$valid
$txt
Definition: error.php:11
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$type
$text
Definition: errorreport.php:18
$rows
Definition: xhr_table.php:10