4 include_once(
"./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
19 function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_print_mode =
false)
23 $this->
setId(
"trsmy");
25 $this->ref_id = $a_ref_id;
35 $this->
parseTitle($this->obj_id,
"trac_summary");
40 $this->
addColumn($this->lng->txt(
"title"),
"title");
52 $this->
setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
53 $this->
setRowTemplate(
"tpl.trac_summary_row.html",
"Services/Tracking");
57 $this->
getItems($a_parent_obj->getObjId(), $a_ref_id);
64 $lng_map = array(
"user_total" =>
"users",
"first_access_min" =>
"trac_first_access",
65 "last_access_max" =>
"trac_last_access",
"mark" =>
"trac_mark",
"status" =>
"trac_status",
66 "spent_seconds_avg" =>
"trac_spent_seconds",
"percentage_avg" =>
"trac_percentage",
67 "read_count_sum" =>
"trac_read_count",
"read_count_avg" =>
"trac_read_count",
71 $all = array(
"user_total");
75 include_once
'Services/Tracking/classes/class.ilObjUserTracking.php';
79 $all[] =
"read_count_sum";
80 $all[] =
"read_count_avg";
81 $default[] =
"read_count_sum";
85 $all[] =
"spent_seconds_avg";
86 $default[] =
"spent_seconds_avg";
89 $all[] =
"percentage_avg";
93 $privacy = array(
"gender",
"city",
"country",
"sel_country");
94 foreach($privacy as $field)
96 if($ilSetting->get(
"usr_settings_course_export_".$field))
104 $default[] =
"percentage_avg";
105 $default[] =
"status";
110 $all[] =
"first_access_min";
111 $all[] =
"last_access_max";
114 $all[] =
"create_date_min";
115 $all[] =
"create_date_max";
119 foreach($all as $column)
124 if(substr(
$l, -3) ==
"avg")
128 else if(substr(
$l, -3) ==
"sum" ||
$l ==
"user_total")
133 if(isset($lng_map[
$l]))
140 $columns[$column] = array(
142 "default" => (in_array($column, $default) ?
true :
false)
156 $this->filter[
"user_total"] = $item->getValue();
159 $lng->txt(
"trac_read_count"));
160 $this->filter[
"read_count"] = $item->getValue();
163 true, $lng->txt(
"trac_spent_seconds"));
164 $this->filter[
"spent_seconds"][
"from"] = $item->getCombinationItem(
"from")->getValueInSeconds();
165 $this->filter[
"spent_seconds"][
"to"] = $item->getCombinationItem(
"to")->getValueInSeconds();
168 $lng->txt(
"trac_percentage"));
169 $this->filter[
"percentage"] = $item->getValue();
171 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
173 $item->setOptions(array(
"" => $lng->txt(
"trac_all"),
178 $this->filter[
"status"] = $item->getValue();
179 if($this->filter[
"status"])
181 $this->filter[
"status"]--;
185 $lng->txt(
"trac_mark"));
186 $this->filter[
"mark"] = $item->getValue();
188 if($ilSetting->get(
"usr_settings_course_export_gender"))
191 $item->setOptions(array(
"" => $lng->txt(
"trac_all"),
"m" => $lng->txt(
"gender_m"),
192 "f" => $lng->txt(
"gender_f")));
193 $this->filter[
"gender"] = $item->getValue();
196 if($ilSetting->get(
"usr_settings_course_export_city"))
199 $this->filter[
"city"] = $item->getValue();
202 if($ilSetting->get(
"usr_settings_course_export_country"))
205 $this->filter[
"country"] = $item->getValue();
208 if($ilSetting->get(
"usr_settings_course_export_sel_country"))
212 $this->filter[
"sel_country"] = $item->getValue();
216 $this->filter[
"language"] = $item->getValue();
219 $this->filter[
"first_access"] = $item->getDate();
222 $this->filter[
"last_access"] = $item->getDate();
225 $this->filter[
"registration"] = $item->getDate();
232 include_once(
"./Services/Utilities/classes/class.ilCountry.php");
236 $options[$c] = $lng->txt(
"meta_c_".$c);
252 include_once(
"./Services/Tracking/classes/class.ilTrQuery.php");
266 foreach(
$data[
"set"] as $idx => $result)
269 if($result[
"title"] ==
"" && $result[
"type"] ==
"sess")
271 include_once
"Modules/Session/classes/class.ilObjSession.php";
273 $data[
"set"][$idx][
"title"] =
$sess->getFirstAppointment()->appointmentToString();
277 $users_no = $result[
"user_total"];
279 $data[
"set"][$idx][
"gender"] = $this->
getItemsPercentages($result[
"gender"], $users_no, array(
"m"=>$lng->txt(
"gender_m"),
"f"=>$lng->txt(
"gender_f")));
283 $languages = array();
284 foreach ($lng->getInstalledLanguages() as $lang_key)
286 $languages[$lang_key] = $lng->txt(
"lang_".$lang_key);
290 include_once(
"./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
291 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
305 $data[
"set"][$idx][
"percentage_avg"] = NULL;
335 $counter = $others_counter = $others_sum = 0;
336 foreach(
$data as $id => $count)
343 if($value_map && isset($value_map[$id]))
345 $caption = $value_map[$id];
350 $caption = $lng->txt(
"none");
353 $perc = round($count/$overall*100);
355 "caption" => $caption,
356 "absolute" => $count.
" ".($count > 1 ? $lng->txt(
"users") : $lng->txt(
"user")),
357 "percentage" => $perc
362 $others_sum += $count;
369 $perc = round($others_sum/$overall*100);
371 "caption" => $otherss_counter.
" ".$lng->txt(
"trac_others"),
372 "absolute" => $others_sum.
" ".($others_sum > 1 ? $lng->txt(
"users") : $lng->txt(
"user")),
373 "percentage" => $perc
387 $pos = strrpos($id,
"_");
390 $function = strtoupper(substr($id,
$pos+1));
391 if(in_array($function, array(
"MIN",
"MAX",
"SUM",
"AVG",
"COUNT")))
393 $id = substr($id, 0,
$pos);
397 if(trim($value) ==
"")
401 return "--".$lng->txt(
"none").
"--";
417 case "spent_seconds":
418 if(in_array(
$type, array(
"exc")))
424 include_once(
"./classes/class.ilFormat.php");
446 if(in_array(
$type, array(
"lm",
"dbk")))
464 $this->tpl->setVariable(
"ICON_ALT", $lng->txt($a_set[
"type"]));
465 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
481 case "percentage_avg":
484 $this->tpl->setVariable(strtoupper($c),
"");
489 $value = $this->
parseValue($c, $a_set[$c], $a_set[
"type"]);
490 $this->tpl->setVariable(strtoupper($c), $value);
500 foreach(
$data as $item)
502 $this->tpl->setCurrentBlock($id.
"_row");
503 $this->tpl->setVariable(
"CAPTION", $item[
"caption"]);
504 $this->tpl->setVariable(
"ABSOLUTE", $item[
"absolute"]);
505 $this->tpl->setVariable(
"PERCENTAGE", $item[
"percentage"]);
506 $this->tpl->parseCurrentBlock();
511 $this->tpl->touchBlock($id);;
517 if(in_array($a_name, array(
"country",
"gender",
"city",
"language",
"status",
"mark")))
526 $worksheet->write($a_row, 0, $this->lng->txt(
"title"));
532 $label = $labels[$c][
"txt"];
533 $label = str_replace(
"Ø", $this->lng->txt(
"trac_average"), $label);
534 $label = str_replace(
"∑", $this->lng->txt(
"trac_sum"), $label);
538 $worksheet->write($a_row, $cnt, $label);
543 $worksheet->write($a_row, $cnt, $label.
" #1");
544 $worksheet->write($a_row, ++$cnt, $label.
" #1");
545 $worksheet->write($a_row, ++$cnt, $label.
" #1 %");
546 $worksheet->write($a_row, ++$cnt, $label.
" #2");
547 $worksheet->write($a_row, ++$cnt, $label.
" #2");
548 $worksheet->write($a_row, ++$cnt, $label.
" #2 %");
549 $worksheet->write($a_row, ++$cnt, $label.
" #3");
550 $worksheet->write($a_row, ++$cnt, $label.
" #3");
551 $worksheet->write($a_row, ++$cnt, $label.
" #3 %");
552 $worksheet->write($a_row, ++$cnt, $label.
" ".$this->lng->txt(
"trac_others"));
553 $worksheet->write($a_row, ++$cnt, $label.
" ".$this->lng->txt(
"trac_others"));
554 $worksheet->write($a_row, ++$cnt, $label.
" ".$this->lng->txt(
"trac_others").
" %");
562 $worksheet->write($a_row, 0, $a_set[
"title"]);
569 $val = $this->
parseValue($c, $a_set[$c],
"user");
570 $worksheet->write($a_row, $cnt, $val);
575 foreach($a_set[$c] as $idx => $value)
579 preg_match(
"/alt=\"([^\"]+)\"/", $value[
"caption"],
$res);
580 $value[
"caption"] =
$res[1];
582 $worksheet->write($a_row, $cnt, $value[
"caption"]);
583 $worksheet->write($a_row, ++$cnt, (
int)$value[
"absolute"]);
584 $worksheet->write($a_row, ++$cnt, $value[
"percentage"]);
587 if(
sizeof($a_set[$c]) < 4)
589 for($loop = 4; $loop >
sizeof($a_set[$c]); $loop--)
591 $worksheet->write($a_row, $cnt,
"");
592 $worksheet->write($a_row, ++$cnt,
"");
593 $worksheet->write($a_row, ++$cnt,
"");
603 $a_csv->addColumn($this->lng->txt(
"title"));
608 $label = $labels[$c][
"txt"];
609 $label = str_replace(
"Ø", $this->lng->txt(
"trac_average"), $label);
610 $label = str_replace(
"∑", $this->lng->txt(
"trac_sum"), $label);
614 $a_csv->addColumn($label);
618 $a_csv->addColumn($label.
" #1");
619 $a_csv->addColumn($label.
" #1");
620 $a_csv->addColumn($label.
" #1 %");
621 $a_csv->addColumn($label.
" #2");
622 $a_csv->addColumn($label.
" #2");
623 $a_csv->addColumn($label.
" #2 %");
624 $a_csv->addColumn($label.
" #3");
625 $a_csv->addColumn($label.
" #3");
626 $a_csv->addColumn($label.
" #3 %");
627 $a_csv->addColumn($label.
" ".$this->lng->txt(
"trac_others"));
628 $a_csv->addColumn($label.
" ".$this->lng->txt(
"trac_others"));
629 $a_csv->addColumn($label.
" ".$this->lng->txt(
"trac_others").
" %");
638 $a_csv->addColumn($a_set[
"title"]);
644 $val = $this->
parseValue($c, $a_set[$c],
"user");
645 $a_csv->addColumn($val);
649 foreach($a_set[$c] as $idx => $value)
653 preg_match(
"/alt=\"([^\"]+)\"/", $value[
"caption"],
$res);
654 $value[
"caption"] =
$res[1];
656 $a_csv->addColumn($value[
"caption"]);
657 $a_csv->addColumn((
int)$value[
"absolute"]);
658 $a_csv->addColumn($value[
"percentage"]);
660 if(
sizeof($a_set[$c]) < 4)
662 for($loop = 4; $loop >
sizeof($a_set[$c]); $loop--)
664 $a_csv->addColumn(
"");
665 $a_csv->addColumn(
"");
666 $a_csv->addColumn(
"");