Skip to content

Commit e99c9e2

Browse files
committed
[FIX] #47263 LTI: Table pagination and filter fixes
- Add pagination support with withRange() - Fix inverted with_key filter (filter and display now use consistent negation)
1 parent 22059dc commit e99c9e2

7 files changed

+38
-13
lines changed

components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerAdministrationGUI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected function showGlobalProviderCmd(): void
162162
$providerList->setKeywordFilter($filter_params['keywords'] ?? '');
163163
$providerList->setHasOutcomeFilter(($filter_params['outcome'] ?? '') === '' ? null : $filter_params['outcome'] === 'yes');
164164
$providerList->setIsExternalFilter(($filter_params['internal'] ?? '') === '' ? null : $filter_params['internal'] !== 'yes');
165-
$providerList->setIsProviderKeyCustomizableFilter(($filter_params['with_key'] ?? '') === '' ? null : $filter_params['with_key'] === 'yes');
165+
$providerList->setIsProviderKeyCustomizableFilter(($filter_params['with_key'] ?? '') === '' ? null : !($filter_params['with_key'] === 'yes'));
166166
$providerList->setCategoryFilter($filter_params['category'] ?? '');
167167

168168
$providerList->load();
@@ -444,7 +444,7 @@ protected function showUserProviderCmd(): void
444444
$providerList->setKeywordFilter($filter_params['keywords'] ?? '');
445445
$providerList->setHasOutcomeFilter(($filter_params['outcome'] ?? '') === '' ? null : $filter_params['outcome'] === 'yes');
446446
$providerList->setIsExternalFilter(($filter_params['internal'] ?? '') === '' ? null : $filter_params['internal'] !== 'yes');
447-
$providerList->setIsProviderKeyCustomizableFilter(($filter_params['with_key'] ?? '') === '' ? null : $filter_params['with_key'] === 'yes');
447+
$providerList->setIsProviderKeyCustomizableFilter(($filter_params['with_key'] ?? '') === '' ? null : !($filter_params['with_key'] === 'yes'));
448448
$providerList->setCategoryFilter($filter_params['category'] ?? '');
449449

450450
$providerList->load();

