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