19declare(strict_types=1);
38 protected readonly UIFactory $ui_factory,
39 protected readonly UIRenderer $ui_renderer,
40 protected readonly DataFactory $data_factory,
48 $column_factory = $this->ui_factory->table()->column();
49 $iconActor = $this->ui_factory->symbol()->icon()->standard(Icon::USR,
'me');
52 'is_actor' => $column_factory->boolean(
'', $iconActor,
''),
53 'rank' => $column_factory->text($this->
lng->txt(
'toplist_col_rank')),
54 'participant' => $column_factory->text($this->
lng->txt(
'toplist_col_participant')),
55 'achieved' => $column_factory->date(
56 $this->
lng->txt(
'toplist_col_achieved'),
57 $this->data_factory->dateFormat()->withTime24($this->data_factory->dateFormat()->standard())
59 'score' => $column_factory->text($this->
lng->txt(
'toplist_col_score')),
60 'percentage' => $column_factory->number($this->
lng->txt(
'toplist_col_percentage'))->withUnit(
'%'),
61 'workingtime' => $column_factory->text($this->
lng->txt(
'toplist_col_wtime')),
65 'achieved' => $this->test_obj->getHighscoreAchievedTS(),
66 'score' => $this->test_obj->getHighscoreScore(),
67 'percentage' => $this->test_obj->getHighscorePercentage(),
68 'workingtime' => $this->test_obj->getHighscoreWTime()
72 foreach ($columns as $key => $column) {
73 if (isset($optional_columns[$key]) && !$optional_columns[$key]) {
76 $list[$key] = $column->withIsOptional(
false,
true)->withIsSortable(
false);
83 array $visible_column_ids,
86 mixed $additional_viewcontrol_data,
88 mixed $additional_parameters
93 if (isset($row[
'tstamp']) && in_array(
'achieved', $visible_column_ids,
true)) {
94 $item[
'achieved'] = new \DateTimeImmutable(
'@' . $row[
'tstamp']);
96 if (isset($row[
'reached_points']) && in_array(
'score', $visible_column_ids,
true)) {
97 $item[
'score'] = $row[
'reached_points'] .
' / ' . $row[
'max_points'];
99 if (isset($row[
'percentage']) && in_array(
'percentage', $visible_column_ids,
true)) {
100 $item[
'percentage'] = $row[
'percentage'];
102 if (isset($row[
'workingtime']) && in_array(
'workingtime', $visible_column_ids,
true)) {
103 $item[
'workingtime'] = $this->
formatTime($row[
'workingtime']);
106 yield $row_builder->
buildDataRow((
string) $row[
'rank'], $item);
111 mixed $additional_viewcontrol_data,
113 mixed $additional_parameters
121 if ($this->list_type === TopListType::GENERAL) {
122 return $this->
repository->getGeneralToplist($this->test_obj, $this->order_by);
125 if ($this->order_by === TopListOrder::BY_SCORE) {
126 return $this->
repository->getUserToplistByPercentage($this->test_obj, $this->
user->getId());
129 return $this->
repository->getUserToplistByWorkingtime($this->test_obj, $this->
user->getId());
134 $hours = intdiv($seconds, 3600);
135 $minutes = intdiv($seconds % 3600, 60);
136 $seconds = $seconds % 60;
138 return sprintf(
'%02d:%02d:%02d', $hours, $minutes, $seconds);
143 if ($row[
'rank'] ===
'...') {
151 'rank' =>
"{$row['rank']}.",
152 'participant' => $this->test_obj->isHighscoreAnon() && (
int) $row[
'usr_id'] !== $this->
user->getId()
154 : $row[
'lastname'] .
', ' . $row[
'firstname'],
155 'is_actor' => isset($row[
'usr_id']) && ((
int) $row[
'usr_id'] === $this->
user->getId())
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
buildBasicItemFromRowArray(array $row)
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...
__construct(protected readonly \ilObjTest $test_obj, protected readonly TestTopListRepository $repository, protected readonly \ilLanguage $lng, protected readonly \ilObjUser $user, protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly DataFactory $data_factory, protected readonly TopListType $list_type, protected readonly TopListOrder $order_by)
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....
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes the specific behavior of an ILIAS standard icon.
buildDataRow(string $id, array $record)
An entity that renders components to a string output.