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)
34 $ilCtrl = $DIC[
'ilCtrl'];
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");
45 if (!$this->is_details) {
60 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
62 $this->
addColumn($caption,
"month_" . $num);
65 foreach ($this->types as
$type) {
67 $caption =
" " . $this->lng->txt(
"trac_object_stat_lp_" . $type);
76 foreach ($this->status as
$status) {
77 $icon = $icons->renderIconForStatus($status);
79 foreach ($this->types as $type) {
81 $caption =
$icon .
" " . $this->lng->txt(
82 "trac_object_stat_lp_" . $type
85 $caption =
$icon .
" Ø";
87 $this->
addColumn($caption, $status .
"_" . $type);
92 if (!$this->is_details) {
93 $this->
setTitle($this->lng->txt(
"trac_object_stat_lp"));
101 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
102 $this->
setRowTemplate(
"tpl.lp_object_statistics_lp_row.html",
"Services/Tracking");
115 if ($this->is_details) {
126 if ($a_field !=
"title") {
144 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
159 $this->
filter[
"type"] =
"crs";
163 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
165 $ti->setMaxLength(64);
168 $ti->readFromSession();
169 $this->
filter[
"query"] = $ti->getValue();
175 $si->readFromSession();
176 if (!
$si->getValue()) {
177 $si->setValue(date(
"Y-m"));
179 $this->
filter[
"yearmonth"] =
$si->getValue();
181 if (!strpos($this->
filter[
"yearmonth"],
"-")) {
184 "mem_cnt_max" =>
$lng->txt(
"members") .
" " .
$lng->txt(
"trac_object_stat_lp_max"),
185 "mem_cnt_avg" =>
$lng->txt(
"members") .
" Ø",
189 $si->setOptions($options);
191 $si->readFromSession();
192 if (!
$si->getValue()) {
193 $si->setValue(
"mem_cnt_max");
195 $this->
filter[
"measure"] =
$si->getValue();
198 if ($this->is_details) {
199 $this->filters = array();
206 $all_status = array_merge(array(
"mem_cnt"), $this->status);
215 $objects = array_keys($objects);
217 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
219 $yearmonth = explode(
"-", $this->
filter[
"yearmonth"]);
220 if (
sizeof($yearmonth) == 1) {
222 $obj_id = $item[
"obj_id"];
223 if (!isset(
$data[$obj_id])) {
224 $data[$obj_id][
"obj_id"] = $obj_id;
228 $measure_type = substr($this->
filter[
"measure"], -3);
229 $measure_field = substr($this->
filter[
"measure"], 0, -4);
230 $value = $item[$measure_field .
"_" . $measure_type];
231 $idx = $item[
"yyyy"] .
"-" . str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
232 $data[$obj_id][
"month_" . $idx] = $value;
235 if ($this->is_chart) {
237 foreach (array_keys($this->
getMonthsYear($yearmonth[0])) as $num) {
238 $num = (int) array_pop(explode(
"-", $num));
240 $idx = $yearmonth[0] .
241 "-" . str_pad($num, 2,
"0", STR_PAD_LEFT) .
242 "-" . str_pad($item[
"dd"], 2,
"0", STR_PAD_LEFT);
243 $this->chart_data[$item[
"obj_id"]][$idx] = $item;
250 $obj_id = $item[
"obj_id"];
251 if (!isset(
$data[$obj_id])) {
252 $data[$obj_id][
"obj_id"] = $obj_id;
257 foreach ($all_status as
$status) {
259 if (is_numeric($status)) {
260 $field = $this->status_map[
$status];
266 foreach ($this->types as
$type) {
267 $value = $item[$field .
"_" .
$type];
268 $data[$obj_id][$status .
"_" .
$type] = $value;
273 if ($this->is_chart) {
276 $this->chart_data[$item[
"obj_id"]][$item[
"dd"]] = $item;
282 foreach ($objects as $obj_id) {
283 if (!isset(
$data[$obj_id])) {
284 $data[$obj_id][
"obj_id"] = $obj_id;
292 include_once
"./Services/Link/classes/class.ilLink.php";
298 $all_status = array_merge(array(
"mem_cnt"), $this->status);
300 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
302 $month =
"month_" . $item[
"yyyy"] .
"-" . str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
304 foreach ($all_status as
$status) {
306 if ($status !=
"mem_cnt") {
307 $field = $this->status_map[
$status];
312 foreach ($this->types as
$type) {
313 $value = $item[$field .
"_" .
$type];
314 $idx = $item[
"yyyy"] .
"-" . str_pad($item[
"mm"], 2,
"0", STR_PAD_LEFT);
315 $data[$status .
"_" .
$type][
"month_" . $idx] = $value;
323 foreach (array_keys(
$data) as $figure) {
324 $status = substr($figure, 0, -4);
325 $type = substr($figure, -3);
331 $icon = $icons->renderIconForStatus((
int) $status);
332 $text =
$icon .
" " . $text;
334 $text = $this->lng->txt(
"members");
336 if (
$type !=
"avg") {
337 $caption = $text .
" " . $this->lng->txt(
"trac_object_stat_lp_" .
$type);
339 $caption = $text .
" Ø";
341 $data[$figure][
"figure"] = $caption;
349 foreach ($this->types as
$type) {
350 $a_row[
"mem_cnt_" .
$type] = null;
352 foreach ($this->status as
$status) {
353 foreach ($this->types as $type) {
354 $a_row[$status .
"_" .
$type] = null;
366 $ilCtrl = $DIC[
'ilCtrl'];
368 if (!$this->is_details) {
372 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
373 $ilCtrl->setParameter($this->parent_obj,
"item_id", $a_set[
"obj_id"]);
374 $url = $ilCtrl->getLinkTarget($this->parent_obj,
"showLearningProgressDetails");
375 $a_set[
"title"] .=
" (<a href=\"#\" onclick=\"ilObjStat.showLPDetails(event, '" .
$url .
"');\">Details</a>)";
376 $ilCtrl->setParameter($this->parent_obj,
"item_id",
"");
379 $this->tpl->setCurrentBlock(
"checkbox");
380 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
382 $this->tpl->setVariable(
"ICON_ALT", $this->lng->txt(
$type));
383 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
384 if ($this->preselected && in_array($a_set[
"obj_id"], $this->preselected)) {
385 $this->tpl->setVariable(
"CHECKBOX_STATE",
" checked=\"checked\"");
387 $this->tpl->parseCurrentBlock();
389 $this->tpl->setCurrentBlock(
"details");
390 $this->tpl->setVariable(
"TXT_FIGURE", $a_set[
"figure"]);
391 $this->tpl->parseCurrentBlock();
394 $this->tpl->setCurrentBlock(
"item");
396 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
399 $this->tpl->setVariable(
"ITEM_VALUE", $value);
400 $this->tpl->parseCurrentBlock();
403 foreach ($this->types as
$type) {
404 $this->tpl->setVariable(
"ITEM_VALUE", $this->
anonymizeValue((
int) $a_set[
"mem_cnt_" . $type]));
405 $this->tpl->parseCurrentBlock();
407 foreach ($this->status as
$status) {
408 foreach ($this->types as $type) {
409 $this->tpl->setVariable(
"ITEM_VALUE", $this->
anonymizeValue((
int) $a_set[$status .
"_" . $type]));
410 $this->tpl->parseCurrentBlock();
422 $a_graph_items = array(array_pop($a_graph_items));
424 include_once
"Services/Chart/classes/class.ilChart.php";
426 $chart->setsize(700, 500);
429 $chart->setLegend($legend);
432 $custom_order = array(
439 $chart->setColors(array());
442 foreach ($this->chart_data as $object_id => $days) {
443 if (in_array($object_id, $a_graph_items)) {
445 foreach ($custom_order as
$status => $colors) {
463 $chart_colors[] = $colors[0];
465 $chart->setColors($chart_colors);
467 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
468 $x_axis = $this->lng->txt(
"month");
472 for ($loop = 1; $loop < 32; $loop++) {
473 $item_day = $month .
"-" . str_pad($loop, 2,
"0", STR_PAD_LEFT);
474 foreach (array_keys($custom_order) as
$status) {
475 if (isset($days[$item_day])) {
477 $value = (int) $days[$item_day][$this->status_map[$status] .
"_avg"];
481 $max_value = max($max_value, $value);
483 $series[
$status]->addPoint($counter, $value);
489 $x_axis = $this->lng->txt(
"day");
490 for ($loop = 1; $loop < 32; $loop++) {
491 foreach (array_keys($custom_order) as
$status) {
492 if (isset($days[$loop])) {
494 $value = (int) $days[$loop][$this->status_map[$status] .
"_avg"];
498 $max_value = max($max_value, $value);
500 $series[
$status]->addPoint($loop, $value);
505 foreach (array_keys($custom_order) as
$status) {
506 $chart->addData($series[$status]);
514 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
517 $labels[$counter] = $caption;
521 for ($loop = 1; $loop < 32; $loop++) {
522 $labels[$loop] = $loop .
".";
525 $chart->setTicks($labels, $value_ticks,
true);
527 return $chart->getHTML();
536 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
538 include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
541 $tpl->addJavascript(
"./Services/Tracking/js/ilObjStat.js");
const LP_STATUS_COMPLETED_NUM
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
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
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static _lookupTitle($a_id)
lookup object title
getGraph(array $a_graph_items)
static initPanel($a_resize=false, ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel.
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.
numericOrdering($a_field)
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.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
getMonthsFilter($a_short=false)
__construct(Container $dic, ilPlugin $plugin)
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)
setEnableHeader($a_enableheader)
Set Enable Header.
TableGUI class for learning progress.
getCurrentFilter($as_query=false)
setEnableTitle($a_enabletitle)
Set Enable Title.
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.