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,
87 ?array $additional_parameters
92 if (isset($row[
'tstamp']) && in_array(
'achieved', $visible_column_ids,
true)) {
93 $item[
'achieved'] = new \DateTimeImmutable(
'@' . $row[
'tstamp']);
95 if (isset($row[
'reached_points']) && in_array(
'score', $visible_column_ids,
true)) {
96 $item[
'score'] = $row[
'reached_points'] .
' / ' . $row[
'max_points'];
98 if (isset($row[
'percentage']) && in_array(
'percentage', $visible_column_ids,
true)) {
99 $item[
'percentage'] = $row[
'percentage'];
101 if (isset($row[
'workingtime']) && in_array(
'workingtime', $visible_column_ids,
true)) {
102 $item[
'workingtime'] = $this->
formatTime($row[
'workingtime']);
105 yield $row_builder->
buildDataRow((
string) $row[
'rank'], $item);
117 if ($this->list_type === TopListType::GENERAL) {
118 return $this->
repository->getGeneralToplist($this->test_obj, $this->order_by);
121 if ($this->order_by === TopListOrder::BY_SCORE) {
122 return $this->
repository->getUserToplistByPercentage($this->test_obj, $this->
user->getId());
125 return $this->
repository->getUserToplistByWorkingtime($this->test_obj, $this->
user->getId());
130 $hours = intdiv($seconds, 3600);
131 $minutes = intdiv($seconds % 3600, 60);
132 $seconds = $seconds % 60;
134 return sprintf(
'%02d:%02d:%02d', $hours, $minutes, $seconds);
139 if ($row[
'rank'] ===
'...') {
147 'rank' =>
"{$row['rank']}.",
148 'participant' => $this->test_obj->isHighscoreAnon() && (
int) $row[
'usr_id'] !== $this->
user->getId()
150 : $row[
'lastname'] .
', ' . $row[
'firstname'],
151 '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)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
__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)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
This describes the specific behavior of an ILIAS standard icon.
buildDataRow(string $id, array $record)
An entity that renders components to a string output.