Skip to content

Commit b191e0b

Browse files
matheuszychthojou
authored andcommitted
Shows anonymous username in participants table when test is anonymous
1 parent 09184e6 commit b191e0b

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,16 @@ public function isScoringFinalized(): bool
243243
return $this->scoring_finalized;
244244
}
245245

246-
public function getDisplayName(Language $language): string
246+
public function getDisplayName(Language $language, bool $anonymous_test = false): string
247247
{
248+
if ($this->user_id === ANONYMOUS_USER_ID && $this->importname !== null && $this->importname !== '') {
249+
return "{$this->importname} ({$language->txt('imported')})";
250+
}
251+
252+
if ($anonymous_test) {
253+
return $language->txt('anonymous');
254+
}
255+
248256
$display_name = '';
249257

250258
if ($this->firstname) {
@@ -254,8 +262,6 @@ public function getDisplayName(Language $language): string
254262
$display_name .= $this->lastname;
255263
}
256264

257-
return $this->user_id === ANONYMOUS_USER_ID && $this->importname !== null && $this->importname !== ''
258-
? "{$this->importname} ({$language->txt('imported')})"
259-
: $display_name;
265+
return $display_name;
260266
}
261267
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getRows(
108108
$total_duration = $record->getTotalDuration($processing_time);
109109
$status_of_attempt = $record->getAttemptOverviewInformation()?->getStatusOfAttempt() ?? StatusOfAttempt::NOT_YET_STARTED;
110110
$row = [
111-
'name' => $record->getDisplayName($this->lng),
111+
'name' => $record->getDisplayName($this->lng, $this->test_object->getAnonymity()),
112112
'login' => $record->getLogin(),
113113
'matriculation' => $record->getMatriculation(),
114114
'total_time_on_task' => $record->getAttemptOverviewInformation()?->getHumanReadableTotalTimeOnTask() ?? '',

0 commit comments

Comments
 (0)