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 public function __construct($a_parent_obj, $a_parent_cmd, array $a_preselect = null, $a_load_items =
true, $a_is_chart =
false, $a_is_details =
false)
37 $this->preselected = $a_preselect;
38 $this->is_chart = (bool) $a_is_chart;
39 $this->is_details = (bool) $a_is_details;
41 $this->
setId(
"lpobjstatlptbl");
43 parent::__construct($a_parent_obj, $a_parent_cmd);
45 if (!$this->is_details) {
60 if (strpos($this->filter[
"yearmonth"],
"-") ===
false) {
61 foreach ($this->
getMonthsYear($this->filter[
"yearmonth"]) as $num => $caption) {
62 $this->
addColumn($caption,
"month_" . $num);
65 foreach ($this->types as
$type) {
67 $caption =
" " . $this->lng->txt(
"trac_object_stat_lp_" . $type);
74 include_once(
"./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
75 foreach ($this->status as
$status) {
80 foreach ($this->types as $type) {
82 $caption =
$icon . $this->lng->txt(
"trac_object_stat_lp_" . $type);
84 $caption =
$icon .
" Ø";
86 $this->
addColumn($caption, $status .
"_" . $type);
91 if (!$this->is_details) {
92 $this->
setTitle($this->lng->txt(
"trac_object_stat_lp"));
101 $this->
setRowTemplate(
"tpl.lp_object_statistics_lp_row.html",
"Services/Tracking");
114 if ($this->is_details) {
125 if ($a_field !=
"title") {
143 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
158 $this->filter[
"type"] =
"crs";
162 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
167 $ti->readFromSession();
168 $this->filter[
"query"] = $ti->getValue();
174 $si->readFromSession();
175 if (!
$si->getValue()) {
176 $si->setValue(date(
"Y-m"));
178 $this->filter[
"yearmonth"] =
$si->getValue();
180 if (!strpos($this->filter[
"yearmonth"],
"-")) {
183 "mem_cnt_max" =>
$lng->txt(
"members") .
" " .
$lng->txt(
"trac_object_stat_lp_max"),
184 "mem_cnt_avg" =>
$lng->txt(
"members") .
" Ø",
188 $si->setOptions($options);
190 $si->readFromSession();
191 if (!
$si->getValue()) {
192 $si->setValue(
"mem_cnt_max");
194 $this->filter[
"measure"] =
$si->getValue();
197 if ($this->is_details) {
198 $this->filters = array();
205 $all_status = array_merge(array(
"mem_cnt"), $this->status);
214 $objects = array_keys($objects);
216 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
218 $yearmonth = explode(
"-", $this->filter[
"yearmonth"]);
219 if (
sizeof($yearmonth) == 1) {
221 $obj_id = $item[
"obj_id"];
222 if (!isset(
$data[$obj_id])) {
223 $data[$obj_id][
"obj_id"] = $obj_id;
227 $measure_type = substr($this->filter[
"measure"], -3);
228 $measure_field = substr($this->filter[
"measure"], 0, -4);
229 $value = $item[$measure_field .
"_" . $measure_type];
230 $idx = $item[
"yyyy"] .
"-" . str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
231 $data[$obj_id][
"month_" . $idx] = $value;
234 if ($this->is_chart) {
236 foreach (array_keys($this->
getMonthsYear($yearmonth[0])) as $num) {
237 $num = (int) array_pop(explode(
"-", $num));
239 $idx = $yearmonth[0] .
240 "-" . str_pad($num, 2,
"0", STR_PAD_LEFT) .
241 "-" . str_pad($item[
"dd"], 2,
"0", STR_PAD_LEFT);
242 $this->chart_data[$item[
"obj_id"]][$idx] = $item;
249 $obj_id = $item[
"obj_id"];
250 if (!isset(
$data[$obj_id])) {
251 $data[$obj_id][
"obj_id"] = $obj_id;
256 foreach ($all_status as
$status) {
258 if (is_numeric($status)) {
259 $field = $this->status_map[
$status];
265 foreach ($this->types as
$type) {
266 $value = $item[$field .
"_" .
$type];
267 $data[$obj_id][$status .
"_" .
$type] = $value;
272 if ($this->is_chart) {
275 $this->chart_data[$item[
"obj_id"]][$item[
"dd"]] = $item;
281 foreach ($objects as $obj_id) {
282 if (!isset(
$data[$obj_id])) {
283 $data[$obj_id][
"obj_id"] = $obj_id;
291 include_once
"./Services/Link/classes/class.ilLink.php";
297 $all_status = array_merge(array(
"mem_cnt"), $this->status);
299 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
301 $month =
"month_" . $item[
"yyyy"] .
"-" . str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
303 foreach ($all_status as
$status) {
305 if ($status !=
"mem_cnt") {
306 $field = $this->status_map[
$status];
311 foreach ($this->types as
$type) {
312 $value = $item[$field .
"_" .
$type];
313 $idx = $item[
"yyyy"] .
"-" . str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
314 $data[$status .
"_" .
$type][
"month_" . $idx] = $value;
320 foreach (array_keys(
$data) as $figure) {
321 $status = substr($figure, 0, -4);
322 $type = substr($figure, -3);
330 $text = $this->lng->txt(
"members");
332 if (
$type !=
"avg") {
333 $caption =
$text .
" " . $this->lng->txt(
"trac_object_stat_lp_" .
$type);
335 $caption =
$text .
" Ø";
337 $data[$figure][
"figure"] = $caption;
345 foreach ($this->types as
$type) {
346 $a_row[
"mem_cnt_" .
$type] = null;
348 foreach ($this->status as
$status) {
349 foreach ($this->types as $type) {
350 $a_row[$status .
"_" .
$type] = null;
364 if (!$this->is_details) {
368 if (strpos($this->filter[
"yearmonth"],
"-") ===
false) {
369 $ilCtrl->setParameter($this->parent_obj,
"item_id", $a_set[
"obj_id"]);
370 $url =
$ilCtrl->getLinkTarget($this->parent_obj,
"showLearningProgressDetails");
371 $a_set[
"title"] .=
" (<a href=\"#\" onclick=\"ilObjStat.showLPDetails(event, '" .
$url .
"');\">Details</a>)";
372 $ilCtrl->setParameter($this->parent_obj,
"item_id",
"");
375 $this->tpl->setCurrentBlock(
"checkbox");
376 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
377 $this->tpl->setVariable(
"ICON_SRC", ilObject::_getIcon(
"",
"tiny",
$type));
378 $this->tpl->setVariable(
"ICON_ALT", $this->lng->txt(
$type));
379 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
380 if ($this->preselected && in_array($a_set[
"obj_id"], $this->preselected)) {
381 $this->tpl->setVariable(
"CHECKBOX_STATE",
" checked=\"checked\"");
383 $this->tpl->parseCurrentBlock();
385 $this->tpl->setCurrentBlock(
"details");
386 $this->tpl->setVariable(
"TXT_FIGURE", $a_set[
"figure"]);
387 $this->tpl->parseCurrentBlock();
390 $this->tpl->setCurrentBlock(
"item");
392 if (strpos($this->filter[
"yearmonth"],
"-") ===
false) {
393 foreach (array_keys($this->
getMonthsYear($this->filter[
"yearmonth"])) as $num) {
395 $this->tpl->setVariable(
"ITEM_VALUE", $value);
396 $this->tpl->parseCurrentBlock();
399 foreach ($this->types as
$type) {
400 $this->tpl->setVariable(
"ITEM_VALUE", $this->
anonymizeValue((
int) $a_set[
"mem_cnt_" . $type]));
401 $this->tpl->parseCurrentBlock();
403 foreach ($this->status as
$status) {
404 foreach ($this->types as $type) {
405 $this->tpl->setVariable(
"ITEM_VALUE", $this->
anonymizeValue((
int) $a_set[$status .
"_" . $type]));
406 $this->tpl->parseCurrentBlock();
418 $a_graph_items = array(array_pop($a_graph_items));
420 include_once
"Services/Chart/classes/class.ilChart.php";
422 $chart->setsize(700, 500);
428 $custom_order = array(
435 $chart->setColors(array());
438 foreach ($this->chart_data as $object_id => $days) {
439 if (in_array($object_id, $a_graph_items)) {
441 foreach ($custom_order as
$status => $colors) {
459 $chart_colors[] = $colors[0];
461 $chart->setColors($chart_colors);
463 if (strpos($this->filter[
"yearmonth"],
"-") ===
false) {
464 $x_axis = $this->lng->txt(
"month");
467 foreach (array_keys($this->
getMonthsYear($this->filter[
"yearmonth"])) as $month) {
468 for ($loop = 1; $loop < 32; $loop++) {
469 $item_day = $month .
"-" . str_pad($loop, 2,
"0", STR_PAD_LEFT);
470 foreach (array_keys($custom_order) as
$status) {
471 if (isset($days[$item_day])) {
473 $value = (int) $days[$item_day][$this->status_map[$status] .
"_avg"];
477 $max_value = max($max_value, $value);
479 $series[
$status]->addPoint($counter, $value);
485 $x_axis = $this->lng->txt(
"day");
486 for ($loop = 1; $loop < 32; $loop++) {
487 foreach (array_keys($custom_order) as
$status) {
488 if (isset($days[$loop])) {
490 $value = (int) $days[$loop][$this->status_map[$status] .
"_avg"];
494 $max_value = max($max_value, $value);
496 $series[
$status]->addPoint($loop, $value);
501 foreach (array_keys($custom_order) as
$status) {
502 $chart->addData($series[$status]);
510 if (strpos($this->filter[
"yearmonth"],
"-") ===
false) {
512 foreach ($this->
getMonthsYear($this->filter[
"yearmonth"],
true) as $caption) {
513 $labels[$counter] = $caption;
517 for ($loop = 1; $loop < 32; $loop++) {
518 $labels[$loop] = $loop .
".";
521 $chart->setTicks($labels, $value_ticks,
true);
523 return $chart->getHTML();
532 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
534 include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
537 $tpl->addJavascript(
"./Services/Tracking/js/ilObjStat.js");
const LP_STATUS_COMPLETED_NUM
anonymizeValue($a_value, $a_force_number=false)
static getObjectLPStatistics(array $a_obj_ids, $a_year, $a_month=null, $a_group_by_day=false)
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static _getImagePathForStatus($a_status)
Get image path for status.
setEnableNumInfo($a_val)
Set enable num info.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
getMonthsYear($a_year=null, $a_short=false)
searchObjects(array $filter, $permission, array $preset_obj_ids=null, $a_check_lp_activation=true)
Search objects that match current filters.
const LP_STATUS_IN_PROGRESS_NUM
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static _lookupTitle($a_id)
lookup object title
getGraph(array $a_graph_items)
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
__construct($a_parent_obj, $a_parent_cmd, array $a_preselect=null, $a_load_items=true, $a_is_chart=false, $a_is_details=false)
Constructor.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
TableGUI class for learning progress.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
buildValueScale($a_max_value, $a_anonymize=false, $a_format_seconds=false)
addMultiCommand($a_cmd, $a_text)
Add Command button.
This class represents a text property in a property form.
numericOrdering($a_field)
setMaxLength($a_maxlength)
Set Max Length.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
fillRow($a_set)
Fill table row.
initLearningProgressDetailsLayer()
const LP_STATUS_NOT_ATTEMPTED_NUM
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
getMonthsFilter($a_short=false)
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getDetailItems($a_obj_id)
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
setEnableHeader($a_enableheader)
Set Enable Header.
TableGUI class for learning progress.
getCurrentFilter($as_query=false)
setEnableTitle($a_enabletitle)
Set Enable Title.
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
static getInstanceByType($a_type, $a_id)
Get type instance.
setLimit($a_limit=0, $a_default_limit=0)
const LP_STATUS_FAILED_NUM
setFilterCommand($a_val, $a_caption=null)
Set filter command.