From 8471a849d3443cdcb3d70b24a22cfb9b1952789f Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Mon, 8 Dec 2025 11:07:27 +0100 Subject: [PATCH 1/7] Fixes issue with name of user being anonymous when importing users to different system even thou test is not anonymous --- components/ILIAS/Test/src/Participants/Participant.php | 6 ++++++ .../ILIAS/Test/src/Participants/ParticipantRepository.php | 3 +++ .../ILIAS/Test/src/Participants/ParticipantTable.php | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/ILIAS/Test/src/Participants/Participant.php b/components/ILIAS/Test/src/Participants/Participant.php index 279577d0f573..07ed7e45c027 100644 --- a/components/ILIAS/Test/src/Participants/Participant.php +++ b/components/ILIAS/Test/src/Participants/Participant.php @@ -35,6 +35,7 @@ public function __construct( private readonly string $firstname = '', private readonly string $lastname = '', private readonly string $login = '', + private readonly ?string $importname = null, private readonly string $matriculation = '', private int $extra_time = 0, private readonly int $attempts = 0, @@ -86,6 +87,11 @@ public function getLogin(): string return $this->login; } + public function getImportname(): ?string + { + return $this->importname; + } + public function getMatriculation(): string { return $this->matriculation; diff --git a/components/ILIAS/Test/src/Participants/ParticipantRepository.php b/components/ILIAS/Test/src/Participants/ParticipantRepository.php index 2e0559822ca7..553b99256877 100755 --- a/components/ILIAS/Test/src/Participants/ParticipantRepository.php +++ b/components/ILIAS/Test/src/Participants/ParticipantRepository.php @@ -329,6 +329,7 @@ private function arrayToObject(array $row): Participant $row['firstname'] ?? '', $row['lastname'] ?? '', $row['login'] ?? '', + $row['importname'] ?? null, $row['matriculation'] ?? '', $row['extra_time'] ?? 0, $row['tries'] ?? 0, @@ -357,6 +358,7 @@ private function getActiveParticipantsQuery(): string ta.anonymous_id, ta.tries, ta.submitted, + ta.importname, ta.last_finished_pass, ta.last_started_pass, COALESCE(ta.last_started_pass, -1) <> COALESCE(ta.last_finished_pass, -1) as unfinished_attempts, @@ -395,6 +397,7 @@ private function getInvitedParticipantsQuery(): string ta.anonymous_id, ta.tries, ta.submitted, + ta.importname, ta.last_finished_pass, ta.last_started_pass, COALESCE(ta.last_started_pass, -1) <> COALESCE(ta.last_finished_pass, -1) as unfinished_attempts, diff --git a/components/ILIAS/Test/src/Participants/ParticipantTable.php b/components/ILIAS/Test/src/Participants/ParticipantTable.php index ff5ab5e4a9de..5ccc689bf21f 100644 --- a/components/ILIAS/Test/src/Participants/ParticipantTable.php +++ b/components/ILIAS/Test/src/Participants/ParticipantTable.php @@ -107,8 +107,13 @@ public function getRows( foreach ($this->getViewControlledRecords($filter_data, $range, $order) as $record) { $total_duration = $record->getTotalDuration($processing_time); $status_of_attempt = $record->getAttemptOverviewInformation()?->getStatusOfAttempt() ?? StatusOfAttempt::NOT_YET_STARTED; + $unmatched = $record->getUserId() === ANONYMOUS_USER_ID && $record->getImportname(); $row = [ - 'name' => $this->test_object->buildName($record->getUserId(), $record->getFirstname(), $record->getLastname()), + 'name' => $this->test_object->buildName( + $record->getUserId(), + !$unmatched ? $record->getFirstname() : '', + !$unmatched ? $record->getLastname() : "{$record->getImportname()} ({$this->lng->txt('imported')})", + ), 'login' => $record->getLogin(), 'matriculation' => $record->getMatriculation(), 'total_time_on_task' => $record->getAttemptOverviewInformation()?->getHumanReadableTotalTimeOnTask() ?? '', From ef59b6bfaec106d371235c7621fa002265a0dbcb Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Mon, 8 Dec 2025 13:36:23 +0100 Subject: [PATCH 2/7] Fixes imported name in scoring view --- components/ILIAS/Test/src/GUIFactory.php | 2 ++ .../src/Scoring/Manual/ConsecutiveScoring.php | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/components/ILIAS/Test/src/GUIFactory.php b/components/ILIAS/Test/src/GUIFactory.php index 264b3ff630c4..e4fa09551919 100644 --- a/components/ILIAS/Test/src/GUIFactory.php +++ b/components/ILIAS/Test/src/GUIFactory.php @@ -77,6 +77,8 @@ public function __construct( $this->test_dic['scoring.manual.done_helper'], $this->global_dic['ilUser'], $this->internal['test.access']($test_obj), + $this->global_dic['ilDB'], + $this->global_dic['lng'], ); $this->internal['manscoring.positionsfactory'] = fn(\ilObjTest $test_obj): PositionsFactory => diff --git a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php index ab620edd67ac..16a242dbba12 100644 --- a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php +++ b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php @@ -20,7 +20,6 @@ namespace ILIAS\Test\Scoring\Manual; -use ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository; use ILIAS\Test\Logging\TestLogger; use ILIAS\Test\Logging\TestScoringInteractionTypes; use ILIAS\Test\Logging\AdditionalInformationGenerator; @@ -37,6 +36,8 @@ public function __construct( private TestManScoringDoneHelper $scoring_done_helper, private \ilObjUser $current_user, private readonly \ilTestAccess $test_access, + private readonly \ilDBInterface $db, + private readonly \ilLanguage $lng, ) { } @@ -94,7 +95,20 @@ public function getUserFullName( ) { return \ilObjTest::buildExamId($usr_active_id, $attempt, $this->object->getId()); } - $user_id = (string) $this->object->_getUserIdFromActiveId($usr_active_id); + + $statement = $this->db->queryF( + 'SELECT importname FROM tst_active WHERE importname IS NOT NULL AND importname != "" AND user_fi = %s AND active_id = %s', + [\ilDBConstants::T_INTEGER, \ilDBConstants::T_INTEGER], + [ANONYMOUS_USER_ID, $usr_active_id] + ); + $results = $this->db->fetchAll($statement); + $importname = $results[0]['importname'] ?? null; + + if ($importname !== null && $importname !== '') { + return "{$importname} ({$this->lng->txt('imported')})"; + } + + $user_id = (string) $this->object::_getUserIdFromActiveId($usr_active_id); $user_data = $this->object->getUserData([$user_id]); $user = $user_data[$user_id]; return sprintf( From f5ae6b190f9575299ae9793ea906792b4763bc75 Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Tue, 9 Dec 2025 11:23:11 +0100 Subject: [PATCH 3/7] Adds better participant name handling --- .../classes/class.ilTestEvaluationGUI.php | 17 +++++------- .../Test/src/Participants/Participant.php | 26 +++++++++++++++++++ .../src/Participants/ParticipantTable.php | 7 +---- .../ParticipantTableDeleteResultsAction.php | 2 +- .../src/Results/Toplist/DataRetrieval.php | 3 ++- .../Results/Toplist/TestTopListRepository.php | 6 ++--- .../src/Scoring/Manual/ConsecutiveScoring.php | 14 +++------- 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php index fe52933b650e..71d78b5fae72 100755 --- a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php @@ -18,6 +18,7 @@ declare(strict_types=1); +use ILIAS\Test\Participants\Participant; use ILIAS\Test\Results\Presentation\TitlesBuilder as ResultsTitlesBuilder; use ILIAS\Test\Presentation\PrintLayoutProvider; use ILIAS\UI\Component\ViewControl\Mode as ViewControlMode; @@ -138,10 +139,7 @@ function (string $v): SubPanel { $attempt_id = ilObjTest::_getResultPass($value); $components = $this->buildAttemptComponents($value, $attempt_id, false, true); return $this->ui_factory->panel()->sub( - $this->buildResultsTitle( - ilObjUser::_lookupFullname($this->object->_getUserIdFromActiveId($value)), - $attempt_id - ), + $this->buildResultsTitle($value, $attempt_id), $components ); }, @@ -183,10 +181,7 @@ public function showResults(): void } $results_panel = $this->ui_factory->panel()->report( - $this->buildResultsTitle( - ilObjUser::_lookupFullname($this->object->_getUserIdFromActiveId($current_active_id)), - $attempt_id - ), + $this->buildResultsTitle($current_active_id, $attempt_id), $this->buildAttemptComponents($current_active_id, $attempt_id, true, false) ); @@ -327,7 +322,7 @@ public function outUserPassDetails(): void true ), $settings, - $this->buildResultsTitle($this->user->getFullname(), $pass), + $this->buildResultsTitle($active_id, $pass), false ); @@ -783,7 +778,7 @@ protected function sendPage(string $page) $this->http->close(); } - protected function buildResultsTitle(string $fullname, int $pass): string + protected function buildResultsTitle(int $active_id, int $pass): string { if ($this->object->getAnonymity()) { return sprintf( @@ -794,7 +789,7 @@ protected function buildResultsTitle(string $fullname, int $pass): string return sprintf( $this->lng->txt('tst_result_user_name_pass'), $pass + 1, - $fullname + Participant::getParticipantName($active_id) ); } diff --git a/components/ILIAS/Test/src/Participants/Participant.php b/components/ILIAS/Test/src/Participants/Participant.php index 07ed7e45c027..81eccc22ead4 100644 --- a/components/ILIAS/Test/src/Participants/Participant.php +++ b/components/ILIAS/Test/src/Participants/Participant.php @@ -241,4 +241,30 @@ public function isScoringFinalized(): bool { return $this->scoring_finalized; } + + public static function getParticipantName(int $active_id): string + { + global $DIC; + $db = $DIC->database(); + $lng = $DIC->language(); + + $user_id = \ilObjTest::_getUserIdFromActiveId($active_id); + $name = \ilObjUser::_lookupFullname($user_id); + + if ($user_id === ANONYMOUS_USER_ID) { + $statement = $db->queryF( + 'SELECT importname FROM tst_active WHERE importname IS NOT NULL AND importname != "" AND user_fi = %s AND active_id = %s', + [\ilDBConstants::T_INTEGER, \ilDBConstants::T_INTEGER], + [ANONYMOUS_USER_ID, $active_id] + ); + $results = $db->fetchAll($statement); + $importname = $results[0]['importname'] ?? null; + + if ($importname !== null && $importname !== '') { + $name = "{$importname} ({$lng->txt('imported')})"; + } + } + + return $name; + } } diff --git a/components/ILIAS/Test/src/Participants/ParticipantTable.php b/components/ILIAS/Test/src/Participants/ParticipantTable.php index 5ccc689bf21f..1b53862ad890 100644 --- a/components/ILIAS/Test/src/Participants/ParticipantTable.php +++ b/components/ILIAS/Test/src/Participants/ParticipantTable.php @@ -107,13 +107,8 @@ public function getRows( foreach ($this->getViewControlledRecords($filter_data, $range, $order) as $record) { $total_duration = $record->getTotalDuration($processing_time); $status_of_attempt = $record->getAttemptOverviewInformation()?->getStatusOfAttempt() ?? StatusOfAttempt::NOT_YET_STARTED; - $unmatched = $record->getUserId() === ANONYMOUS_USER_ID && $record->getImportname(); $row = [ - 'name' => $this->test_object->buildName( - $record->getUserId(), - !$unmatched ? $record->getFirstname() : '', - !$unmatched ? $record->getLastname() : "{$record->getImportname()} ({$this->lng->txt('imported')})", - ), + 'name' => Participant::getParticipantName($record->getActiveId()), 'login' => $record->getLogin(), 'matriculation' => $record->getMatriculation(), 'total_time_on_task' => $record->getAttemptOverviewInformation()?->getHumanReadableTotalTimeOnTask() ?? '', diff --git a/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php b/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php index 808331505d00..488b21f61875 100644 --- a/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php +++ b/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php @@ -84,7 +84,7 @@ public function getModal( (string) $v->getUserId(), $this->test_obj->getAnonymity() ? $this->lng->txt('anonymous') - : \ilObjUser::_lookupFullname($v->getUserId()) + : Participant::getParticipantName($v->getActiveId()) ), $selected_participants ) diff --git a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php index e6fe5a4b62de..2bed6481db7b 100755 --- a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php +++ b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php @@ -23,6 +23,7 @@ use ILIAS\Data\Factory as DataFactory; use ILIAS\Data\Range; use ILIAS\Data\Order; +use ILIAS\Test\Participants\Participant; use ILIAS\UI\Component\Symbol\Icon\Standard as Icon; use ILIAS\UI\Component\Table\DataRowBuilder; use ILIAS\UI\Factory as UIFactory; @@ -151,7 +152,7 @@ private function buildBasicItemFromRowArray(array $row): array 'rank' => "{$row['rank']}.", 'participant' => $this->test_obj->isHighscoreAnon() && (int) $row['usr_id'] !== $this->user->getId() ? '-, -' - : $row['lastname'] . ', ' . $row['firstname'], + : Participant::getParticipantName($row['active_id']), 'is_actor' => isset($row['usr_id']) && ((int) $row['usr_id'] === $this->user->getId()) ]; } diff --git a/components/ILIAS/Test/src/Results/Toplist/TestTopListRepository.php b/components/ILIAS/Test/src/Results/Toplist/TestTopListRepository.php index 56f350fb44d1..bc3d88bb19e5 100755 --- a/components/ILIAS/Test/src/Results/Toplist/TestTopListRepository.php +++ b/components/ILIAS/Test/src/Results/Toplist/TestTopListRepository.php @@ -32,7 +32,7 @@ public function getGeneralToplist(\ilObjTest $object, TopListOrder $order_by): \ $this->db->setLimit($object->getHighscoreTopNum(), 0); $result = $this->db->query( ' - SELECT tst_result_cache.*, round(points/maxpoints*100,2) as percentage, tst_pass_result.workingtime, usr_data.usr_id, usr_data.firstname, usr_data.lastname + SELECT tst_result_cache.*, round(points/maxpoints*100,2) as percentage, tst_pass_result.workingtime, usr_data.usr_id, usr_data.firstname, usr_data.lastname, tst_active.active_id FROM object_reference INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi @@ -107,7 +107,7 @@ public function getUserToplistByPercentage(\ilObjTest $object, int $a_user_id): $result = $this->db->query(" SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage , - tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname + tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname, tst_active.active_id FROM object_reference INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi @@ -192,7 +192,7 @@ public function getUserToplistByWorkingtime(\ilObjTest $object, int $a_user_id): $result = $this->db->query(" SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, - tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname + tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname, tst_active.active_id FROM object_reference INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi diff --git a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php index 16a242dbba12..d80d52f22e02 100644 --- a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php +++ b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php @@ -23,6 +23,7 @@ use ILIAS\Test\Logging\TestLogger; use ILIAS\Test\Logging\TestScoringInteractionTypes; use ILIAS\Test\Logging\AdditionalInformationGenerator; +use ILIAS\Test\Participants\Participant; use ILIAS\Test\TestManScoringDoneHelper; class ConsecutiveScoring @@ -96,16 +97,9 @@ public function getUserFullName( return \ilObjTest::buildExamId($usr_active_id, $attempt, $this->object->getId()); } - $statement = $this->db->queryF( - 'SELECT importname FROM tst_active WHERE importname IS NOT NULL AND importname != "" AND user_fi = %s AND active_id = %s', - [\ilDBConstants::T_INTEGER, \ilDBConstants::T_INTEGER], - [ANONYMOUS_USER_ID, $usr_active_id] - ); - $results = $this->db->fetchAll($statement); - $importname = $results[0]['importname'] ?? null; - - if ($importname !== null && $importname !== '') { - return "{$importname} ({$this->lng->txt('imported')})"; + $participant_name = Participant::getParticipantName($usr_active_id); + if (str_ends_with($participant_name, ' (imported)')) { + return $participant_name; } $user_id = (string) $this->object::_getUserIdFromActiveId($usr_active_id); From dad9e0ef8dd0af1913484df2e58d8d5fe489fa54 Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Wed, 10 Dec 2025 08:20:42 +0100 Subject: [PATCH 4/7] Implements method loadParticipantNameByActiveId --- .../classes/class.ilTestEvaluationGUI.php | 4 +-- .../Test/classes/class.ilTestResultsGUI.php | 1 + .../Test/classes/class.ilTestToplistGUI.php | 2 ++ .../Test/src/Participants/Participant.php | 35 ++++++++----------- .../src/Participants/ParticipantTable.php | 2 +- .../ParticipantTableDeleteResultsAction.php | 2 +- .../src/Results/Toplist/DataRetrieval.php | 5 +-- .../src/Scoring/Manual/ConsecutiveScoring.php | 6 ++-- .../Scoring/Toplist/DataRetrievalTest.php | 1 + .../ILIAS/Test/tests/ilTestToplistGUITest.php | 1 + 10 files changed, 30 insertions(+), 29 deletions(-) diff --git a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php index 71d78b5fae72..cec88dd9198a 100755 --- a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php @@ -18,7 +18,7 @@ declare(strict_types=1); -use ILIAS\Test\Participants\Participant; +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\Results\Presentation\TitlesBuilder as ResultsTitlesBuilder; use ILIAS\Test\Presentation\PrintLayoutProvider; use ILIAS\UI\Component\ViewControl\Mode as ViewControlMode; @@ -789,7 +789,7 @@ protected function buildResultsTitle(int $active_id, int $pass): string return sprintf( $this->lng->txt('tst_result_user_name_pass'), $pass + 1, - Participant::getParticipantName($active_id) + (new ParticipantRepository($this->db))->getParticipantByActiveId($this->object->getId(), $active_id)->getDisplayName() ); } diff --git a/components/ILIAS/Test/classes/class.ilTestResultsGUI.php b/components/ILIAS/Test/classes/class.ilTestResultsGUI.php index cea9b8df6fd5..a5503d7b32be 100755 --- a/components/ILIAS/Test/classes/class.ilTestResultsGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestResultsGUI.php @@ -149,6 +149,7 @@ public function executeCommand(): void $this->ctrl, $this->main_tpl, $this->lng, + $this->db, $this->user, $this->ui_factory, $this->ui_renderer, diff --git a/components/ILIAS/Test/classes/class.ilTestToplistGUI.php b/components/ILIAS/Test/classes/class.ilTestToplistGUI.php index 2f693af25d94..fa468acb3914 100755 --- a/components/ILIAS/Test/classes/class.ilTestToplistGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestToplistGUI.php @@ -41,6 +41,7 @@ public function __construct( protected readonly ilCtrlInterface $ctrl, protected readonly ilGlobalTemplateInterface $tpl, protected readonly ilLanguage $lng, + protected readonly ilDBInterface $db, protected readonly ilObjUser $user, protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, @@ -128,6 +129,7 @@ protected function buildTable(string $title, TopListType $list_type, TopListOrde $this->test_obj, $this->repository, $this->lng, + $this->db, $this->user, $this->ui_factory, $this->ui_renderer, diff --git a/components/ILIAS/Test/src/Participants/Participant.php b/components/ILIAS/Test/src/Participants/Participant.php index 81eccc22ead4..b8df86dbbf80 100644 --- a/components/ILIAS/Test/src/Participants/Participant.php +++ b/components/ILIAS/Test/src/Participants/Participant.php @@ -26,6 +26,7 @@ class Participant { private ?AttemptOverview $attempt_overview = null; private ?\DateTimeImmutable $running_attempt_start = null; + private readonly \ilLanguage $lng; public function __construct( private readonly int $user_id, @@ -50,6 +51,8 @@ public function __construct( private readonly ?\DateTimeImmutable $last_access = null, private readonly bool $scoring_finalized = false ) { + global $DIC; + $this->lng = $DIC->language(); } public function getUserId(): int @@ -242,29 +245,19 @@ public function isScoringFinalized(): bool return $this->scoring_finalized; } - public static function getParticipantName(int $active_id): string + public function getDisplayName(): string { - global $DIC; - $db = $DIC->database(); - $lng = $DIC->language(); - - $user_id = \ilObjTest::_getUserIdFromActiveId($active_id); - $name = \ilObjUser::_lookupFullname($user_id); - - if ($user_id === ANONYMOUS_USER_ID) { - $statement = $db->queryF( - 'SELECT importname FROM tst_active WHERE importname IS NOT NULL AND importname != "" AND user_fi = %s AND active_id = %s', - [\ilDBConstants::T_INTEGER, \ilDBConstants::T_INTEGER], - [ANONYMOUS_USER_ID, $active_id] - ); - $results = $db->fetchAll($statement); - $importname = $results[0]['importname'] ?? null; - - if ($importname !== null && $importname !== '') { - $name = "{$importname} ({$lng->txt('imported')})"; - } + $display_name = ''; + + if ($this->firstname) { + $display_name .= $this->firstname . ' '; + } + if ($this->lastname) { + $display_name .= $this->lastname; } - return $name; + return $this->user_id === ANONYMOUS_USER_ID && $this->importname !== null && $this->importname !== '' + ? "{$this->importname} ({$this->lng->txt('imported')})" + : $display_name; } } diff --git a/components/ILIAS/Test/src/Participants/ParticipantTable.php b/components/ILIAS/Test/src/Participants/ParticipantTable.php index 1b53862ad890..bdaada60b660 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' => Participant::getParticipantName($record->getActiveId()), + 'name' => $record->getDisplayName(), 'login' => $record->getLogin(), 'matriculation' => $record->getMatriculation(), 'total_time_on_task' => $record->getAttemptOverviewInformation()?->getHumanReadableTotalTimeOnTask() ?? '', diff --git a/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php b/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php index 488b21f61875..b770cb53cd29 100644 --- a/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php +++ b/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php @@ -84,7 +84,7 @@ public function getModal( (string) $v->getUserId(), $this->test_obj->getAnonymity() ? $this->lng->txt('anonymous') - : Participant::getParticipantName($v->getActiveId()) + : $v->getDisplayName() ), $selected_participants ) diff --git a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php index 2bed6481db7b..8743969fe2ad 100755 --- a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php +++ b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php @@ -23,7 +23,7 @@ use ILIAS\Data\Factory as DataFactory; use ILIAS\Data\Range; use ILIAS\Data\Order; -use ILIAS\Test\Participants\Participant; +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\UI\Component\Symbol\Icon\Standard as Icon; use ILIAS\UI\Component\Table\DataRowBuilder; use ILIAS\UI\Factory as UIFactory; @@ -35,6 +35,7 @@ public function __construct( protected readonly \ilObjTest $test_obj, protected readonly TestTopListRepository $repository, protected readonly \ilLanguage $lng, + protected readonly \ilDBInterface $db, protected readonly \ilObjUser $user, protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, @@ -152,7 +153,7 @@ private function buildBasicItemFromRowArray(array $row): array 'rank' => "{$row['rank']}.", 'participant' => $this->test_obj->isHighscoreAnon() && (int) $row['usr_id'] !== $this->user->getId() ? '-, -' - : Participant::getParticipantName($row['active_id']), + : (new ParticipantRepository($this->db))->getParticipantByActiveId($this->test_obj->getId(), $row['active_id'])->getDisplayName(), 'is_actor' => isset($row['usr_id']) && ((int) $row['usr_id'] === $this->user->getId()) ]; } diff --git a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php index d80d52f22e02..eee188219bc7 100644 --- a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php +++ b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php @@ -23,7 +23,7 @@ use ILIAS\Test\Logging\TestLogger; use ILIAS\Test\Logging\TestScoringInteractionTypes; use ILIAS\Test\Logging\AdditionalInformationGenerator; -use ILIAS\Test\Participants\Participant; +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\TestManScoringDoneHelper; class ConsecutiveScoring @@ -97,7 +97,9 @@ public function getUserFullName( return \ilObjTest::buildExamId($usr_active_id, $attempt, $this->object->getId()); } - $participant_name = Participant::getParticipantName($usr_active_id); + $participant_name = (new ParticipantRepository($this->db)) + ->getParticipantByActiveId($this->object->getId(), $usr_active_id) + ->getDisplayName(); if (str_ends_with($participant_name, ' (imported)')) { return $participant_name; } diff --git a/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php b/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php index 53877410f407..b62916e29213 100755 --- a/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php +++ b/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php @@ -51,6 +51,7 @@ protected function setUp(): void $this->testObjMock, $this->createMock(TestTopListRepository::class), $DIC['lng'], + $DIC['ilDB'], $DIC['ilUser'], $DIC['ui.factory'], $DIC['ui.renderer'], diff --git a/components/ILIAS/Test/tests/ilTestToplistGUITest.php b/components/ILIAS/Test/tests/ilTestToplistGUITest.php index 1b1fcfab7098..8e740f5524ea 100755 --- a/components/ILIAS/Test/tests/ilTestToplistGUITest.php +++ b/components/ILIAS/Test/tests/ilTestToplistGUITest.php @@ -40,6 +40,7 @@ protected function setUp(): void $DIC['ilCtrl'], $DIC['tpl'], $DIC['lng'], + $DIC['ilDB'], $DIC['ilUser'], $DIC['ui.factory'], $DIC['ui.renderer'], From af01e8697f9518ba91cc9ac624590ed8dfe3a08a Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Thu, 11 Dec 2025 10:52:12 +0100 Subject: [PATCH 5/7] Adds review changes --- .../ILIAS/Test/classes/class.ilObjTestGUI.php | 3 ++- .../Test/classes/class.ilTestEvaluationGUI.php | 4 ++-- .../Test/classes/class.ilTestResultsGUI.php | 8 +++++--- .../Test/classes/class.ilTestToplistGUI.php | 9 +++++---- components/ILIAS/Test/src/GUIFactory.php | 3 +-- .../Test/src/Participants/Participant.php | 6 ++---- .../src/Participants/ParticipantRepository.php | 6 ++++-- .../Test/src/Results/Toplist/DataRetrieval.php | 6 +++--- .../src/Scoring/Manual/ConsecutiveScoring.php | 18 ++++++++---------- components/ILIAS/Test/src/TestDIC.php | 2 +- .../Scoring/Toplist/DataRetrievalTest.php | 5 +++-- .../ILIAS/Test/tests/ilTestResultsGUITest.php | 5 ++++- .../ILIAS/Test/tests/ilTestToplistGUITest.php | 5 +++-- 13 files changed, 43 insertions(+), 37 deletions(-) diff --git a/components/ILIAS/Test/classes/class.ilObjTestGUI.php b/components/ILIAS/Test/classes/class.ilObjTestGUI.php index 07b0e0f626f3..cc13699f4b1a 100755 --- a/components/ILIAS/Test/classes/class.ilObjTestGUI.php +++ b/components/ILIAS/Test/classes/class.ilObjTestGUI.php @@ -481,7 +481,8 @@ public function executeCommand(): void $this->http, $this->data_factory, $this->test_session_factory->getSession(), - $this->getObjectiveOrientedContainer() + $this->getObjectiveOrientedContainer(), + $this->participant_repository ); $this->ctrl->forwardCommand($gui); diff --git a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php index cec88dd9198a..0cae4219b16e 100755 --- a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php @@ -18,9 +18,9 @@ declare(strict_types=1); -use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\Results\Presentation\TitlesBuilder as ResultsTitlesBuilder; use ILIAS\Test\Presentation\PrintLayoutProvider; +use ILIAS\Test\TestDIC; use ILIAS\UI\Component\ViewControl\Mode as ViewControlMode; use ILIAS\UI\Component\Link\Standard as StandardLink; use ILIAS\UI\Component\Panel\Sub as SubPanel; @@ -789,7 +789,7 @@ protected function buildResultsTitle(int $active_id, int $pass): string return sprintf( $this->lng->txt('tst_result_user_name_pass'), $pass + 1, - (new ParticipantRepository($this->db))->getParticipantByActiveId($this->object->getId(), $active_id)->getDisplayName() + TestDIC::dic()['participant.repository']->getParticipantByActiveId($this->object->getTestId(), $active_id)->getDisplayName() ); } diff --git a/components/ILIAS/Test/classes/class.ilTestResultsGUI.php b/components/ILIAS/Test/classes/class.ilTestResultsGUI.php index a5503d7b32be..da42dde929e6 100755 --- a/components/ILIAS/Test/classes/class.ilTestResultsGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestResultsGUI.php @@ -18,6 +18,7 @@ declare(strict_types=1); +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\RequestDataCollector; use ILIAS\Test\Presentation\TabsManager; use ILIAS\Test\Logging\TestLogger; @@ -73,7 +74,8 @@ public function __construct( private readonly GlobalHttpState $http, private readonly DataFactory $data_factory, private readonly ilTestSession $test_session, - private readonly ilTestObjectiveOrientedContainer $objective_parent + private readonly ilTestObjectiveOrientedContainer $objective_parent, + private readonly ParticipantRepository $participant_repository ) { } @@ -149,12 +151,12 @@ public function executeCommand(): void $this->ctrl, $this->main_tpl, $this->lng, - $this->db, $this->user, $this->ui_factory, $this->ui_renderer, $this->data_factory, - $this->http + $this->http, + $this->participant_repository ); $this->ctrl->forwardCommand($gui); break; diff --git a/components/ILIAS/Test/classes/class.ilTestToplistGUI.php b/components/ILIAS/Test/classes/class.ilTestToplistGUI.php index fa468acb3914..dc88db411720 100755 --- a/components/ILIAS/Test/classes/class.ilTestToplistGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestToplistGUI.php @@ -18,6 +18,7 @@ declare(strict_types=1); +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\Results\Toplist\TestTopListRepository; use ILIAS\Test\Results\Toplist\DataRetrieval; use ILIAS\Test\Results\Toplist\TopListOrder; @@ -41,12 +42,12 @@ public function __construct( protected readonly ilCtrlInterface $ctrl, protected readonly ilGlobalTemplateInterface $tpl, protected readonly ilLanguage $lng, - protected readonly ilDBInterface $db, protected readonly ilObjUser $user, protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly DataFactory $data_factory, - protected readonly GlobalHttpState $http_state + protected readonly GlobalHttpState $http_state, + protected readonly ParticipantRepository $participant_repository ) { } @@ -129,13 +130,13 @@ protected function buildTable(string $title, TopListType $list_type, TopListOrde $this->test_obj, $this->repository, $this->lng, - $this->db, $this->user, $this->ui_factory, $this->ui_renderer, $this->data_factory, $list_type, - $order_by + $order_by, + $this->participant_repository ); return $this->ui_factory->table() ->data($table, $title, $table->getColumns()) diff --git a/components/ILIAS/Test/src/GUIFactory.php b/components/ILIAS/Test/src/GUIFactory.php index e4fa09551919..cbf77c4599a1 100644 --- a/components/ILIAS/Test/src/GUIFactory.php +++ b/components/ILIAS/Test/src/GUIFactory.php @@ -77,8 +77,7 @@ public function __construct( $this->test_dic['scoring.manual.done_helper'], $this->global_dic['ilUser'], $this->internal['test.access']($test_obj), - $this->global_dic['ilDB'], - $this->global_dic['lng'], + $this->test_dic['participant.repository'], ); $this->internal['manscoring.positionsfactory'] = fn(\ilObjTest $test_obj): PositionsFactory => diff --git a/components/ILIAS/Test/src/Participants/Participant.php b/components/ILIAS/Test/src/Participants/Participant.php index b8df86dbbf80..d25ec52482d9 100644 --- a/components/ILIAS/Test/src/Participants/Participant.php +++ b/components/ILIAS/Test/src/Participants/Participant.php @@ -26,7 +26,6 @@ class Participant { private ?AttemptOverview $attempt_overview = null; private ?\DateTimeImmutable $running_attempt_start = null; - private readonly \ilLanguage $lng; public function __construct( private readonly int $user_id, @@ -49,10 +48,9 @@ public function __construct( private readonly bool $unfinished_attempts = false, private readonly ?\DateTimeImmutable $first_access = null, private readonly ?\DateTimeImmutable $last_access = null, - private readonly bool $scoring_finalized = false + private readonly bool $scoring_finalized = false, + private readonly \ilLanguage $lng ) { - global $DIC; - $this->lng = $DIC->language(); } public function getUserId(): int diff --git a/components/ILIAS/Test/src/Participants/ParticipantRepository.php b/components/ILIAS/Test/src/Participants/ParticipantRepository.php index 553b99256877..4b730a0a29d1 100755 --- a/components/ILIAS/Test/src/Participants/ParticipantRepository.php +++ b/components/ILIAS/Test/src/Participants/ParticipantRepository.php @@ -26,7 +26,8 @@ class ParticipantRepository { public function __construct( - private readonly \ilDBInterface $database + private readonly \ilDBInterface $database, + private readonly \ilLanguage $lng ) { } @@ -342,7 +343,8 @@ private function arrayToObject(array $row): Participant $row['unfinished_attempts'] === 1, $row['first_access'] === null ? null : new \DateTimeImmutable($row['first_access']), $row['last_access'] === null ? null : new \DateTimeImmutable($row['last_access']), - (bool) $row['scoring_finalized'] + (bool) $row['scoring_finalized'], + $this->lng ); } diff --git a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php index 8743969fe2ad..f5b9032d83c8 100755 --- a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php +++ b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php @@ -35,13 +35,13 @@ public function __construct( protected readonly \ilObjTest $test_obj, protected readonly TestTopListRepository $repository, protected readonly \ilLanguage $lng, - protected readonly \ilDBInterface $db, protected readonly \ilObjUser $user, protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly DataFactory $data_factory, protected readonly TopListType $list_type, - protected readonly TopListOrder $order_by + protected readonly TopListOrder $order_by, + protected readonly ParticipantRepository $participant_repository ) { } @@ -153,7 +153,7 @@ private function buildBasicItemFromRowArray(array $row): array 'rank' => "{$row['rank']}.", 'participant' => $this->test_obj->isHighscoreAnon() && (int) $row['usr_id'] !== $this->user->getId() ? '-, -' - : (new ParticipantRepository($this->db))->getParticipantByActiveId($this->test_obj->getId(), $row['active_id'])->getDisplayName(), + : $this->participant_repository->getParticipantByActiveId($this->test_obj->getTestId(), $row['active_id'])->getDisplayName(), 'is_actor' => isset($row['usr_id']) && ((int) $row['usr_id'] === $this->user->getId()) ]; } diff --git a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php index eee188219bc7..d1f87cd955b3 100644 --- a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php +++ b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php @@ -37,8 +37,7 @@ public function __construct( private TestManScoringDoneHelper $scoring_done_helper, private \ilObjUser $current_user, private readonly \ilTestAccess $test_access, - private readonly \ilDBInterface $db, - private readonly \ilLanguage $lng, + private readonly ParticipantRepository $participant_repository, ) { } @@ -97,16 +96,15 @@ public function getUserFullName( return \ilObjTest::buildExamId($usr_active_id, $attempt, $this->object->getId()); } - $participant_name = (new ParticipantRepository($this->db)) - ->getParticipantByActiveId($this->object->getId(), $usr_active_id) - ->getDisplayName(); - if (str_ends_with($participant_name, ' (imported)')) { - return $participant_name; + $participant = $this->participant_repository->getParticipantByActiveId($this->object->getTestId(), $usr_active_id); + $importname = $participant->getImportname(); + $user_id = $participant->getUserId(); + if ($user_id === ANONYMOUS_USER_ID && $importname !== null && $importname !== '') { + return $participant->getDisplayName(); } - $user_id = (string) $this->object::_getUserIdFromActiveId($usr_active_id); - $user_data = $this->object->getUserData([$user_id]); - $user = $user_data[$user_id]; + $user_id = (string) $user_id; + $user = $this->object->getUserData([$user_id])[$user_id]; return sprintf( "%s %s [%s]", $user["firstname"], diff --git a/components/ILIAS/Test/src/TestDIC.php b/components/ILIAS/Test/src/TestDIC.php index 3aca83d2cc2e..894b615e19fc 100755 --- a/components/ILIAS/Test/src/TestDIC.php +++ b/components/ILIAS/Test/src/TestDIC.php @@ -254,7 +254,7 @@ protected static function buildDIC(ILIASContainer $DIC): self ); $dic['participant.repository'] = static fn($c): ParticipantRepository => - new ParticipantRepository($DIC['ilDB']); + new ParticipantRepository($DIC['ilDB'], $DIC['lng']); $dic['gui.factory'] = static fn($c): GUIFactory => new GUIFactory($DIC, $c); diff --git a/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php b/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php index b62916e29213..aa5cde018e52 100755 --- a/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php +++ b/components/ILIAS/Test/tests/Scoring/Toplist/DataRetrievalTest.php @@ -21,6 +21,7 @@ namespace Results\Toplist; use ILIAS\Data\Factory; +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\Results\Toplist\TestTopListRepository; use ILIAS\Test\Results\Toplist\DataRetrieval; use ILIAS\Test\Results\Toplist\TopListOrder; @@ -51,13 +52,13 @@ protected function setUp(): void $this->testObjMock, $this->createMock(TestTopListRepository::class), $DIC['lng'], - $DIC['ilDB'], $DIC['ilUser'], $DIC['ui.factory'], $DIC['ui.renderer'], $this->createMock(Factory::class), TopListType::GENERAL, - TopListOrder::BY_SCORE + TopListOrder::BY_SCORE, + $this->createMock(ParticipantRepository::class) ); } diff --git a/components/ILIAS/Test/tests/ilTestResultsGUITest.php b/components/ILIAS/Test/tests/ilTestResultsGUITest.php index 85b3e0138c36..efc51d394c95 100755 --- a/components/ILIAS/Test/tests/ilTestResultsGUITest.php +++ b/components/ILIAS/Test/tests/ilTestResultsGUITest.php @@ -18,6 +18,8 @@ declare(strict_types=1); +use ILIAS\Test\Participants\ParticipantRepository; + /** * Class ilTestResultsGUITest * @author Marvin Beym @@ -56,7 +58,8 @@ protected function setUp(): void $DIC['http'], $this->createMock(ILIAS\Data\Factory::class), $this->createMock(ilTestSession::class), - $this->createMock(ilTestObjectiveOrientedContainer::class) + $this->createMock(ilTestObjectiveOrientedContainer::class), + $this->createMock(ParticipantRepository::class) ); } diff --git a/components/ILIAS/Test/tests/ilTestToplistGUITest.php b/components/ILIAS/Test/tests/ilTestToplistGUITest.php index 8e740f5524ea..1778d6f4ba15 100755 --- a/components/ILIAS/Test/tests/ilTestToplistGUITest.php +++ b/components/ILIAS/Test/tests/ilTestToplistGUITest.php @@ -19,6 +19,7 @@ declare(strict_types=1); use ILIAS\Data\Factory; +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\Results\Toplist\TestTopListRepository; /** @@ -40,12 +41,12 @@ protected function setUp(): void $DIC['ilCtrl'], $DIC['tpl'], $DIC['lng'], - $DIC['ilDB'], $DIC['ilUser'], $DIC['ui.factory'], $DIC['ui.renderer'], $this->createMock(Factory::class), - $DIC['http'] + $DIC['http'], + $this->createMock(ParticipantRepository::class) ); } From 82beca2f9a5bc47bba1ac293e5f91f7c2695f87d Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Mon, 15 Dec 2025 10:47:30 +0100 Subject: [PATCH 6/7] Removes ilLanguage dependency in Participant and moves it to the method Participant::getDisplayName --- .../ILIAS/Test/classes/class.ilTestEvaluationGUI.php | 2 +- components/ILIAS/Test/src/GUIFactory.php | 1 + components/ILIAS/Test/src/Participants/Participant.php | 8 ++++---- .../ILIAS/Test/src/Participants/ParticipantRepository.php | 6 ++---- .../ILIAS/Test/src/Participants/ParticipantTable.php | 2 +- .../Participants/ParticipantTableDeleteResultsAction.php | 2 +- .../ILIAS/Test/src/Results/Toplist/DataRetrieval.php | 2 +- .../ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php | 4 +++- components/ILIAS/Test/src/TestDIC.php | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php index 0cae4219b16e..e98ad676728f 100755 --- a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php @@ -789,7 +789,7 @@ protected function buildResultsTitle(int $active_id, int $pass): string return sprintf( $this->lng->txt('tst_result_user_name_pass'), $pass + 1, - TestDIC::dic()['participant.repository']->getParticipantByActiveId($this->object->getTestId(), $active_id)->getDisplayName() + TestDIC::dic()['participant.repository']->getParticipantByActiveId($this->object->getTestId(), $active_id)->getDisplayName($this->lng) ); } diff --git a/components/ILIAS/Test/src/GUIFactory.php b/components/ILIAS/Test/src/GUIFactory.php index cbf77c4599a1..49fc2e305a33 100644 --- a/components/ILIAS/Test/src/GUIFactory.php +++ b/components/ILIAS/Test/src/GUIFactory.php @@ -78,6 +78,7 @@ public function __construct( $this->global_dic['ilUser'], $this->internal['test.access']($test_obj), $this->test_dic['participant.repository'], + $this->global_dic['lng'], ); $this->internal['manscoring.positionsfactory'] = fn(\ilObjTest $test_obj): PositionsFactory => diff --git a/components/ILIAS/Test/src/Participants/Participant.php b/components/ILIAS/Test/src/Participants/Participant.php index d25ec52482d9..4d0c0bcd719a 100644 --- a/components/ILIAS/Test/src/Participants/Participant.php +++ b/components/ILIAS/Test/src/Participants/Participant.php @@ -20,6 +20,7 @@ namespace ILIAS\Test\Participants; +use ILIAS\Language\Language; use ILIAS\Test\Results\Data\AttemptOverview; class Participant @@ -48,8 +49,7 @@ public function __construct( private readonly bool $unfinished_attempts = false, private readonly ?\DateTimeImmutable $first_access = null, private readonly ?\DateTimeImmutable $last_access = null, - private readonly bool $scoring_finalized = false, - private readonly \ilLanguage $lng + private readonly bool $scoring_finalized = false ) { } @@ -243,7 +243,7 @@ public function isScoringFinalized(): bool return $this->scoring_finalized; } - public function getDisplayName(): string + public function getDisplayName(Language $language): string { $display_name = ''; @@ -255,7 +255,7 @@ public function getDisplayName(): string } return $this->user_id === ANONYMOUS_USER_ID && $this->importname !== null && $this->importname !== '' - ? "{$this->importname} ({$this->lng->txt('imported')})" + ? "{$this->importname} ({$language->txt('imported')})" : $display_name; } } diff --git a/components/ILIAS/Test/src/Participants/ParticipantRepository.php b/components/ILIAS/Test/src/Participants/ParticipantRepository.php index 4b730a0a29d1..553b99256877 100755 --- a/components/ILIAS/Test/src/Participants/ParticipantRepository.php +++ b/components/ILIAS/Test/src/Participants/ParticipantRepository.php @@ -26,8 +26,7 @@ class ParticipantRepository { public function __construct( - private readonly \ilDBInterface $database, - private readonly \ilLanguage $lng + private readonly \ilDBInterface $database ) { } @@ -343,8 +342,7 @@ private function arrayToObject(array $row): Participant $row['unfinished_attempts'] === 1, $row['first_access'] === null ? null : new \DateTimeImmutable($row['first_access']), $row['last_access'] === null ? null : new \DateTimeImmutable($row['last_access']), - (bool) $row['scoring_finalized'], - $this->lng + (bool) $row['scoring_finalized'] ); } diff --git a/components/ILIAS/Test/src/Participants/ParticipantTable.php b/components/ILIAS/Test/src/Participants/ParticipantTable.php index bdaada60b660..b017d2c52f9b 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(), + 'name' => $record->getDisplayName($this->lng), 'login' => $record->getLogin(), 'matriculation' => $record->getMatriculation(), 'total_time_on_task' => $record->getAttemptOverviewInformation()?->getHumanReadableTotalTimeOnTask() ?? '', diff --git a/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php b/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php index b770cb53cd29..22ddff5b9323 100644 --- a/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php +++ b/components/ILIAS/Test/src/Participants/ParticipantTableDeleteResultsAction.php @@ -84,7 +84,7 @@ public function getModal( (string) $v->getUserId(), $this->test_obj->getAnonymity() ? $this->lng->txt('anonymous') - : $v->getDisplayName() + : $v->getDisplayName($this->lng) ), $selected_participants ) diff --git a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php index f5b9032d83c8..b5352356105d 100755 --- a/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php +++ b/components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php @@ -153,7 +153,7 @@ private function buildBasicItemFromRowArray(array $row): array 'rank' => "{$row['rank']}.", 'participant' => $this->test_obj->isHighscoreAnon() && (int) $row['usr_id'] !== $this->user->getId() ? '-, -' - : $this->participant_repository->getParticipantByActiveId($this->test_obj->getTestId(), $row['active_id'])->getDisplayName(), + : $this->participant_repository->getParticipantByActiveId($this->test_obj->getTestId(), $row['active_id'])->getDisplayName($this->lng), 'is_actor' => isset($row['usr_id']) && ((int) $row['usr_id'] === $this->user->getId()) ]; } diff --git a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php index d1f87cd955b3..3bac8f205a12 100644 --- a/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php +++ b/components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php @@ -20,6 +20,7 @@ namespace ILIAS\Test\Scoring\Manual; +use ILIAS\Language\Language; use ILIAS\Test\Logging\TestLogger; use ILIAS\Test\Logging\TestScoringInteractionTypes; use ILIAS\Test\Logging\AdditionalInformationGenerator; @@ -38,6 +39,7 @@ public function __construct( private \ilObjUser $current_user, private readonly \ilTestAccess $test_access, private readonly ParticipantRepository $participant_repository, + private readonly Language $lng, ) { } @@ -100,7 +102,7 @@ public function getUserFullName( $importname = $participant->getImportname(); $user_id = $participant->getUserId(); if ($user_id === ANONYMOUS_USER_ID && $importname !== null && $importname !== '') { - return $participant->getDisplayName(); + return $participant->getDisplayName($this->lng); } $user_id = (string) $user_id; diff --git a/components/ILIAS/Test/src/TestDIC.php b/components/ILIAS/Test/src/TestDIC.php index 894b615e19fc..3aca83d2cc2e 100755 --- a/components/ILIAS/Test/src/TestDIC.php +++ b/components/ILIAS/Test/src/TestDIC.php @@ -254,7 +254,7 @@ protected static function buildDIC(ILIASContainer $DIC): self ); $dic['participant.repository'] = static fn($c): ParticipantRepository => - new ParticipantRepository($DIC['ilDB'], $DIC['lng']); + new ParticipantRepository($DIC['ilDB']); $dic['gui.factory'] = static fn($c): GUIFactory => new GUIFactory($DIC, $c); From 6ab4a408945cb59581dfb3ec9aa70c56ea38e10f Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Mon, 15 Dec 2025 16:42:49 +0100 Subject: [PATCH 7/7] Adds small review change --- components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php index e98ad676728f..4b130cf7cb61 100755 --- a/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php +++ b/components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php @@ -18,6 +18,7 @@ declare(strict_types=1); +use ILIAS\Test\Participants\ParticipantRepository; use ILIAS\Test\Results\Presentation\TitlesBuilder as ResultsTitlesBuilder; use ILIAS\Test\Presentation\PrintLayoutProvider; use ILIAS\Test\TestDIC; @@ -49,11 +50,13 @@ class ilTestEvaluationGUI extends ilTestServiceGUI private const DEFAULT_CMD = 'outUserListOfAnswerPasses'; protected ilTestAccess $testAccess; protected ilTestProcessLockerFactory $processLockerFactory; + private readonly ParticipantRepository $participant_repository; public function __construct(ilObjTest $object) { parent::__construct($object); $this->participant_access_filter = new ilTestParticipantAccessFilterFactory($this->access); + $this->participant_repository = TestDIC::dic()['participant.repository']; $this->processLockerFactory = new ilTestProcessLockerFactory( new ilSetting('assessment'), @@ -789,7 +792,7 @@ protected function buildResultsTitle(int $active_id, int $pass): string return sprintf( $this->lng->txt('tst_result_user_name_pass'), $pass + 1, - TestDIC::dic()['participant.repository']->getParticipantByActiveId($this->object->getTestId(), $active_id)->getDisplayName($this->lng) + $this->participant_repository->getParticipantByActiveId($this->object->getTestId(), $active_id)->getDisplayName($this->lng) ); }