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