ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLTIConsumerGradeSynchronizationTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26
36{
37 protected ilLanguage $lng;
39 protected \ILIAS\UI\Renderer $ui_renderer;
40 protected $request;
41 protected bool $isMultiActorReport;
42 private array $records = [];
43
44 public function __construct(bool $isMultiActorReport)
45 {
46 global $DIC;
47
48 $this->isMultiActorReport = $isMultiActorReport;
49
50 $this->lng = $DIC->language();
51 $this->ui_factory = $DIC->ui()->factory();
52 $this->ui_renderer = $DIC->ui()->renderer();
53 $this->request = $DIC->http()->request();
54
55 }
56
60 public function getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters): Generator
61 {
62 foreach ($this->records as $record) {
63 $record['lti_timestamp'] = new DateTimeImmutable($record['lti_timestamp']);
64 $record['score_given'] = $record['score_given'] . ' / ' . $record['score_maximum'];
65 $record['activity_progress'] = $this->lng->txt('grade_activity_progress_' . strtolower($record['activity_progress']));
66 $record['grading_progress'] = $this->lng->txt('grade_grading_progress_' . strtolower($record['grading_progress']));
67 $record['stored'] = new DateTimeImmutable($record['stored']);
68
69 yield $row_builder->buildDataRow((string) $record['id'], $record);
70 }
71 }
72
73 public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?int
74 {
75 return count($this->records);
76 }
77
78 public function setRecords(array $records): void
79 {
80 $this->records = $records;
81 }
82
83 public function getHTML(): string
84 {
85 $table = $this->ui_factory->table()
86 ->data("", $this->getColumns(), $this)
87 ->withOrder(new Order("lti_timestamp", Order::DESC))
88 ->withRequest($this->request);
89
90 return $this->ui_renderer->render($table);
91 }
92
93 private function getColumns(): array
94 {
95 global $DIC;
96 $df = new \ILIAS\Data\Factory();
97
98
99 return [
100 "lti_timestamp" => $this->ui_factory->table()->column()->date($this->lng->txt('tbl_grade_date'), $df->dateFormat()->withTime24($DIC->user()->getDateFormat())),
101 "actor" => $this->ui_factory->table()->column()->text($this->lng->txt('tbl_grade_actor')),
102 "score_given" => $this->ui_factory->table()->column()->text($this->lng->txt('tbl_grade_score')),
103 "activity_progress" => $this->ui_factory->table()->column()->text($this->lng->txt('tbl_grade_activity_progress')),
104 "grading_progress" => $this->ui_factory->table()->column()->text($this->lng->txt('tbl_grade_grading_progress')),
105 "stored" => $this->ui_factory->table()->column()->date($this->lng->txt('tbl_grade_stored'), $df->dateFormat()->withTime24($DIC->user()->getDateFormat()))
106 ];
107 }
108}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
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
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...
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
language handling
buildDataRow(string $id, array $record)
This is how the factory for UI elements looks.
Definition: Factory.php:38
global $DIC
Definition: shib_login.php:26