ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
DataRetrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
24use ilCtrl;
26use ilDateTime;
34use ilSCGroup;
35use ilSCGroups;
36use ilSCTasks;
37
39{
40 /* @var ilSCGroup[] */
41 protected array $groups;
42
43 public function __construct(
44 protected readonly UIServices $ui,
45 protected readonly ilCtrl $ctrl
46 ) {
47 }
48
52 final protected function getSCGroups(): array
53 {
54 return $this->groups ??= ilSCGroups::getInstance()->getGroups();
55 }
56
57 final public function getRows(
58 DataRowBuilder $row_builder,
59 array $visible_column_ids,
61 Order $order,
62 mixed $additional_viewcontrol_data,
63 mixed $filter_data,
64 mixed $additional_parameters
65 ): Generator {
66 [$column_name, $direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
67 $titles = $descriptions = $last_updates = $complete = $failed = [];
68 foreach ($this->getSCGroups() as $group) {
70 $titles[$group->getId()] = $task_gui->getGroupTitle();
71 $descriptions[$group->getId()] = $task_gui->getGroupDescription();
72 $complete[$group->getId()] = ilSCTasks::lookupCompleted($group->getId());
73 $failed[$group->getId()] = ilSCTasks::lookupFailed($group->getId());
74 $last_updates[$group->getId()] = ilSCTasks::lookupLastUpdate($group->getId());
75 }
76 $comparator = match ($column_name) {
77 Handler::TABLE_COL_TITLE => function (ilSCGroup $f1, ilSCGroup $f2) use ($titles) {
78 return strcasecmp($titles[$f1->getId()], $titles[$f2->getId()]);
79 },
80 Handler::TABLE_COL_DESCRIPTION => function (ilSCGroup $f1, ilSCGroup $f2) use ($descriptions) {
81 return strcasecmp($descriptions[$f1->getId()], $descriptions[$f2->getId()]);
82 },
83 Handler::TABLE_COL_LAST_UPDATE => function (ilSCGroup $f1, ilSCGroup $f2) use ($last_updates) {
84 if (ilDateTime::_equals($last_updates[$f1->getId()], $last_updates[$f2->getId()])) {
85 return 0;
86 }
87 return ilDateTime::_before($last_updates[$f1->getId()], $last_updates[$f2->getId()]) ? -1 : 1;
88 },
89 Handler::TABLE_COL_SOLVED_TASKS => function (ilSCGroup $f1, ilSCGroup $f2) use ($complete) {
90 return $complete[$f1->getId()] - $complete[$f2->getId()];
91 },
92 Handler::TABLE_COL_UNSOLVED_TASKS => function (ilSCGroup $f1, ilSCGroup $f2) use ($failed) {
93 return $failed[$f1->getId()] - $failed[$f2->getId()];
94 },
95 default => fn(ilSCGroup $f1, ilSCGroup $f2) => 0
96 };
97 $sc_groups = $this->getSCGroups();
98 uasort($sc_groups, $comparator);
99 if ($direction === "DESC") {
100 $sc_groups = array_reverse($sc_groups, true);
101 }
102 $sc_groups = array_slice($sc_groups, $range->getStart(), $range->getLength(), true);
103 foreach ($sc_groups as $sc_group) {
104 $this->ctrl->setParameterByClass(ilObjSystemCheckGUI::class, 'grp_id', $sc_group->getId());
105 $link = $this->ctrl->getLinkTargetByClass(ilObjSystemCheckGUI::class, 'showGroup');
106 $this->ctrl->clearParameterByClass(ilObjSystemCheckGUI::class, 'grp_id');
107 yield $row_builder->buildDataRow(
108 $sc_group->getId() . '',
109 [
110 Handler::TABLE_COL_TITLE => $this->ui->factory()->link()->standard($titles[$sc_group->getId()], $link),
111 Handler::TABLE_COL_DESCRIPTION => $descriptions[$sc_group->getId()],
112 Handler::TABLE_COL_LAST_UPDATE => ilDatePresentation::formatDate($last_updates[$sc_group->getId()]),
113 Handler::TABLE_COL_SOLVED_TASKS => $complete[$sc_group->getId()],
114 Handler::TABLE_COL_UNSOLVED_TASKS => $failed[$sc_group->getId()],
115 ]
116 );
117 }
118 }
119
120 final public function getTotalRowCount(
121 mixed $additional_viewcontrol_data,
122 mixed $filter_data,
123 mixed $additional_parameters
124 ): ?int {
125 return count($this->getSCGroups());
126 }
127}
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
__construct(protected readonly UIServices $ui, protected readonly ilCtrl $ctrl)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
Class ilCtrl provides processing control methods.
Class for date presentation.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
static getComponentTaskGUIForGroup(int $a_group_id, ?int $a_task_id=null)
Defines a system check group including different tasks of a component.
Description of class.
static getInstance()
Description of class.
static lookupLastUpdate(int $a_grp_id)
static lookupFailed(int $a_grp_id)
static lookupCompleted(int $a_grp_id)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildDataRow(string $id, array $record)