diff --git a/components/ILIAS/Test/src/Scoring/Manual/ScoringByQuestionTableBinder.php b/components/ILIAS/Test/src/Scoring/Manual/ScoringByQuestionTableBinder.php index d4ff3f0a1615..213f5c4f5c1f 100644 --- a/components/ILIAS/Test/src/Scoring/Manual/ScoringByQuestionTableBinder.php +++ b/components/ILIAS/Test/src/Scoring/Manual/ScoringByQuestionTableBinder.php @@ -25,6 +25,8 @@ use ILIAS\Data\Range; use ILIAS\Data\Order; use ILIAS\Language\Language; +use ILIAS\Test\Results\Data\Factory as TestResultsDataFactory; +use ILIAS\Test\Results\Presentation\Factory as TestResultsPresentationFactory; class ScoringByQuestionTableBinder implements DataRetrieval { @@ -35,6 +37,8 @@ public function __construct( private readonly Language $lng, private readonly \DateTimeZone $timezone, private readonly \ilTestParticipantAccessFilterFactory $participant_access_filter_factory, + private readonly TestResultsDataFactory $results_data_factory, + private readonly TestResultsPresentationFactory $results_presentation_factory, private readonly \ilObjTest $test_obj, private readonly int $question_id ) { @@ -154,6 +158,21 @@ function ( array $c, \ilTestEvaluationPassData $pd ) use ($question_id, $active_id, $filtered_participants, $complete_feedback): array { + $is_finished = $this + ->results_data_factory + ->getAttemptOverviewFor( + $this->results_presentation_factory->getAttemptResultsSettings($this->test_obj, false), + $this->test_obj, + $active_id, + $pd->getPass() + ) + ?->getStatusOfAttempt() + ?->isFinished() ?? false; + + if (!$is_finished) { + return $c; + } + $question_result = $pd->getAnsweredQuestionByQuestionId($question_id); $feedback_data = $complete_feedback[$active_id][$pd->getPass()][$question_id] ?? []; if ($this->isFilteredAttempt($pd, $question_result, $feedback_data)) { diff --git a/components/ILIAS/Test/src/Scoring/Manual/class.TestScoringByQuestionGUI.php b/components/ILIAS/Test/src/Scoring/Manual/class.TestScoringByQuestionGUI.php index abfceafbc3c1..56abeb81781b 100755 --- a/components/ILIAS/Test/src/Scoring/Manual/class.TestScoringByQuestionGUI.php +++ b/components/ILIAS/Test/src/Scoring/Manual/class.TestScoringByQuestionGUI.php @@ -123,7 +123,25 @@ protected function showManScoringByQuestionParticipantsTable( if ($this->testrequest->strVal($this->action_parameter_token->getName()) === ScoringByQuestionTable::ACTION_SCORING) { $affected_rows = $this->testrequest->raw($this->row_id_token->getName()); - $this->getAnswerDetail($question_id, $affected_rows[0]); + [$active_id, $attempt] = explode('_', $affected_rows[0]); + + $is_finished = $this + ->results_data_factory + ->getAttemptOverviewFor( + $this->results_presentation_factory->getAttemptResultsSettings($this->object, false), + $this->object, + (int) $active_id, + (int) $attempt + ) + ?->getStatusOfAttempt() + ?->isFinished() ?? false; + + if ($is_finished) { + $this->getAnswerDetail($question_id, $affected_rows[0]); + return; + } + + throw new \Exception('Test attempt is not finished'); } $content = [ @@ -140,6 +158,8 @@ protected function showManScoringByQuestionParticipantsTable( $this->lng, new \DateTimeZone($this->user->getTimeZone()), $this->participant_access_filter, + $this->results_data_factory, + $this->results_presentation_factory, $this->object, $question_id )