Skip to content

Commit 699183e

Browse files
committed
Test: Fix Participant Table With Anoynmous Ids
See: https://mantis.ilias.de/view.php?id=47430
1 parent 7b60b2b commit 699183e

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

components/ILIAS/Test/src/Participants/ParticipantTable.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ public function getRows(
160160
}
161161

162162
yield $this->table_actions->onDataRow(
163-
$row_builder->buildDataRow((string) $record->getUserId(), $row),
163+
$row_builder->buildDataRow(
164+
"{$record->getUserId()}_{$record->getActiveId()}",
165+
$row
166+
),
164167
$record
165168
);
166169
}

components/ILIAS/Test/src/Participants/ParticipantTableActions.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,10 @@ protected function submit(
197197
);
198198
}
199199

200-
protected function resolveSelectedParticipants(TableAction $action, array|string $selected_participants): array
201-
{
200+
protected function resolveSelectedParticipants(
201+
TableAction $action,
202+
array|string $selected_participants
203+
): array {
202204
if ($selected_participants === 'ALL_OBJECTS') {
203205
return array_filter(
204206
iterator_to_array($this->repository->getParticipants($this->test_obj->getTestId())),
@@ -212,7 +214,25 @@ protected function resolveSelectedParticipants(TableAction $action, array|string
212214

213215
return array_filter(
214216
array_map(
215-
fn(int $user_id): ?Participant => $this->repository->getParticipantByUserId($this->test_obj->getTestId(), $user_id),
217+
function (string $ids_string): ?Participant {
218+
[$user_id, $active_id] = array_map(
219+
'intval',
220+
explode('_', $ids_string)
221+
);
222+
223+
if ($user_id === ANONYMOUS_USER_ID) {
224+
return $this->repository->getParticipantByActiveId(
225+
$this->test_obj->getTestId(),
226+
$active_id
227+
);
228+
}
229+
230+
return $this->repository->getParticipantByUserId(
231+
$this->test_obj->getTestId(),
232+
$user_id
233+
);
234+
235+
},
216236
$selected_participants
217237
),
218238
static fn(?Participant $participant): bool => $participant instanceof Participant && $action->allowActionForRecord($participant)

components/ILIAS/Test/src/RequestDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ public function getMultiSelectionIds(string $key): array|string
207207
return $query->retrieve(
208208
$key,
209209
$this->refinery->custom()->transformation(
210-
static fn(array|string $value): array|string => $value === 'ALL_OBJECTS' || $value[0] === 'ALL_OBJECTS'
210+
static fn($v): array|string => $v === 'ALL_OBJECTS' || $v[0] === 'ALL_OBJECTS'
211211
? 'ALL_OBJECTS'
212-
: array_map('intval', $value)
212+
: $v
213213
)
214214
);
215215
}

0 commit comments

Comments
 (0)