From 4c7eba6745615227be808e7448d90b02d048482e Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Mon, 16 Mar 2026 08:43:39 +0100 Subject: [PATCH] Shows anonymous username in participants table when test is anonymous --- .../ILIAS/Test/src/Participants/Participant.php | 14 ++++++++++---- .../Test/src/Participants/ParticipantTable.php | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/components/ILIAS/Test/src/Participants/Participant.php b/components/ILIAS/Test/src/Participants/Participant.php index 4d0c0bcd719a..21bf4258b985 100644 --- a/components/ILIAS/Test/src/Participants/Participant.php +++ b/components/ILIAS/Test/src/Participants/Participant.php @@ -243,8 +243,16 @@ public function isScoringFinalized(): bool return $this->scoring_finalized; } - public function getDisplayName(Language $language): string + public function getDisplayName(Language $language, bool $anonymous_test = false): string { + if ($this->user_id === ANONYMOUS_USER_ID && $this->importname !== null && $this->importname !== '') { + return "{$this->importname} ({$language->txt('imported')})"; + } + + if ($anonymous_test) { + return $language->txt('anonymous'); + } + $display_name = ''; if ($this->firstname) { @@ -254,8 +262,6 @@ public function getDisplayName(Language $language): string $display_name .= $this->lastname; } - return $this->user_id === ANONYMOUS_USER_ID && $this->importname !== null && $this->importname !== '' - ? "{$this->importname} ({$language->txt('imported')})" - : $display_name; + return $display_name; } } diff --git a/components/ILIAS/Test/src/Participants/ParticipantTable.php b/components/ILIAS/Test/src/Participants/ParticipantTable.php index 1d75ea633f72..7e623f0ec21d 100644 --- a/components/ILIAS/Test/src/Participants/ParticipantTable.php +++ b/components/ILIAS/Test/src/Participants/ParticipantTable.php @@ -108,7 +108,7 @@ public function getRows( $total_duration = $record->getTotalDuration($processing_time); $status_of_attempt = $record->getAttemptOverviewInformation()?->getStatusOfAttempt() ?? StatusOfAttempt::NOT_YET_STARTED; $row = [ - 'name' => $record->getDisplayName($this->lng), + 'name' => $record->getDisplayName($this->lng, $this->test_object->getAnonymity()), 'login' => $record->getLogin(), 'matriculation' => $record->getMatriculation(), 'total_time_on_task' => $record->getAttemptOverviewInformation()?->getHumanReadableTotalTimeOnTask() ?? '',