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
4 changes: 2 additions & 2 deletions components/ILIAS/Test/classes/class.ilObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4273,7 +4273,7 @@ public function getTestParticipants(): array
LEFT JOIN usr_data
ON tst_active.user_fi = usr_data.usr_id
WHERE tst_active.test_fi = %s
ORDER BY usr_data.lastname
ORDER BY usr_data.lastname, usr_data.firstname, tst_active.active_id
";
$result = $this->db->queryF(
$query,
Expand All @@ -4297,7 +4297,7 @@ public function getTestParticipants(): array
LEFT JOIN usr_data
ON tst_active.user_fi = usr_data.usr_id
WHERE tst_active.test_fi = %s
ORDER BY usr_data.lastname
ORDER BY usr_data.lastname, usr_data.firstname, tst_active.active_id
";
$result = $this->db->queryF(
$query,
Expand Down
3 changes: 2 additions & 1 deletion components/ILIAS/Test/src/GUIFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public function __construct(
$this->internal['manscoring.positionsfactory'] = fn(\ilObjTest $test_obj): PositionsFactory =>
new PositionsFactory(
$test_obj,
$this->test_dic['question.general_properties.repository']
$this->test_dic['question.general_properties.repository'],
$this->global_dic['ilAccess']
);

$this->internal['manscoring.testscoring'] = fn(\ilObjTest $test_obj): TestScoring =>
Expand Down
26 changes: 24 additions & 2 deletions components/ILIAS/Test/src/Scoring/Manual/PositionsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class PositionsFactory
{
public function __construct(
private readonly \ilObjTest $test_obj,
private readonly GeneralQuestionPropertiesRepository $question_repo
private readonly GeneralQuestionPropertiesRepository $question_repo,
private readonly \ilAccess $access
) {
}

Expand All @@ -35,7 +36,10 @@ public function get(): Positions
$user_questions = [];
$user_attempts = [];
$question_properties = [];
foreach (array_keys($this->test_obj->getTestParticipants()) as $usr_active_id) {

$test_participants = $this->filterParticipantsIfOrgUnitsEnabled($this->test_obj->getTestParticipants());

foreach (array_keys($test_participants) as $usr_active_id) {
$attempt = \ilObjTest::_getResultPass($usr_active_id);
$user_attempts[$usr_active_id] = $attempt;
$user_questions[$usr_active_id] = $this->test_obj->isRandomTest()
Expand Down Expand Up @@ -73,4 +77,22 @@ public function get(): Positions
$question_properties
);
}

private function filterParticipantsIfOrgUnitsEnabled(array $test_participants): array
{
if (!\ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($this->test_obj->getId())) {
return $test_participants;
}

$allowed_participants = $this->access->filterUserIdsByPositionOfCurrentUser(
\ilOrgUnitOperation::OP_SCORE_PARTICIPANTS,
$this->test_obj->getRefId(),
array_column($test_participants, 'usr_id')
);

return array_filter(
$test_participants,
static fn(array $participant): bool => in_array($participant['usr_id'], $allowed_participants, true)
);
}
}
Loading