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