19declare(strict_types=0);
35 protected array
$types = array(
"min",
"avg",
"max");
51 ?
object $a_parent_obj,
53 ?array $a_preselect =
null,
54 bool $a_is_chart =
false,
55 bool $a_is_details =
false
59 $this->ui_factory =
$DIC->ui()->factory();
60 $this->ui_renderer =
$DIC->ui()->renderer();
62 $this->preselected = $a_preselect;
63 $this->is_chart = $a_is_chart;
64 $this->is_details = $a_is_details;
66 $this->
setId(
"lpobjstatlptbl");
70 public function init(): void
72 if (!$this->is_details) {
75 $this->
addColumn($this->
lng->txt(
"trac_title"),
"title");
78 $column_definition = $all_columns[$col_name];
80 $column_definition[
'txt'],
81 $column_definition[
'sortable'] ? $column_definition[
'field'] :
'',
82 $column_definition[
'width']
92 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
95 ) as $num => $caption) {
96 if ($this->is_details) {
99 $this->
addColumn($caption,
"month_" . $num);
103 foreach ($this->types as $type) {
104 if ($type !=
"avg") {
105 $caption =
" " . $this->
lng->txt(
106 "trac_object_stat_lp_" . $type
109 $caption =
" Ø";
112 $this->
lng->txt(
"trac_members_short") . $caption,
119 foreach ($this->status as
$status) {
122 foreach ($this->types as $type) {
123 if ($type !=
"avg") {
124 $caption =
$icon .
" " . $this->
lng->txt(
125 "trac_object_stat_lp_" . $type
128 $caption =
$icon .
" Ø";
135 if (!$this->is_details) {
136 $this->
setTitle($this->
lng->txt(
"trac_object_stat_lp"));
140 "showLearningProgressGraph",
141 $this->
lng->txt(
"trac_show_graph")
148 $this->
ctrl->getFormAction(
149 $this->getParentObject(),
150 $this->getParentCmd()
154 "tpl.lp_object_statistics_lp_row.html",
155 "components/ILIAS/Tracking"
172 if ($this->is_details) {
180 if ($this->is_details) {
184 $columns[
'obj_id'] = [
186 'txt' => $this->
lng->txt(
'object_id'),
192 $columns[
'reference_ids'] = [
193 'field' =>
'reference_ids',
194 'txt' => $this->
lng->txt(
'trac_reference_ids_column'),
200 $columns[
'paths'] = [
202 'txt' => $this->
lng->txt(
'trac_paths'),
214 $alphabetic_ordering = [
217 if (!in_array($a_field, $alphabetic_ordering)) {
237 $this->
filter[
"type"] =
"crs";
241 $this->
lng->txt(
"trac_title_description"),
244 $ti->setMaxLength(64);
247 $ti->readFromSession();
248 $this->
filter[
"query"] = $ti->getValue();
252 $this->
lng->txt(
"year") .
" / " . $this->lng->txt(
"month"),
257 $si->readFromSession();
258 if (!$si->getValue()) {
259 $si->setValue(date(
"Y-m"));
261 $this->
filter[
"yearmonth"] = $si->getValue();
263 if (!strpos($this->
filter[
"yearmonth"],
"-")) {
265 $this->
lng->txt(
"trac_figure"),
269 "mem_cnt_max" => $this->
lng->txt(
271 ) .
" " . $this->lng->txt(
"trac_object_stat_lp_max"),
272 "mem_cnt_avg" => $this->lng->txt(
"members") .
" Ø",
276 ) .
" " . $this->lng->txt(
"trac_object_stat_lp_max"),
281 $si->setOptions($options);
283 $si->readFromSession();
284 if (!$si->getValue()) {
285 $si->setValue(
"mem_cnt_max");
287 $this->
filter[
"measure"] = $si->getValue();
292 if ($this->is_details) {
293 $this->filters = array();
300 $all_status = array_merge(array(
"mem_cnt"), $this->status);
309 $objects = array_keys($objects);
311 $yearmonth = explode(
"-", $this->
filter[
"yearmonth"]);
312 if (
sizeof($yearmonth) == 1) {
317 $obj_id = $item[
"obj_id"];
318 if (!isset(
$data[$obj_id])) {
319 $data[$obj_id][
"obj_id"] = $obj_id;
325 $measure_type = substr($this->
filter[
"measure"], -3);
326 $measure_field = substr($this->
filter[
"measure"], 0, -4);
327 $value = $item[$measure_field .
"_" . $measure_type];
328 $idx = $item[
"yyyy"] .
"-" . str_pad(
334 $data[$obj_id][
"month_" . $idx] = $value;
337 if ($this->is_chart) {
342 $num_string = explode(
'-', $num);
343 $num = (
int) array_pop($num_string);
350 $idx = $yearmonth[0] .
363 $this->chart_data[$item[
"obj_id"]][$idx] = $item;
374 $obj_id = $item[
"obj_id"];
375 if (!isset(
$data[$obj_id])) {
376 $data[$obj_id][
"obj_id"] = $obj_id;
384 foreach ($all_status as
$status) {
387 $field = $this->status_map[
$status];
393 foreach ($this->types as $type) {
394 $value = $item[$field .
"_" . $type];
400 if ($this->is_chart) {
408 $this->chart_data[$item[
"obj_id"]][$item[
"dd"]] = $item;
414 foreach ($objects as $obj_id) {
415 if (!isset(
$data[$obj_id])) {
416 $data[$obj_id][
"obj_id"] = $obj_id;
428 $all_status = array_merge(array(
"mem_cnt"), $this->status);
432 $this->
filter[
"yearmonth"]
434 $month =
"month_" . $item[
"yyyy"] .
"-" . str_pad(
441 foreach ($all_status as
$status) {
444 $field = $this->status_map[
$status];
449 foreach ($this->types as $type) {
450 $value = $item[$field .
"_" . $type];
451 $idx = $item[
"yyyy"] .
"-" . str_pad(
465 foreach (array_keys(
$data) as $figure) {
466 $status = substr($figure, 0, -4);
467 $type = substr($figure, -3);
474 $text =
$icon .
" " . $text;
476 $text = $this->
lng->txt(
"members");
478 if ($type !=
"avg") {
479 $caption = $text .
" " . $this->
lng->txt(
480 "trac_object_stat_lp_" . $type
483 $caption = $text .
" Ø";
485 $data[$figure][
"figure"] = $caption;
491 protected function initRow(array &$a_row): void
493 foreach ($this->types as $type) {
494 $a_row[
"mem_cnt_" . $type] =
null;
496 foreach ($this->status as
$status) {
497 foreach ($this->types as $type) {
498 $a_row[
$status .
"_" . $type] =
null;
506 protected function fillRow(array $a_set): void
510 $ilCtrl =
$DIC[
'ilCtrl'];
512 if (!$this->is_details) {
516 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
517 $this->
ctrl->setParameter(
524 "showLearningProgressDetails"
527 $details_modal = $this->ui_factory->modal()->roundtrip(
'', [])->withAsyncRenderUrl(
$url);
528 $details_button = $this->ui_factory->button()->shy(
529 ' (' . $this->
lng->txt(
'details') .
')',
530 $details_modal->getShowSignal()
532 $a_set[
"title"] .= $this->ui_renderer->render([$details_button, $details_modal]);
533 $this->
ctrl->setParameter($this->parent_obj,
"item_id",
"");
538 $this->tpl->setVariable(
'OBJ_ID_COL_VALUE', (
string) $a_set[
'obj_id']);
541 $this->tpl->setVariable(
'REF_IDS', implode(
', ', $a_set[
'reference_ids']));
545 foreach ($a_set[
'reference_ids'] as $reference_id) {
547 $path_gui->enableTextOnly(
false);
548 $path_gui->enableHideLeaf(
false);
549 $path_gui->setUseImages(
true);
552 $this->tpl->setVariable(
'PATHS', implode(
'<br />', $paths));
554 $this->tpl->setCurrentBlock(
"checkbox");
555 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
556 $this->tpl->setVariable(
560 $this->tpl->setVariable(
"ICON_ALT", $this->
lng->txt($type));
561 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
562 if ($this->preselected && in_array(
566 $this->tpl->setVariable(
568 " checked=\"checked\""
571 $this->tpl->parseCurrentBlock();
573 $this->tpl->setCurrentBlock(
"details");
574 $this->tpl->setVariable(
"TXT_FIGURE", $a_set[
"figure"]);
575 $this->tpl->parseCurrentBlock();
578 $this->tpl->setCurrentBlock(
"item");
580 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
584 $value = $this->
anonymizeValue((
int) ($a_set[
"month_" . $num] ?? 0));
585 $this->tpl->setVariable(
"ITEM_VALUE", $value);
586 $this->tpl->parseCurrentBlock();
589 foreach ($this->types as $type) {
590 $this->tpl->setVariable(
593 (
int) ($a_set[
"mem_cnt_" . $type] ?? 0)
596 $this->tpl->parseCurrentBlock();
598 foreach ($this->status as
$status) {
599 foreach ($this->types as $type) {
600 $this->tpl->setVariable(
603 (
int) ($a_set[
$status .
"_" . $type] ?? 0)
606 $this->tpl->parseCurrentBlock();
612 public function getGraph(array $a_graph_items): string
614 $a_graph_items = array(array_pop($a_graph_items));
617 $chart->setSize(
"700",
"500");
620 $chart->setLegend($legend);
623 $custom_order = array(
634 $chart->setColors(array());
637 foreach ($this->chart_data as $object_id => $days) {
638 if (in_array($object_id, $a_graph_items)) {
640 foreach ($custom_order as
$status => $colors) {
641 $series[
$status] = $chart->getDataInstance(
647 $chart_colors[] = $colors[0];
649 $chart->setColors($chart_colors);
651 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
652 $x_axis = $this->
lng->txt(
"month");
657 $this->
filter[
"yearmonth"]
660 for ($loop = 1; $loop < 32; $loop++) {
661 $item_day = $month .
"-" . str_pad(
667 foreach (array_keys($custom_order) as
$status) {
668 if (isset($days[$item_day])) {
670 $value = (
int) $days[$item_day][$this->status_map[
$status] .
"_avg"];
674 $max_value = max($max_value, $value);
682 $x_axis = $this->
lng->txt(
"day");
683 for ($loop = 1; $loop < 32; $loop++) {
684 foreach (array_keys($custom_order) as
$status) {
685 if (isset($days[$loop])) {
687 $value = (
int) $days[$loop][$this->status_map[
$status] .
"_avg"];
691 $max_value = max($max_value, $value);
693 $series[
$status]->addPoint($loop, $value);
698 foreach (array_keys($custom_order) as
$status) {
699 $chart->addData($series[
$status]);
707 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
710 $this->
filter[
"yearmonth"],
717 for ($loop = 1; $loop < 32; $loop++) {
718 $labels[$loop] = $loop .
".";
721 $chart->setTicks($labels, $value_ticks,
true);
723 return $chart->getHTML();
Builds a Color from either hex- or rgb values.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByType(int $a_type, string $a_id)
TableGUI class for learning progress.
getGraph(array $a_graph_items)
fillRow(array $a_set)
Fill table row.
getDetailItems(int $a_obj_id)
getSelectableColumns()
Get selectable columns.
numericOrdering(string $a_field)
Should this field be sorted numeric?
isForwardingToFormDispatcher()
__construct(?object $a_parent_obj, string $a_parent_cmd, ?array $a_preselect=null, bool $a_is_chart=false, bool $a_is_details=false)
Constructor.
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
TableGUI class for learning progress.
getMonthsYear($a_year=null, $a_short=false)
anonymizeValue($a_value, bool $a_force_number=false)
initRepositoryFilter(array $filter)
findReferencesForObjId(int $a_obj_id)
getCurrentFilter(bool $as_query=false)
getMonthsFilter($a_short=false)
buildValueScale(int $a_max_value, bool $a_anonymize=false, bool $a_format_seconds=false)
searchObjects(array $filter, string $permission, ?array $preset_obj_ids=null, bool $a_check_lp_activation=true)
Search objects that match current filters.
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupTitle(int $obj_id)
isColumnSelected(string $col)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setFilterCommand(string $a_val, string $a_caption="")
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableNumInfo(bool $a_val)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setDisableFilterHiding(bool $a_val=true)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
setData(array $a_data)
Set table data.
This class represents a text property in a property form.
static getObjectLPStatistics(array $a_obj_ids, int $a_year, ?int $a_month=null, bool $a_group_by_day=false)
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)