ILIAS  Release_4_4_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;
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 "edit_learning_progress" access
323  $preselected_obj_ids = $this->searchObjects($this->getCurrentFilter(true), "edit_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  // percentages
380  $users_no = $result["user_total"];
381  $data["set"][$idx]["country"] = $this->getItemsPercentages($result["country"], $users_no);
382  $data["set"][$idx]["gender"] = $this->getItemsPercentages($result["gender"], $users_no, array("m"=>$lng->txt("gender_m"), "f"=>$lng->txt("gender_f")));
383  $data["set"][$idx]["city"] = $this->getItemsPercentages($result["city"], $users_no);
384  $data["set"][$idx]["sel_country"] = $this->getItemsPercentages($result["sel_country"], $users_no, $this->getSelCountryCodes());
385  $data["set"][$idx]["mark"] = $this->getItemsPercentages($result["mark"], $users_no);
386  $data["set"][$idx]["language"] = $this->getItemsPercentages($result["language"], $users_no, $languages);
387 
388  // if we encounter any invalid status codes, e.g. null, map them to not attempted instead
389  foreach($result["status"] as $status_code => $status_counter)
390  {
391  // null is cast to ""
392  if($status_code === "" || !in_array($status_code, $valid_status))
393  {
394  $result["status"][ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM] += $status_counter;
395  unset($result["status"][$status_code]);
396  }
397  }
398  $data["set"][$idx]["status"] = $this->getItemsPercentagesStatus($result["status"], $users_no, $status_map);
399 
400  if(!$this->isPercentageAvailable($result["obj_id"]))
401  {
402  $data["set"][$idx]["percentage_avg"] = NULL;
403  }
404  }
405 
406  $this->setMaxCount($data["cnt"]);
407  $this->setData($data["set"]);
408  }
409 
419  protected function getItemsPercentages(array $data = NULL, $overall, array $value_map = NULL, $limit = 3)
420  {
421  global $lng;
422 
423  if(!$overall)
424  {
425  return false;
426  }
427 
428  $result = array();
429 
430  if($data)
431  {
432  // if we have only 1 item more than the limit, "others" makes no sense
433  if(sizeof($data) == $limit+1)
434  {
435  $limit++;
436  }
437 
438  $counter = $others_counter = $others_sum = 0;
439  foreach($data as $id => $count)
440  {
441  $counter++;
442  if($counter <= $limit)
443  {
444  $caption = $id;
445 
446  if($value_map && isset($value_map[$id]))
447  {
448  $caption = $value_map[$id];
449  }
450 
451  if($caption == "")
452  {
453  $caption = $lng->txt("none");
454  }
455 
456  $perc = round($count/$overall*100);
457  $result[] = array(
458  "caption" => $caption,
459  "absolute" => $count, // ." ".($count > 1 ? $lng->txt("users") : $lng->txt("user")),
460  "percentage" => $perc
461  );
462  }
463  else
464  {
465  $others_sum += $count;
466  $others_counter++;
467  }
468  }
469 
470  if($others_counter)
471  {
472  $perc = round($others_sum/$overall*100);
473  $result[] = array(
474  "caption" => $otherss_counter." ".$lng->txt("trac_others"),
475  "absolute" => $others_sum, // ." ".($others_sum > 1 ? $lng->txt("users") : $lng->txt("user")),
476  "percentage" => $perc
477  );
478  }
479  }
480 
481  return $result;
482  }
483 
492  protected function getItemsPercentagesStatus(array $data = NULL, $overall, array $value_map = NULL)
493  {
494  global $lng;
495 
496  $result = array();
497  foreach($value_map as $id => $caption)
498  {
499  $count = 0;
500  if(isset($data[$id]))
501  {
502  $count = $data[$id];
503  }
504  $perc = round($count/$overall*100);
505 
506  $result[] = array(
507  "caption" => $caption,
508  "absolute" => $count,
509  "percentage" => $perc
510  );
511  }
512 
513  return $result;
514  }
515 
516  protected function parseValue($id, $value, $type)
517  {
518  global $lng;
519 
520  // get rid of aggregation
521  $pos = strrpos($id, "_");
522  if($pos !== false)
523  {
524  $function = strtoupper(substr($id, $pos+1));
525  if(in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT")))
526  {
527  $id = substr($id, 0, $pos);
528  }
529  }
530 
531  if(trim($value) == "")
532  {
533  if($id == "title")
534  {
535  return "--".$lng->txt("none")."--";
536  }
537  return "";
538  }
539  switch($id)
540  {
541  case 'status_changed':
542  case "first_access":
543  case "create_date":
545  break;
546 
547  case "last_access":
549  break;
550 
551  case "spent_seconds":
552  case "read_count_spent_seconds":
553  if(in_array($type, array("exc")))
554  {
555  $value = "-";
556  }
557  else
558  {
559  include_once("./Services/Utilities/classes/class.ilFormat.php");
560  $value = ilFormat::_secondsToString($value);
561  }
562  break;
563 
564  case "percentage":
565  /* :TODO:
566  if(in_array(strtolower($this->status_class),
567  array("illpstatusmanual", "illpstatusscormpackage", "illpstatustestfinished")) ||
568  $type == "exc"))
569  */
570  if(false)
571  {
572  $value = "-";
573  }
574  else
575  {
576  $value = $value."%";
577  }
578  break;
579 
580  case "mark":
581  if(in_array($type, array("lm", "dbk")))
582  {
583  $value = "-";
584  }
585  break;
586  }
587 
588  return $value;
589  }
590 
594  protected function fillRow($a_set)
595  {
596  global $lng, $ilCtrl;
597 
598  $this->tpl->setVariable("ICON", ilObject::_getIcon("", "tiny", $a_set["type"]));
599  $this->tpl->setVariable("ICON_ALT", $lng->txt($a_set["type"]));
600  $this->tpl->setVariable("TITLE", $a_set["title"]);
601 
602  if($a_set["offline"])
603  {
604  $this->tpl->setCurrentBlock("offline");
605  $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
606  $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline"));
607  $this->tpl->parseCurrentBlock();
608  }
609 
610  foreach ($this->getSelectedColumns() as $c)
611  {
612  switch($c)
613  {
614  case "country":
615  case "gender":
616  case "city":
617  case "language":
618  case "status":
619  case "mark":
620  case "sel_country":
621  $this->renderPercentages($c, $a_set[$c]);
622  break;
623 
624  case "percentage_avg":
625  if((int)$a_set[$c] === 0 || !$this->isPercentageAvailable($a_set["obj_id"]))
626  {
627  $this->tpl->setVariable(strtoupper($c), "");
628  break;
629  }
630 
631  default:
632  $value = $this->parseValue($c, $a_set[$c], $a_set["type"]);
633  $this->tpl->setVariable(strtoupper($c), $value);
634  break;
635  }
636  }
637 
638  if($this->is_root)
639  {
640  $path = $this->buildPath($a_set["ref_ids"], false, true);
641  if($path)
642  {
643  $this->tpl->setCurrentBlock("item_path");
644  foreach($path as $ref_id => $path_item)
645  {
646  $this->tpl->setVariable("PATH_ITEM", $path_item);
647 
648  if(!$this->anonymized)
649  {
650  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
651  $this->tpl->setVariable("URL_DETAILS", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
652  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
653  $this->tpl->setVariable("TXT_DETAILS", $lng->txt('trac_participants'));
654  }
655  else
656  {
657  $this->tpl->setVariable("URL_DETAILS", ilLink::_getLink($ref_id, $a_set["type"]));
658  $this->tpl->setVariable("TXT_DETAILS", $lng->txt('view'));
659  }
660 
661  $this->tpl->parseCurrentBlock();
662  }
663  }
664 
665  $this->tpl->setCurrentBlock("item_command");
666  $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
667  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
668  $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('trac_hide'));
669  $this->tpl->parseCurrentBlock();
670 
671  $this->tpl->touchBlock("path_action");
672  }
673  }
674 
675  protected function renderPercentages($id, $data)
676  {
677  if($data)
678  {
679  foreach($data as $item)
680  {
681  $this->tpl->setCurrentBlock($id."_row");
682  $this->tpl->setVariable("CAPTION", $item["caption"]);
683  $this->tpl->setVariable("ABSOLUTE", $item["absolute"]);
684  $this->tpl->setVariable("PERCENTAGE", $item["percentage"]);
685  $this->tpl->parseCurrentBlock();
686  }
687  }
688  else
689  {
690  $this->tpl->touchBlock($id);;
691  }
692  }
693 
694  protected function isArrayColumn($a_name)
695  {
696  if(in_array($a_name, array("country", "gender", "city", "language", "status", "mark")))
697  {
698  return true;
699  }
700  return false;
701  }
702 
703  public function numericOrdering($a_field)
704  {
705  $pos = strrpos($a_field, "_");
706  if($pos !== false)
707  {
708  $function = strtoupper(substr($a_field, $pos+1));
709  if(in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT", "TOTAL")))
710  {
711  return true;
712  }
713  }
714  return false;
715  }
716 
717  protected function fillHeaderExcel($worksheet, &$a_row)
718  {
719  $worksheet->write($a_row, 0, $this->lng->txt("title"));
720 
721  $labels = $this->getSelectableColumns();
722  $cnt = 1;
723  foreach ($this->getSelectedColumns() as $c)
724  {
725  $label = $labels[$c]["txt"];
726  $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
727  $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
728 
729  if(!$this->isArrayColumn($c))
730  {
731  $worksheet->write($a_row, $cnt, $label);
732  $cnt++;
733  }
734  else
735  {
736  if($c != "status")
737  {
738  $worksheet->write($a_row, $cnt, $label." #1");
739  $worksheet->write($a_row, ++$cnt, $label." #1");
740  $worksheet->write($a_row, ++$cnt, $label." #1 %");
741  $worksheet->write($a_row, ++$cnt, $label." #2");
742  $worksheet->write($a_row, ++$cnt, $label." #2");
743  $worksheet->write($a_row, ++$cnt, $label." #2 %");
744  $worksheet->write($a_row, ++$cnt, $label." #3");
745  $worksheet->write($a_row, ++$cnt, $label." #3");
746  $worksheet->write($a_row, ++$cnt, $label." #3 %");
747  $worksheet->write($a_row, ++$cnt, $label." ".$this->lng->txt("trac_others"));
748  $worksheet->write($a_row, ++$cnt, $label." ".$this->lng->txt("trac_others"));
749  $worksheet->write($a_row, ++$cnt, $label." ".$this->lng->txt("trac_others")." %");
750  }
751  else
752  {
753  // build status to image map
754  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
755  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
756  $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
760  $cnt--;
761  foreach($valid_status as $status)
762  {
764  $worksheet->write($a_row, ++$cnt, $text);
765  $worksheet->write($a_row, ++$cnt, $text." %");
766  }
767  }
768  $cnt++;
769  }
770  }
771  }
772 
773  protected function fillRowExcel($worksheet, &$a_row, $a_set)
774  {
775  $worksheet->write($a_row, 0, $a_set["title"]);
776 
777  $cnt = 1;
778  foreach ($this->getSelectedColumns() as $c)
779  {
780  if(!$this->isArrayColumn($c))
781  {
782  $val = $this->parseValue($c, $a_set[$c], "user");
783  $worksheet->write($a_row, $cnt, $val);
784  $cnt++;
785  }
786  else
787  {
788  foreach($a_set[$c] as $idx => $value)
789  {
790  if($c == "status")
791  {
792  $worksheet->write($a_row, $cnt, (int)$value["absolute"]);
793  $worksheet->write($a_row, ++$cnt, $value["percentage"]);
794  }
795  else
796  {
797  $worksheet->write($a_row, $cnt, $value["caption"]);
798  $worksheet->write($a_row, ++$cnt, (int)$value["absolute"]);
799  $worksheet->write($a_row, ++$cnt, $value["percentage"]);
800  }
801  $cnt++;
802  }
803  if(sizeof($a_set[$c]) < 4 && $c != "status")
804  {
805  for($loop = 4; $loop > sizeof($a_set[$c]); $loop--)
806  {
807  $worksheet->write($a_row, $cnt, "");
808  $worksheet->write($a_row, ++$cnt, "");
809  $worksheet->write($a_row, ++$cnt, "");
810  $cnt++;
811  }
812  }
813  }
814  }
815  }
816 
817  protected function fillHeaderCSV($a_csv)
818  {
819  $a_csv->addColumn($this->lng->txt("title"));
820 
821  $labels = $this->getSelectableColumns();
822  foreach ($this->getSelectedColumns() as $c)
823  {
824  $label = $labels[$c]["txt"];
825  $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
826  $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
827 
828  if(!$this->isArrayColumn($c))
829  {
830  $a_csv->addColumn($label);
831  }
832  else
833  {
834  if($c != "status")
835  {
836  $a_csv->addColumn($label." #1");
837  $a_csv->addColumn($label." #1");
838  $a_csv->addColumn($label." #1 %");
839  $a_csv->addColumn($label." #2");
840  $a_csv->addColumn($label." #2");
841  $a_csv->addColumn($label." #2 %");
842  $a_csv->addColumn($label." #3");
843  $a_csv->addColumn($label." #3");
844  $a_csv->addColumn($label." #3 %");
845  $a_csv->addColumn($label." ".$this->lng->txt("trac_others"));
846  $a_csv->addColumn($label." ".$this->lng->txt("trac_others"));
847  $a_csv->addColumn($label." ".$this->lng->txt("trac_others")." %");
848  }
849  else
850  {
851  // build status to image map
852  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
853  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
854  $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM,
858  foreach($valid_status as $status)
859  {
861  $a_csv->addColumn($text);
862  $a_csv->addColumn($text." %");
863  }
864  }
865  }
866  }
867 
868  $a_csv->addRow();
869  }
870 
871  protected function fillRowCSV($a_csv, $a_set)
872  {
873  $a_csv->addColumn($a_set["title"]);
874 
875  foreach ($this->getSelectedColumns() as $c)
876  {
877  if(!$this->isArrayColumn($c))
878  {
879  $val = $this->parseValue($c, $a_set[$c], "user");
880  $a_csv->addColumn($val);
881  }
882  else
883  {
884  foreach($a_set[$c] as $idx => $value)
885  {
886  if($c != "status")
887  {
888  $a_csv->addColumn($value["caption"]);
889  }
890  $a_csv->addColumn((int)$value["absolute"]);
891  $a_csv->addColumn($value["percentage"]);
892  }
893  if(sizeof($a_set[$c]) < 4 && $c != "status")
894  {
895  for($loop = 4; $loop > sizeof($a_set[$c]); $loop--)
896  {
897  $a_csv->addColumn("");
898  $a_csv->addColumn("");
899  $a_csv->addColumn("");
900  }
901  }
902  }
903  }
904 
905  $a_csv->addRow();
906  }
907 }
908 ?>