4 include_once(
"./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
5 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
18 protected $types = array(
"min",
"avg",
"max");
30 function __construct($a_parent_obj, $a_parent_cmd, array $a_preselect = null, $a_load_items =
true, $a_is_chart =
false, $a_is_details =
false)
34 $this->preselected = $a_preselect;
35 $this->is_chart = (bool)$a_is_chart;
36 $this->is_details = (bool)$a_is_details;
38 $this->
setId(
"lpobjstatlptbl");
42 if(!$this->is_details)
48 $this->
addColumn($lng->txt(
"trac_title"),
"title");
49 $this->
addColumn($lng->txt(
"object_id"),
"obj_id");
55 $this->
addColumn($lng->txt(
"trac_figure"));
60 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
62 foreach($this->
getMonthsYear($this->filter[
"yearmonth"]) as $num => $caption)
64 $this->
addColumn($caption,
"month_".$num,
"",
false,
"ilRight");
69 foreach($this->types as $type)
73 $caption =
" ".$this->lng->txt(
"trac_object_stat_lp_".$type);
79 $this->
addColumn($lng->txt(
"trac_members_short").$caption,
"mem_cnt_".$type,
"",
false,
"ilRight");
82 include_once(
"./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
83 foreach($this->status as
$status)
89 foreach($this->types as $type)
93 $caption =
$icon.$this->lng->txt(
"trac_object_stat_lp_".$type);
97 $caption =
$icon.
" Ø";
99 $this->
addColumn($caption, $status.
"_".$type,
"",
false,
"ilRight");
104 if(!$this->is_details)
106 $this->
setTitle($this->lng->txt(
"trac_object_stat_lp"));
109 $this->
addMultiCommand(
"showLearningProgressGraph", $lng->txt(
"trac_show_graph"));
114 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
115 $this->
setRowTemplate(
"tpl.lp_object_statistics_lp_row.html",
"Services/Tracking");
129 if($this->is_details)
143 if($a_field !=
"title")
160 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
175 $this->filter[
"type"] =
"crs";
179 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
180 $ti =
new ilTextInputGUI($lng->txt(
"trac_title_description"),
"query");
184 $ti->readFromSession();
185 $this->filter[
"query"] = $ti->getValue();
191 $si->readFromSession();
194 $si->setValue(date(
"Y-m"));
196 $this->filter[
"yearmonth"] =
$si->getValue();
198 if(!strpos($this->filter[
"yearmonth"],
"-"))
202 "mem_cnt_max" => $lng->txt(
"members").
" ".$lng->txt(
"trac_object_stat_lp_max"),
203 "mem_cnt_avg" => $lng->txt(
"members").
" Ø",
207 $si->setOptions($options);
209 $si->readFromSession();
212 $si->setValue(
"mem_cnt_max");
214 $this->filter[
"measure"] =
$si->getValue();
217 if($this->is_details)
219 $this->filters = array();
226 $all_status = array_merge(array(
"mem_cnt"), $this->status);
231 $objects = array_keys($objects);
233 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
235 $yearmonth = explode(
"-", $this->filter[
"yearmonth"]);
236 if(
sizeof($yearmonth) == 1)
240 $obj_id = $item[
"obj_id"];
241 if(!isset(
$data[$obj_id]))
243 $data[$obj_id][
"obj_id"] = $obj_id;
247 $measure_type = substr($this->filter[
"measure"], -3);
248 $measure_field = substr($this->filter[
"measure"], 0, -4);
249 $value = $item[$measure_field.
"_".$measure_type];
250 $idx = $item[
"yyyy"].
"-".str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
251 $data[$obj_id][
"month_".$idx] = $value;
257 foreach(array_keys($this->
getMonthsYear($yearmonth[0])) as $num)
259 $num = (int)array_pop(explode(
"-", $num));
262 $idx = $yearmonth[0].
263 "-".str_pad($num, 2,
"0", STR_PAD_LEFT).
264 "-".str_pad($item[
"dd"], 2,
"0", STR_PAD_LEFT);
265 $this->chart_data[$item[
"obj_id"]][$idx] = $item;
275 $obj_id = $item[
"obj_id"];
276 if(!isset(
$data[$obj_id]))
278 $data[$obj_id][
"obj_id"] = $obj_id;
283 foreach($all_status as
$status)
286 if(is_numeric($status))
288 $field = $this->status_map[
$status];
296 foreach($this->types as $type)
298 $value = $item[$field.
"_".$type];
299 $data[$obj_id][$status.
"_".$type] = $value;
309 $this->chart_data[$item[
"obj_id"]][$item[
"dd"]] = $item;
315 foreach($objects as $obj_id)
317 if(!isset(
$data[$obj_id]))
319 $data[$obj_id][
"obj_id"] = $obj_id;
327 include_once
"./Services/Link/classes/class.ilLink.php";
333 $all_status = array_merge(array(
"mem_cnt"), $this->status);
335 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
338 $month =
"month_".$item[
"yyyy"].
"-".str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
340 foreach($all_status as
$status)
343 if($status !=
"mem_cnt")
345 $field = $this->status_map[
$status];
352 foreach($this->types as $type)
354 $value = $item[$field.
"_".$type];
355 $idx = $item[
"yyyy"].
"-".str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
356 $data[$status.
"_".$type][
"month_".$idx] = $value;
362 foreach(array_keys(
$data) as $figure)
364 $status = substr($figure, 0, -4);
365 $type = substr($figure, -3);
372 $text =
$icon.
" ".$text;
376 $text = $this->lng->txt(
"members");
380 $caption = $text.
" ".$this->lng->txt(
"trac_object_stat_lp_".$type);
384 $caption = $text.
" Ø";
386 $data[$figure][
"figure"] = $caption;
394 foreach($this->types as $type)
396 $a_row[
"mem_cnt_".$type] = null;
398 foreach($this->status as
$status)
400 foreach($this->types as $type)
402 $a_row[$status.
"_".$type] = null;
414 if(!$this->is_details)
419 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
421 $ilCtrl->setParameter($this->parent_obj,
"item_id", $a_set[
"obj_id"]);
422 $url = $ilCtrl->getLinkTarget($this->parent_obj,
"showLearningProgressDetails");
423 $a_set[
"title"] .=
" (<a href=\"#\" onclick=\"ilObjStat.showLPDetails(event, '".$url.
"');\">Details</a>)";
424 $ilCtrl->setParameter($this->parent_obj,
"item_id",
"");
427 $this->tpl->setCurrentBlock(
"checkbox");
428 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
430 $this->tpl->setVariable(
"ICON_ALT", $this->lng->txt($type));
431 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
432 if($this->preselected && in_array($a_set[
"obj_id"], $this->preselected))
434 $this->tpl->setVariable(
"CHECKBOX_STATE",
" checked=\"checked\"");
436 $this->tpl->parseCurrentBlock();
440 $this->tpl->setCurrentBlock(
"details");
441 $this->tpl->setVariable(
"TXT_FIGURE", $a_set[
"figure"]);
442 $this->tpl->parseCurrentBlock();
445 $this->tpl->setCurrentBlock(
"item");
447 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
449 foreach(array_keys($this->
getMonthsYear($this->filter[
"yearmonth"])) as $num)
452 $this->tpl->setVariable(
"ITEM_VALUE", $value);
453 $this->tpl->parseCurrentBlock();
458 foreach($this->types as $type)
460 $this->tpl->setVariable(
"ITEM_VALUE", $this->
anonymizeValue((
int)$a_set[
"mem_cnt_".$type]));
461 $this->tpl->parseCurrentBlock();
463 foreach($this->status as
$status)
465 foreach($this->types as $type)
467 $this->tpl->setVariable(
"ITEM_VALUE", $this->
anonymizeValue((
int)$a_set[$status.
"_".$type]));
468 $this->tpl->parseCurrentBlock();
478 $a_graph_items = array(array_pop($a_graph_items));
480 include_once
"Services/Chart/classes/class.ilChart.php";
481 $chart =
new ilChart(
"objstlp", 700, 500);
484 $chart->setLegend($legend);
487 $custom_order = array(
494 $chart->setColors(array());
497 foreach($this->chart_data as $object_id => $days)
499 if(in_array($object_id, $a_graph_items))
502 foreach($custom_order as
$status => $colors)
521 $chart_colors[] = $colors[0];
523 $chart->setColors($chart_colors);
525 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
527 $x_axis = $this->lng->txt(
"month");
530 foreach(array_keys($this->
getMonthsYear($this->filter[
"yearmonth"])) as $month)
532 for($loop = 1; $loop<32; $loop++)
534 $item_day = $month.
"-".str_pad($loop, 2,
"0", STR_PAD_LEFT);
535 foreach(array_keys($custom_order) as
$status)
537 if(isset($days[$item_day]))
540 $value = (int)$days[$item_day][$this->status_map[$status].
"_avg"];
546 $max_value = max($max_value, $value);
548 $series[
$status]->addPoint($counter, $value);
556 $x_axis = $this->lng->txt(
"day");
557 for($loop = 1; $loop<32; $loop++)
559 foreach(array_keys($custom_order) as
$status)
561 if(isset($days[$loop]))
564 $value = (int)$days[$loop][$this->status_map[$status].
"_avg"];
570 $max_value = max($max_value, $value);
572 $series[
$status]->addPoint($loop, $value);
577 foreach(array_keys($custom_order) as
$status)
579 $chart->addData($series[$status]);
587 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
590 foreach($this->
getMonthsYear($this->filter[
"yearmonth"],
true) as $caption)
592 $labels[$counter] = $caption;
598 for($loop = 1; $loop<32; $loop++)
600 $labels[$loop] = $loop.
".";
603 $chart->setTicks($labels, $value_ticks,
true);
605 return $chart->getHTML();
612 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
614 include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
617 $tpl->addJavascript(
"./Services/Tracking/js/ilObjStat.js");