components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerGradeSynchronizationTableGUI.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getRows(
6666
mixed $filter_data,
6767
mixed $additional_parameters
6868
): Generator {
69-
$records = $this->applyOrdering($this->records, $order);
69+
$records = $this->applyOrdering($this->records, $order, $range);
7070
foreach ($records as $record) {
7171
$record['lti_timestamp'] = new DateTimeImmutable($record['lti_timestamp']);
7272
$record['score_given'] = $record['score_given'] . ' / ' . $record['score_maximum'];
@@ -91,7 +91,7 @@ public function setRecords(array $records): void
9191
$this->records = $records;
9292
}
9393

94-
protected function applyOrdering(array $records, Order $order): array
94+
protected function applyOrdering(array $records, Order $order, ?Range $range = null): array
9595
{
9696
[$order_field, $order_direction] = $order->join(
9797
[],
@@ -116,6 +116,10 @@ protected function applyOrdering(array $records, Order $order): array
116116
$records = array_reverse($records);
117117
}
118118

119+
if ($range !== null) {
120+
$records = array_slice($records, $range->getStart(), $range->getLength());
121+
}
122+
119123
return $records;
120124
}
121125

@@ -124,6 +128,7 @@ public function getHTML(): string
124128
$table = $this->ui_factory->table()
125129
->data($this, "", $this->getColumns())
126130
->withOrder(new Order("lti_timestamp", Order::DESC))
131+
->withRange(new Range(0, 20))
127132
->withRequest($this->request);
128133

129134
return $this->ui_renderer->render($table);

components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerProviderSelectionFormTableGUI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct(string $newType, ilObjLTIConsumerGUI $parentGui, str
5757
$providerList->setKeywordFilter($filter_params['keywords'] ?? '');
5858
$providerList->setHasOutcomeFilter(($filter_params['outcome'] ?? '') === '' ? null : $filter_params['outcome'] === 'yes');
5959
$providerList->setIsExternalFilter(($filter_params['internal'] ?? '') === '' ? null : $filter_params['internal'] !== 'yes');
60-
$providerList->setIsProviderKeyCustomizableFilter(($filter_params['with_key'] ?? '') === '' ? null : $filter_params['with_key'] === 'yes');
60+
$providerList->setIsProviderKeyCustomizableFilter(($filter_params['with_key'] ?? '') === '' ? null : !($filter_params['with_key'] === 'yes'));
6161
$providerList->setCategoryFilter($filter_params['category'] ?? '');
6262

6363
$providerList->load();

components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerProviderTableGUI.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getRows(
104104
mixed $filter_data,
105105
mixed $additional_parameters
106106
): Generator {
107-
$records = $this->applyOrdering($this->records, $order);
107+
$records = $this->applyOrdering($this->records, $order, $range);
108108
foreach ($records as $record) {
109109
$record["icon"] = $record["icon"] ?? "lti";
110110
$record["icon"] = $this->ui_factory->symbol()->icon()->standard($record["icon"], $record["icon"], IconAlias::SMALL);
@@ -144,7 +144,7 @@ public function setData(array $data): void
144144
$this->records = $data;
145145
}
146146

147-
protected function applyOrdering(array $records, Order $order): array
147+
protected function applyOrdering(array $records, Order $order, ?Range $range = null): array
148148
{
149149
[$order_field, $order_direction] = $order->join(
150150
[],
@@ -161,6 +161,10 @@ protected function applyOrdering(array $records, Order $order): array
161161
$records = array_reverse($records);
162162
}
163163

164+
if ($range !== null) {
165+
$records = array_slice($records, $range->getStart(), $range->getLength());
166+
}
167+
164168
return $records;
165169
}
166170

@@ -172,6 +176,7 @@ public function getHTML(bool $hasWriteAccess = false): string
172176
$table = $this->ui_factory->table()
173177
->data($this, $this->lng->txt('tbl_provider_header'), $this->getColumns())
174178
->withOrder(new Order('title', Order::ASC))
179+
->withRange(new Range(0, 20))
175180
->withRequest($this->request);
176181

177182
if ($hasWriteAccess) {

components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerProviderUsageTableGUI.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getRows(
6767
/** @var Services $static_url */
6868
$static_url = $DIC["static_url"];
6969

70-
$records = $this->applyOrdering($this->records, $order);
70+
$records = $this->applyOrdering($this->records, $order, $range);
7171
foreach ($records as $record) {
7272
$record['icon'] = $record['icon'] ?? "lti";
7373
$record['icon'] = $this->ui_factory->symbol()->icon()->standard($record['icon'], $record['icon'], Icon::SMALL);
@@ -99,7 +99,7 @@ public function setData(array $data): void
9999
$this->records = $data;
100100
}
101101

102-
protected function applyOrdering(array $records, Order $order): array
102+
protected function applyOrdering(array $records, Order $order, ?Range $range = null): array
103103
{
104104
[$order_field, $order_direction] = $order->join(
105105
[],
@@ -116,6 +116,10 @@ protected function applyOrdering(array $records, Order $order): array
116116
$records = array_reverse($records);
117117
}
118118

119+
if ($range !== null) {
120+
$records = array_slice($records, $range->getStart(), $range->getLength());
121+
}
122+
119123
return $records;
120124
}
121125

@@ -124,6 +128,7 @@ public function getHTML(): string
124128
$table = $this->ui_factory->table()
125129
->data($this, $this->lng->txt('tbl_provider_usage_header'), $this->getColumns())
126130
->withOrder(new Order('title', Order::ASC))
131+
->withRange(new Range(0, 20))
127132
->withRequest($this->request);
128133

129134
return $this->ui_renderer->render($table);

components/ILIAS/LTIProvider/classes/Consumer/class.ilObjectConsumerTableGUI.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function getRows(
176176
mixed $filter_data,
177177
mixed $additional_parameters
178178
): Generator {
179-
$records = $this->applyOrdering($this->records, $order);
179+
$records = $this->applyOrdering($this->records, $order, $range);
180180
foreach ($records as $record) {
181181
$record["active"] = $this->ui_factory->symbol()->icon()->custom(
182182
$record["active"] ?
@@ -221,6 +221,7 @@ public function getHtml(): string
221221
$table = $this->ui_factory->table()
222222
->data($this, $this->lng->txt('lti_object_consumer'), $this->getColumns())
223223
->withOrder(new Order('title', Order::ASC))
224+
->withRange(new Range(0, 20))
224225
->withActions($this->getActions())
225226
->withRequest($this->request);
226227

@@ -237,7 +238,7 @@ public function setEditable(bool $a_editable): void
237238
$this->editable = $a_editable;
238239
}
239240

240-
protected function applyOrdering(array $records, Order $order): array
241+
protected function applyOrdering(array $records, Order $order, ?Range $range = null): array
241242
{
242243
[$order_field, $order_direction] = $order->join(
243244
[],
@@ -254,6 +255,10 @@ protected function applyOrdering(array $records, Order $order): array
254255
$records = array_reverse($records);
255256
}
256257

258+
if ($range !== null) {
259+
$records = array_slice($records, $range->getStart(), $range->getLength());
260+
}
261+
257262
return $records;
258263
}
259264
}

components/ILIAS/LTIProvider/classes/InternalProvider/class.ilLTIProviderReleasedObjectsTableGUI.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function getRows(
118118
/** @var Services $static_url */
119119
$static_url = $DIC["static_url"];
120120

121-
$records = $this->applyOrdering($this->records, $order);
121+
$records = $this->applyOrdering($this->records, $order, $range);
122122
foreach ($records as $record) {
123123
$link = (string) $static_url->builder()->build(
124124
$record['type'],
@@ -150,6 +150,7 @@ public function getHtml(): string
150150
$table = $this->ui_factory->table()
151151
->data($this, $this->lng->txt('lti_released_objects'), $this->getColumns())
152152
->withOrder(new Order('title', Order::ASC))
153+
->withRange(new Range(0, 20))
153154
->withRequest($this->request);
154155

155156
return $this->ui_renderer->render($table);
@@ -160,7 +161,7 @@ public function getId(): string
160161
return $this->id;
161162
}
162163

163-
protected function applyOrdering(array $records, Order $order): array
164+
protected function applyOrdering(array $records, Order $order, ?Range $range = null): array
164165
{
165166
[$order_field, $order_direction] = $order->join(
166167
[],
@@ -177,6 +178,10 @@ protected function applyOrdering(array $records, Order $order): array
177178
$records = array_reverse($records);
178179
}
179180

181+
if ($range !== null) {
182+
$records = array_slice($records, $range->getStart(), $range->getLength());
183+
}
184+
180185
return $records;
181186
}
182187
}

0 commit comments

Comments
 (0)