Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/ILIAS/Test/classes/class.ilObjTestGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 9 additions & 11 deletions components/ILIAS/Test/classes/class.ilTestEvaluationGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

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;
Expand Down Expand Up @@ -48,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'),
Expand Down Expand Up @@ -138,10 +142,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
);
},
Expand Down Expand Up @@ -183,10 +184,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)
);

Expand Down Expand Up @@ -327,7 +325,7 @@ public function outUserPassDetails(): void
true
),
$settings,
$this->buildResultsTitle($this->user->getFullname(), $pass),
$this->buildResultsTitle($active_id, $pass),
false
);

Expand Down Expand Up @@ -783,7 +781,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(
Expand All @@ -794,7 +792,7 @@ protected function buildResultsTitle(string $fullname, int $pass): string
return sprintf(
$this->lng->txt('tst_result_user_name_pass'),
$pass + 1,
$fullname
$this->participant_repository->getParticipantByActiveId($this->object->getTestId(), $active_id)->getDisplayName($this->lng)
);
}

Expand Down
7 changes: 5 additions & 2 deletions components/ILIAS/Test/classes/class.ilTestResultsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
) {
}

Expand Down Expand Up @@ -153,7 +155,8 @@ public function executeCommand(): void
$this->ui_factory,
$this->ui_renderer,
$this->data_factory,
$this->http
$this->http,
$this->participant_repository
);
$this->ctrl->forwardCommand($gui);
break;
Expand Down
7 changes: 5 additions & 2 deletions components/ILIAS/Test/classes/class.ilTestToplistGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,7 +46,8 @@ public function __construct(
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
) {
}

Expand Down Expand Up @@ -133,7 +135,8 @@ protected function buildTable(string $title, TopListType $list_type, TopListOrde
$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())
Expand Down
2 changes: 2 additions & 0 deletions components/ILIAS/Test/src/GUIFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->test_dic['participant.repository'],
$this->global_dic['lng'],
);

$this->internal['manscoring.positionsfactory'] = fn(\ilObjTest $test_obj): PositionsFactory =>
Expand Down
23 changes: 23 additions & 0 deletions components/ILIAS/Test/src/Participants/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace ILIAS\Test\Participants;

use ILIAS\Language\Language;
use ILIAS\Test\Results\Data\AttemptOverview;

class Participant
Expand All @@ -35,6 +36,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,
Expand Down Expand Up @@ -86,6 +88,11 @@ public function getLogin(): string
return $this->login;
}

public function getImportname(): ?string
{
return $this->importname;
}

public function getMatriculation(): string
{
return $this->matriculation;
Expand Down Expand Up @@ -235,4 +242,20 @@ public function isScoringFinalized(): bool
{
return $this->scoring_finalized;
}

public function getDisplayName(Language $language): string
{
$display_name = '';

if ($this->firstname) {
$display_name .= $this->firstname . ' ';
}
if ($this->lastname) {
$display_name .= $this->lastname;
}

return $this->user_id === ANONYMOUS_USER_ID && $this->importname !== null && $this->importname !== ''
? "{$this->importname} ({$language->txt('imported')})"
: $display_name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' => $this->test_object->buildName($record->getUserId(), $record->getFirstname(), $record->getLastname()),
'name' => $record->getDisplayName($this->lng),
'login' => $record->getLogin(),
'matriculation' => $record->getMatriculation(),
'total_time_on_task' => $record->getAttemptOverviewInformation()?->getHumanReadableTotalTimeOnTask() ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getModal(
(string) $v->getUserId(),
$this->test_obj->getAnonymity()
? $this->lng->txt('anonymous')
: \ilObjUser::_lookupFullname($v->getUserId())
: $v->getDisplayName($this->lng)
),
$selected_participants
)
Expand Down
6 changes: 4 additions & 2 deletions components/ILIAS/Test/src/Results/Toplist/DataRetrieval.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use ILIAS\Data\Factory as DataFactory;
use ILIAS\Data\Range;
use ILIAS\Data\Order;
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;
Expand All @@ -39,7 +40,8 @@ public function __construct(
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
) {
}

Expand Down Expand Up @@ -151,7 +153,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'],
: $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())
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions components/ILIAS/Test/src/Scoring/Manual/ConsecutiveScoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

namespace ILIAS\Test\Scoring\Manual;

use ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository;
use ILIAS\Language\Language;
use ILIAS\Test\Logging\TestLogger;
use ILIAS\Test\Logging\TestScoringInteractionTypes;
use ILIAS\Test\Logging\AdditionalInformationGenerator;
use ILIAS\Test\Participants\ParticipantRepository;
use ILIAS\Test\TestManScoringDoneHelper;

class ConsecutiveScoring
Expand All @@ -37,6 +38,8 @@ public function __construct(
private TestManScoringDoneHelper $scoring_done_helper,
private \ilObjUser $current_user,
private readonly \ilTestAccess $test_access,
private readonly ParticipantRepository $participant_repository,
private readonly Language $lng,
) {
}

Expand Down Expand Up @@ -94,9 +97,16 @@ public function getUserFullName(
) {
return \ilObjTest::buildExamId($usr_active_id, $attempt, $this->object->getId());
}
$user_id = (string) $this->object->_getUserIdFromActiveId($usr_active_id);
$user_data = $this->object->getUserData([$user_id]);
$user = $user_data[$user_id];

$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($this->lng);
}

$user_id = (string) $user_id;
$user = $this->object->getUserData([$user_id])[$user_id];
return sprintf(
"%s %s [%s]",
$user["firstname"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,7 +57,8 @@ protected function setUp(): void
$DIC['ui.renderer'],
$this->createMock(Factory::class),
TopListType::GENERAL,
TopListOrder::BY_SCORE
TopListOrder::BY_SCORE,
$this->createMock(ParticipantRepository::class)
);
}

Expand Down
5 changes: 4 additions & 1 deletion components/ILIAS/Test/tests/ilTestResultsGUITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

declare(strict_types=1);

use ILIAS\Test\Participants\ParticipantRepository;

/**
* Class ilTestResultsGUITest
* @author Marvin Beym <mbeym@databay.de>
Expand Down Expand Up @@ -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)
);
}

Expand Down
4 changes: 3 additions & 1 deletion components/ILIAS/Test/tests/ilTestToplistGUITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
declare(strict_types=1);

use ILIAS\Data\Factory;
use ILIAS\Test\Participants\ParticipantRepository;
use ILIAS\Test\Results\Toplist\TestTopListRepository;

/**
Expand All @@ -44,7 +45,8 @@ protected function setUp(): void
$DIC['ui.factory'],
$DIC['ui.renderer'],
$this->createMock(Factory::class),
$DIC['http']
$DIC['http'],
$this->createMock(ParticipantRepository::class)
);
}

Expand Down