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