19declare(strict_types=1);
39 protected readonly UIFactory $ui_factory,
40 protected readonly UIRenderer $ui_renderer,
41 protected readonly DataFactory $data_factory,
50 $column_factory = $this->ui_factory->table()->column();
51 $iconActor = $this->ui_factory->symbol()->icon()->standard(Icon::USR,
'me');
54 'is_actor' => $column_factory->boolean(
'', $iconActor,
''),
55 'rank' => $column_factory->text($this->
lng->txt(
'toplist_col_rank')),
56 'participant' => $column_factory->text($this->
lng->txt(
'toplist_col_participant')),
57 'achieved' => $column_factory->date(
58 $this->
lng->txt(
'toplist_col_achieved'),
59 $this->data_factory->dateFormat()->withTime24($this->data_factory->dateFormat()->standard())
61 'score' => $column_factory->text($this->
lng->txt(
'toplist_col_score')),
62 'percentage' => $column_factory->number($this->
lng->txt(
'toplist_col_percentage'))->withUnit(
'%'),
63 'workingtime' => $column_factory->text($this->
lng->txt(
'toplist_col_wtime')),
67 'achieved' => $this->test_obj->getHighscoreAchievedTS(),
68 'score' => $this->test_obj->getHighscoreScore(),
69 'percentage' => $this->test_obj->getHighscorePercentage(),
70 'workingtime' => $this->test_obj->getHighscoreWTime()
74 foreach ($columns as $key => $column) {
75 if (isset($optional_columns[$key]) && !$optional_columns[$key]) {
78 $list[$key] = $column->withIsOptional(
false,
true)->withIsSortable(
false);
85 array $visible_column_ids,
88 mixed $additional_viewcontrol_data,
90 mixed $additional_parameters
95 if (isset($row[
'tstamp']) && in_array(
'achieved', $visible_column_ids,
true)) {
96 $item[
'achieved'] = new \DateTimeImmutable(
'@' . $row[
'tstamp']);
98 if (isset($row[
'reached_points']) && in_array(
'score', $visible_column_ids,
true)) {
99 $item[
'score'] = $row[
'reached_points'] .
' / ' . $row[
'max_points'];
101 if (isset($row[
'percentage']) && in_array(
'percentage', $visible_column_ids,
true)) {
102 $item[
'percentage'] = $row[
'percentage'];
104 if (isset($row[
'workingtime']) && in_array(
'workingtime', $visible_column_ids,
true)) {
105 $item[
'workingtime'] = $this->
formatTime($row[
'workingtime']);
108 yield $row_builder->
buildDataRow((
string) $row[
'rank'], $item);
113 mixed $additional_viewcontrol_data,
115 mixed $additional_parameters
123 if ($this->list_type === TopListType::GENERAL) {
124 return $this->
repository->getGeneralToplist($this->test_obj, $this->order_by);
127 if ($this->order_by === TopListOrder::BY_SCORE) {
128 return $this->
repository->getUserToplistByPercentage($this->test_obj, $this->
user->getId());
131 return $this->
repository->getUserToplistByWorkingtime($this->test_obj, $this->
user->getId());
136 $hours = intdiv($seconds, 3600);
137 $minutes = intdiv($seconds % 3600, 60);
138 $seconds = $seconds % 60;
140 return sprintf(
'%02d:%02d:%02d', $hours, $minutes, $seconds);
145 if ($row[
'rank'] ===
'...') {
153 'rank' =>
"{$row['rank']}.",
154 'participant' => $this->test_obj->isHighscoreAnon() && (
int) $row[
'usr_id'] !== $this->
user->getId()
156 : $this->participant_repository->getParticipantByActiveId($this->test_obj->getTestId(), $row[
'active_id'])->getDisplayName($this->
lng),
157 '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, protected readonly ParticipantRepository $participant_repository)
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.