ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_print_mode = false)
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng;
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  include_once './Services/Object/classes/class.ilObjectLP.php';
33  $this->olp = ilObjectLP::getInstance($this->obj_id);
34  }
35 
36  parent::__construct($a_parent_obj, $a_parent_cmd);
37 
38  if($a_print_mode)
39  {
40  $this->setPrintMode(true);
41  }
42 
43  $this->parseTitle($this->obj_id, "trac_summary");
44  $this->setLimit(9999);
45  $this->setShowTemplates(true);
46  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
47 
48  $this->addColumn($this->lng->txt("title"), "title");
49  $this->setDefaultOrderField("title");
50 
51  $labels = $this->getSelectableColumns();
52  foreach ($this->getSelectedColumns() as $c)
53  {
54  $this->addColumn($labels[$c]["txt"], $c);
55  }
56 
57  if($this->is_root)
58  {
59  $this->addColumn($this->lng->txt("path"));
60  $this->addColumn($this->lng->txt("action"));
61  }
62  $this->initFilter();
63 
64  // $this->setExternalSorting(true);
65  $this->setEnableHeader(true);
66  $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
67  $this->setRowTemplate("tpl.trac_summary_row.html", "Services/Tracking");
68 
69  $this->getItems($a_parent_obj->getObjId(), $a_ref_id);
70  }
71 
73  {
74  global $lng, $ilSetting;
75 
76  $lng_map = array("user_total" => "users", "first_access_min" => "trac_first_access",
77  "last_access_max" => "trac_last_access", "mark" => "trac_mark", "status" => "trac_status",
78  'status_changed_max' => 'trac_status_changed',
79  "spent_seconds_avg" => "trac_spent_seconds", "percentage_avg" => "trac_percentage",
80  "read_count_sum" => "trac_read_count", "read_count_avg" => "trac_read_count",
81  "read_count_spent_seconds_avg" => "trac_read_count_spent_seconds"
82  );
83 
84 
85  $all = array("user_total");
86  $default = array();
87 
88  // show only if extended data was activated in lp settings
89  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
90  $tracking = new ilObjUserTracking();
91  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT))
92  {
93  $all[] = "read_count_sum";
94  $all[] = "read_count_avg";
95  $default[] = "read_count_sum";
96  }
97  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS))
98  {
99  $all[] = "spent_seconds_avg";
100  $default[] = "spent_seconds_avg";
101  }
102  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT) &&
103  $tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS))
104  {
105  $all[] = "read_count_spent_seconds_avg";
106  // $default[] = "read_count_spent_seconds_avg";
107  }
108 
109  $all[] = "percentage_avg";
110 
111  // do not show status if learning progress is deactivated
112  if($this->is_root || $this->olp->isActive())
113  {
114  $all[] = "status";
115  $all[] = 'status_changed_max';
116  }
117 
118  if($this->is_root || ilObject::_lookupType($this->obj_id) != "lm")
119  {
120  $all[] = "mark";
121  }
122 
123  $privacy = array("gender", "city", "country", "sel_country");
124  foreach($privacy as $field)
125  {
126  if($ilSetting->get("usr_settings_course_export_".$field))
127  {
128  $all[] = $field;
129  }
130  }
131 
132  $all[] = "language";
133 
134  $default[] = "percentage_avg";
135  $default[] = "status";
136  $default[] = "mark";
137 
138  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
139  {
140  $all[] = "first_access_min";
141  $all[] = "last_access_max";
142  }
143 
144  $all[] = "create_date_min";
145  $all[] = "create_date_max";
146 
147 
148  $columns = array();
149  foreach($all as $column)
150  {
151  $l = $column;
152 
153  $prefix = false;
154  if(substr($l, -3) == "avg")
155  {
156  $prefix = "&#216; ";
157  }
158  else if(substr($l, -3) == "sum" || $l == "user_total")
159  {
160  $prefix = "&#8721; ";
161  }
162 
163  if(isset($lng_map[$l]))
164  {
165  $l = $lng_map[$l];
166  }
167 
168  $txt = $prefix.$lng->txt($l);
169 
170  if(in_array($column, array("read_count_avg", "spent_seconds_avg", "percentage_avg")))
171  {
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  function initFilter()
187  {
188  global $lng, $ilSetting;
189 
190  if($this->is_root)
191  {
192  return parent::initFilter(true, false);
193  }
194 
195  // show only if extended data was activated in lp settings
196  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
197  $tracking = new ilObjUserTracking();
198 
199  $item = $this->addFilterItemByMetaType("user_total", ilTable2GUI::FILTER_NUMBER_RANGE, true,
200  "&#8721; ".$lng->txt("users"));
201  $this->filter["user_total"] = $item->getValue();
202 
203  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT))
204  {
205  $item = $this->addFilterItemByMetaType("read_count", ilTable2GUI::FILTER_NUMBER_RANGE, true,
206  "&#8721; ".$lng->txt("trac_read_count"));
207  $this->filter["read_count"] = $item->getValue();
208  }
209 
210  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS))
211  {
212  $item = $this->addFilterItemByMetaType("spent_seconds", ilTable2GUI::FILTER_DURATION_RANGE,
213  true, "&#216; ".$lng->txt("trac_spent_seconds")." / ".$lng->txt("user"));
214  $this->filter["spent_seconds"]["from"] = $item->getCombinationItem("from")->getValueInSeconds();
215  $this->filter["spent_seconds"]["to"] = $item->getCombinationItem("to")->getValueInSeconds();
216  }
217 
218  $item = $this->addFilterItemByMetaType("percentage", ilTable2GUI::FILTER_NUMBER_RANGE, true,
219  "&#216; ".$lng->txt("trac_percentage")." / ".$lng->txt("user"));
220  $this->filter["percentage"] = $item->getValue();
221 
222  // do not show status if learning progress is deactivated
223  if($this->olp->isActive())
224  {
225  include_once "Services/Tracking/classes/class.ilLPStatus.php";
226  $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT, true);
227  $item->setOptions(array("" => $lng->txt("trac_all"),
232  $this->filter["status"] = $item->getValue();
233  if($this->filter["status"])
234  {
235  $this->filter["status"]--;
236  }
237 
238  $item = $this->addFilterItemByMetaType("trac_status_changed", ilTable2GUI::FILTER_DATE_RANGE, true);
239  $this->filter["status_changed"] = $item->getDate();
240  }
241 
242  if(ilObject::_lookupType($this->obj_id) != "lm")
243  {
244  $item = $this->addFilterItemByMetaType("mark", ilTable2GUI::FILTER_TEXT, true,
245  $lng->txt("trac_mark"));
246  $this->filter["mark"] = $item->getValue();
247  }
248 
249  if($ilSetting->get("usr_settings_course_export_gender"))
250  {
251  $item = $this->addFilterItemByMetaType("gender", ilTable2GUI::FILTER_SELECT, true);
252  $item->setOptions(array("" => $lng->txt("trac_all"), "m" => $lng->txt("gender_m"),
253  "f" => $lng->txt("gender_f")));
254  $this->filter["gender"] = $item->getValue();
255  }
256 
257  if($ilSetting->get("usr_settings_course_export_city"))
258  {
259  $item = $this->addFilterItemByMetaType("city", ilTable2GUI::FILTER_TEXT, true);
260  $this->filter["city"] = $item->getValue();
261  }
262 
263  if($ilSetting->get("usr_settings_course_export_country"))
264  {
265  $item = $this->addFilterItemByMetaType("country", ilTable2GUI::FILTER_TEXT, true);
266  $this->filter["country"] = $item->getValue();
267  }
268 
269  if($ilSetting->get("usr_settings_course_export_sel_country"))
270  {
271  $item = $this->addFilterItemByMetaType("sel_country", ilTable2GUI::FILTER_SELECT, true);
272  $item->setOptions(array("" => $lng->txt("trac_all"))+$this->getSelCountryCodes());
273  $this->filter["sel_country"] = $item->getValue();
274  }
275 
276  $item = $this->addFilterItemByMetaType("language", ilTable2GUI::FILTER_LANGUAGE, true);
277  $this->filter["language"] = $item->getValue();
278 
279  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
280  {
281  $item = $this->addFilterItemByMetaType("trac_first_access", ilTable2GUI::FILTER_DATETIME_RANGE, true);
282  $this->filter["first_access"] = $item->getDate();
283 
284  $item = $this->addFilterItemByMetaType("trac_last_access", ilTable2GUI::FILTER_DATETIME_RANGE, true);
285  $this->filter["last_access"] = $item->getDate();
286  }
287 
288  $item = $this->addFilterItemByMetaType("registration_filter", ilTable2GUI::FILTER_DATE_RANGE, true);
289  $this->filter["registration"] = $item->getDate();
290  }
291 
293  {
294  global $lng;
295 
296  include_once("./Services/Utilities/classes/class.ilCountry.php");
297  $options = array();
298  foreach (ilCountry::getCountryCodes() as $c)
299  {
300  $options[$c] = $lng->txt("meta_c_".$c);
301  }
302  asort($options);
303  return $options;
304  }
305 
312  function getItems($a_object_id, $a_ref_id)
313  {
314  global $lng, $rbacsystem;
315 
316  include_once("./Services/Tracking/classes/class.ilTrQuery.php");
317 
318  $preselected_obj_ids = $filter = NULL;
319  if($this->is_root)
320  {
321  // using search to get all relevant objects
322  // #8498/#8499: restrict to objects with at least "read_learning_progress" access
323  $preselected_obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read_learning_progress");
324  }
325  else
326  {
327  // using summary filters
328  $filter = $this->getCurrentFilter();
329  }
330 
332  $a_object_id,
333  $a_ref_id,
337  ilUtil::stripSlashes($this->getLimit()),
338  $filter,
339  $this->getSelectedColumns(),
340  $preselected_obj_ids
341  );
342 
343  // build status to image map
344  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
345  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
346  $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
350  $status_map = array();
351  foreach($valid_status as $status)
352  {
355  $status_map[$status] = ilUtil::img($path, $text);
356  }
357 
358  // language map
359  $lng->loadLanguageModule("meta");
360  $languages = array();
361  foreach ($lng->getInstalledLanguages() as $lang_key)
362  {
363  $languages[$lang_key] = $lng->txt("meta_l_".$lang_key);
364  }
365 
366  $rows = array();
367  foreach($data["set"] as $idx => $result)
368  {
369  // sessions have no title
370  if($result["title"] == "" && $result["type"] == "sess")
371  {
372  include_once "Modules/Session/classes/class.ilObjSession.php";
373  $sess = new ilObjSession($result["obj_id"], false);
374  $data["set"][$idx]["title"] = $sess->getFirstAppointment()->appointmentToString();
375  }
376 
377  $data["set"][$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($result["obj_id"], $result["type"]);
378 
379  // #13807
380  if($result["ref_ids"])
381  {
382  $valid = false;
383  foreach($result["ref_ids"] as $check_ref_id)
384  {
385  if($rbacsystem->checkAccess("read_learning_progress", $check_ref_id))
386  {
387  $valid = true;
388  break;
389  }
390  }
391  if(!$valid)
392  {
393  foreach(array_keys($data["set"][$idx]) as $col_id)
394  {
395  if(!in_array($col_id, array("type", "title", "obj_id", "ref_id", "offline")))
396  {
397  $data["set"][$idx][$col_id] = null;
398  }
399  }
400  $data["set"][$idx]["privacy_conflict"] = true;
401  continue;
402  }
403  }
404 
405  // percentages
406  $users_no = $result["user_total"];
407  $data["set"][$idx]["country"] = $this->getItemsPercentages($result["country"], $users_no);
408  $data["set"][$idx]["gender"] = $this->getItemsPercentages($result["gender"], $users_no, array("m"=>$lng->txt("gender_m"), "f"=>$lng->txt("gender_f")));
409  $data["set"][$idx]["city"] = $this->getItemsPercentages($result["city"], $users_no);
410  $data["set"][$idx]["sel_country"] = $this->getItemsPercentages($result["sel_country"], $users_no, $this->getSelCountryCodes());
411  $data["set"][$idx]["mark"] = $this->getItemsPercentages($result["mark"], $users_no);
412  $data["set"][$idx]["language"] = $this->getItemsPercentages($result["language"], $users_no, $languages);
413 
414  // if we encounter any invalid status codes, e.g. null, map them to not attempted instead
415  foreach($result["status"] as $status_code => $status_counter)
416  {
417  // null is cast to ""
418  if($status_code === "" || !in_array($status_code, $valid_status))
419  {
420  $result["status"][ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM] += $status_counter;
421  unset($result["status"][$status_code]);
422  }
423  }
424  $data["set"][$idx]["status"] = $this->getItemsPercentagesStatus($result["status"], $users_no, $status_map);
425 
426  if(!$this->isPercentageAvailable($result["obj_id"]))
427  {
428  $data["set"][$idx]["percentage_avg"] = NULL;
429  }
430  }
431 
432  $this->setMaxCount($data["cnt"]);
433  $this->setData($data["set"]);
434  }
435 
445  protected function getItemsPercentages(array $data = NULL, $overall, array $value_map = NULL, $limit = 3)
446  {
447  global $lng;
448 
449  if(!$overall)
450  {
451  return false;
452  }
453 
454  $result = array();
455 
456  if($data)
457  {
458  // if we have only 1 item more than the limit, "others" makes no sense
459  if(sizeof($data) == $limit+1)
460  {
461  $limit++;
462  }
463 
464  $counter = $others_counter = $others_sum = 0;
465  foreach($data as $id => $count)
466  {
467  $counter++;
468  if($counter <= $limit)
469  {
470  $caption = $id;
471 
472  if($value_map && isset($value_map[$id]))
473  {
474  $caption = $value_map[$id];
475  }
476 
477  if($caption == "")
478  {
479  $caption = $lng->txt("none");
480  }
481 
482  $perc = round($count/$overall*100);
483  $result[] = array(
484  "caption" => $caption,
485  "absolute" => $count, // ." ".($count > 1 ? $lng->txt("users") : $lng->txt("user")),
486  "percentage" => $perc
487  );
488  }
489  else
490  {
491  $others_sum += $count;
492  $others_counter++;
493  }
494  }
495 
496  if($others_counter)
497  {
498  $perc = round($others_sum/$overall*100);
499  $result[] = array(
500  "caption" => $otherss_counter." ".$lng->txt("trac_others"),
501  "absolute" => $others_sum, // ." ".($others_sum > 1 ? $lng->txt("users") : $lng->txt("user")),
502  "percentage" => $perc
503  );
504  }
505  }
506 
507  return $result;
508  }
509 
518  protected function getItemsPercentagesStatus(array $data = NULL, $overall, array $value_map = NULL)
519  {
520  global $lng;
521 
522  $result = array();
523  foreach($value_map as $id => $caption)
524  {
525  $count = 0;
526  if(isset($data[$id]))
527  {
528  $count = $data[$id];
529  }
530  $perc = round($count/$overall*100);
531 
532  $result[] = array(
533  "caption" => $caption,
534  "absolute" => $count,
535  "percentage" => $perc
536  );
537  }
538 
539  return $result;
540  }
541 
542  protected function parseValue($id, $value, $type)
543  {
544  global $lng;
545 
546  // get rid of aggregation
547  $pos = strrpos($id, "_");
548  if($pos !== false)
549  {
550  $function = strtoupper(substr($id, $pos+1));
551  if(in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT")))
552  {
553  $id = substr($id, 0, $pos);
554  }
555  }
556 
557  if(trim($value) == "")
558  {
559  if($id == "title")
560  {
561  return "--".$lng->txt("none")."--";
562  }
563  return "";
564  }
565  switch($id)
566  {
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":
579  if(in_array($type, array("exc")))
580  {
581  $value = "-";
582  }
583  else
584  {
585  include_once("./Services/Utilities/classes/class.ilFormat.php");
586  $value = ilFormat::_secondsToString($value, ($value < 3600 ? true : false)); // #14858
587  }
588  break;
589 
590  case "percentage":
591  /* :TODO:
592  if(in_array(strtolower($this->status_class),
593  array("illpstatusmanual", "illpstatusscormpackage", "illpstatustestfinished")) ||
594  $type == "exc"))
595  */
596  if(false)
597  {
598  $value = "-";
599  }
600  else
601  {
602  $value = $value."%";
603  }
604  break;
605 
606  case "mark":
607  if(in_array($type, array("lm", "dbk")))
608  {
609  $value = "-";
610  }
611  break;
612  }
613 
614  return $value;
615  }
616 
620  protected function fillRow($a_set)
621  {
622  global $lng, $ilCtrl;
623 
624  $this->tpl->setVariable("ICON", ilObject::_getIcon("", "tiny", $a_set["type"]));
625  $this->tpl->setVariable("ICON_ALT", $lng->txt($a_set["type"]));
626  $this->tpl->setVariable("TITLE", $a_set["title"]);
627 
628  if($a_set["offline"] || $a_set["privacy_conflict"])
629  {
630  $mess = array();
631  if($a_set["offline"])
632  {
633  $mess[] = $lng->txt("offline");
634  }
635  if($a_set["privacy_conflict"])
636  {
637  $mess[] = $lng->txt("status_no_permission");
638  }
639  $this->tpl->setCurrentBlock("status_bl");
640  $this->tpl->setVariable("TEXT_STATUS", implode(", ", $mess));
641  $this->tpl->parseCurrentBlock();
642  }
643 
644  foreach ($this->getSelectedColumns() as $c)
645  {
646  switch($c)
647  {
648  case "country":
649  case "gender":
650  case "city":
651  case "language":
652  case "status":
653  case "mark":
654  case "sel_country":
655  $this->renderPercentages($c, $a_set[$c]);
656  break;
657 
658  case "percentage_avg":
659  if((int)$a_set[$c] === 0 || !$this->isPercentageAvailable($a_set["obj_id"]))
660  {
661  $this->tpl->setVariable(strtoupper($c), "");
662  break;
663  }
664 
665  default:
666  $value = $this->parseValue($c, $a_set[$c], $a_set["type"]);
667  $this->tpl->setVariable(strtoupper($c), $value);
668  break;
669  }
670  }
671 
672  if($this->is_root)
673  {
674  $path = $this->buildPath($a_set["ref_ids"], false, true);
675  if($path)
676  {
677  $this->tpl->setCurrentBlock("item_path");
678  foreach($path as $ref_id => $path_item)
679  {
680  $this->tpl->setVariable("PATH_ITEM", $path_item);
681 
682  if(!$this->anonymized)
683  {
684  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
685  $this->tpl->setVariable("URL_DETAILS", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
686  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
687  $this->tpl->setVariable("TXT_DETAILS", $lng->txt('trac_participants'));
688  }
689  else
690  {
691  $this->tpl->setVariable("URL_DETAILS", ilLink::_getLink($ref_id, $a_set["type"]));
692  $this->tpl->setVariable("TXT_DETAILS", $lng->txt('view'));
693  }
694 
695  $this->tpl->parseCurrentBlock();
696  }
697  }
698 
699  $this->tpl->setCurrentBlock("item_command");
700  $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
701  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
702  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
703  $this->tpl->parseCurrentBlock();
704 
705  $this->tpl->touchBlock("path_action");
706  }
707  }
708 
709  protected function renderPercentages($id, $data)
710  {
711  if($data)
712  {
713  foreach($data as $item)
714  {
715  $this->tpl->setCurrentBlock($id."_row");
716  $this->tpl->setVariable("CAPTION", $item["caption"]);
717  $this->tpl->setVariable("ABSOLUTE", $item["absolute"]);
718  $this->tpl->setVariable("PERCENTAGE", $item["percentage"]);
719  $this->tpl->parseCurrentBlock();
720  }
721  }
722  else
723  {
724  $this->tpl->touchBlock($id);;
725  }
726  }
727 
728  protected function isArrayColumn($a_name)
729  {
730  if(in_array($a_name, array("country", "gender", "city", "language", "status", "mark")))
731  {
732  return true;
733  }
734  return false;
735  }
736 
737  public function numericOrdering($a_field)
738  {
739  $pos = strrpos($a_field, "_");
740  if($pos !== false)
741  {
742  $function = strtoupper(substr($a_field, $pos+1));
743  if(in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT", "TOTAL")))
744  {
745  return true;
746  }
747  }
748  return false;
749  }
750 
751  protected function fillHeaderExcel($worksheet, &$a_row)
752  {
753  $worksheet->write($a_row, 0, $this->lng->txt("title"));
754 
755  $labels = $this->getSelectableColumns();
756  $cnt = 1;
757  foreach ($this->getSelectedColumns() as $c)
758  {
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  {
765  $worksheet->write($a_row, $cnt, $label);
766  $cnt++;
767  }
768  else
769  {
770  if($c != "status")
771  {
772  $worksheet->write($a_row, $cnt, $label." #1");
773  $worksheet->write($a_row, ++$cnt, $label." #1");
774  $worksheet->write($a_row, ++$cnt, $label." #1 %");
775  $worksheet->write($a_row, ++$cnt, $label." #2");
776  $worksheet->write($a_row, ++$cnt, $label." #2");
777  $worksheet->write($a_row, ++$cnt, $label." #2 %");
778  $worksheet->write($a_row, ++$cnt, $label." #3");
779  $worksheet->write($a_row, ++$cnt, $label." #3");
780  $worksheet->write($a_row, ++$cnt, $label." #3 %");
781  $worksheet->write($a_row, ++$cnt, $label." ".$this->lng->txt("trac_others"));
782  $worksheet->write($a_row, ++$cnt, $label." ".$this->lng->txt("trac_others"));
783  $worksheet->write($a_row, ++$cnt, $label." ".$this->lng->txt("trac_others")." %");
784  }
785  else
786  {
787  // build status to image map
788  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
789  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
790  $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
794  $cnt--;
795  foreach($valid_status as $status)
796  {
798  $worksheet->write($a_row, ++$cnt, $text);
799  $worksheet->write($a_row, ++$cnt, $text." %");
800  }
801  }
802  $cnt++;
803  }
804  }
805  }
806 
807  protected function fillRowExcel($worksheet, &$a_row, $a_set)
808  {
809  $worksheet->write($a_row, 0, $a_set["title"]);
810 
811  $cnt = 1;
812  foreach ($this->getSelectedColumns() as $c)
813  {
814  if(!$this->isArrayColumn($c))
815  {
816  $val = $this->parseValue($c, $a_set[$c], "user");
817  $worksheet->write($a_row, $cnt, $val);
818  $cnt++;
819  }
820  else
821  {
822  foreach($a_set[$c] as $idx => $value)
823  {
824  if($c == "status")
825  {
826  $worksheet->write($a_row, $cnt, (int)$value["absolute"]);
827  $worksheet->write($a_row, ++$cnt, $value["percentage"]);
828  }
829  else
830  {
831  $worksheet->write($a_row, $cnt, $value["caption"]);
832  $worksheet->write($a_row, ++$cnt, (int)$value["absolute"]);
833  $worksheet->write($a_row, ++$cnt, $value["percentage"]);
834  }
835  $cnt++;
836  }
837  if(sizeof($a_set[$c]) < 4 && $c != "status")
838  {
839  for($loop = 4; $loop > sizeof($a_set[$c]); $loop--)
840  {
841  $worksheet->write($a_row, $cnt, "");
842  $worksheet->write($a_row, ++$cnt, "");
843  $worksheet->write($a_row, ++$cnt, "");
844  $cnt++;
845  }
846  }
847  }
848  }
849  }
850 
851  protected function fillHeaderCSV($a_csv)
852  {
853  $a_csv->addColumn($this->lng->txt("title"));
854 
855  $labels = $this->getSelectableColumns();
856  foreach ($this->getSelectedColumns() as $c)
857  {
858  $label = $labels[$c]["txt"];
859  $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
860  $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
861 
862  if(!$this->isArrayColumn($c))
863  {
864  $a_csv->addColumn($label);
865  }
866  else
867  {
868  if($c != "status")
869  {
870  $a_csv->addColumn($label." #1");
871  $a_csv->addColumn($label." #1");
872  $a_csv->addColumn($label." #1 %");
873  $a_csv->addColumn($label." #2");
874  $a_csv->addColumn($label." #2");
875  $a_csv->addColumn($label." #2 %");
876  $a_csv->addColumn($label." #3");
877  $a_csv->addColumn($label." #3");
878  $a_csv->addColumn($label." #3 %");
879  $a_csv->addColumn($label." ".$this->lng->txt("trac_others"));
880  $a_csv->addColumn($label." ".$this->lng->txt("trac_others"));
881  $a_csv->addColumn($label." ".$this->lng->txt("trac_others")." %");
882  }
883  else
884  {
885  // build status to image map
886  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
887  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
888  $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
892  foreach($valid_status as $status)
893  {
895  $a_csv->addColumn($text);
896  $a_csv->addColumn($text." %");
897  }
898  }
899  }
900  }
901 
902  $a_csv->addRow();
903  }
904 
905  protected function fillRowCSV($a_csv, $a_set)
906  {
907  $a_csv->addColumn($a_set["title"]);
908 
909  foreach ($this->getSelectedColumns() as $c)
910  {
911  if(!$this->isArrayColumn($c))
912  {
913  $val = $this->parseValue($c, $a_set[$c], "user");
914  $a_csv->addColumn($val);
915  }
916  else
917  {
918  foreach($a_set[$c] as $idx => $value)
919  {
920  if($c != "status")
921  {
922  $a_csv->addColumn($value["caption"]);
923  }
924  $a_csv->addColumn((int)$value["absolute"]);
925  $a_csv->addColumn($value["percentage"]);
926  }
927  if(sizeof($a_set[$c]) < 4 && $c != "status")
928  {
929  for($loop = 4; $loop > sizeof($a_set[$c]); $loop--)
930  {
931  $a_csv->addColumn("");
932  $a_csv->addColumn("");
933  $a_csv->addColumn("");
934  }
935  }
936  }
937  }
938 
939  $a_csv->addRow();
940  }
941 }
942 ?>