Skip to content

Commit c7db83b

Browse files
committed
Test: Only Show Correction of Points if Available
See: https://mantis.ilias.de/view.php?id=48302
1 parent 72d74a7 commit c7db83b

3 files changed

Lines changed: 18 additions & 21 deletions

File tree

components/ILIAS/Test/classes/class.ilTestCorrectionsGUI.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ protected function checkQuestion(): bool
389389
return false;
390390
}
391391

392-
if (!$this->supportsAdjustment($this->question_gui)) {
392+
if (!$this->question_gui?->supportsAdjustment()) {
393393
return false;
394394
}
395395

@@ -460,9 +460,7 @@ protected function getQuestions(): array
460460
return array_reduce(
461461
$this->test_obj->getTestQuestions(),
462462
function (array $c, array $v): array {
463-
$question_gui = $this->getQuestionGUI($v['question_id']);
464-
465-
if (!$this->supportsAdjustment($question_gui)) {
463+
if (!$this->getQuestionGUI($v['question_id'])?->supportsAdjustment()) {
466464
return $c;
467465
}
468466

@@ -472,19 +470,4 @@ function (array $c, array $v): array {
472470
[]
473471
);
474472
}
475-
476-
/**
477-
* Returns if the given question object support scoring adjustment.
478-
*
479-
* @param $question_object assQuestionGUI
480-
*
481-
* @return bool True, if relevant interfaces are implemented to support scoring adjustment.
482-
*/
483-
protected function supportsAdjustment(\assQuestionGUI $question_object): bool
484-
{
485-
return ($question_object instanceof ilGuiQuestionScoringAdjustable
486-
|| $question_object instanceof ilGuiAnswerScoringAdjustable)
487-
&& ($question_object->getObject() instanceof ilObjQuestionScoringAdjustable
488-
|| $question_object->getObject() instanceof ilObjAnswerScoringAdjustable);
489-
}
490473
}

components/ILIAS/Test/src/Questions/Presentation/QuestionsTableActions.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
namespace ILIAS\Test\Questions\Presentation;
2222

23+
use ILIAS\Test\Questions\Properties\Properties;
2324
use ILIAS\Test\Questions\Properties\Repository as TestQuestionsRepository;
2425
use ILIAS\Test\ResponseHandler;
2526
use ILIAS\UI\Factory as UIFactory;
@@ -75,7 +76,8 @@ public function __construct(
7576
}
7677

7778
public function setDisabledActions(
78-
OrderingRow $row
79+
OrderingRow $row,
80+
Properties $record
7981
): OrderingRow {
8082
$disable_default_actions = $this->is_in_test_with_random_question_set
8183
|| $this->is_in_test_with_results;
@@ -87,7 +89,11 @@ public function setDisabledActions(
8789
->withDisabledAction(self::ACTION_EDIT_PAGE, $disable_default_actions)
8890
->withDisabledAction(
8991
self::ACTION_ADJUST,
90-
!$this->is_adjusting_questions_with_results_allowed || !$this->is_in_test_with_results
92+
!$this->is_adjusting_questions_with_results_allowed
93+
|| !$this->is_in_test_with_results
94+
|| !\assQuestion::instantiateQuestionGUI(
95+
$record->getGeneralQuestionProperties()->getQuestionId()
96+
)->supportsAdjustment()
9197
)->withDisabledAction(self::ACTION_FEEDBACK, $disable_default_actions)
9298
->withDisabledAction(self::ACTION_PRINT_ANSWERS, !$this->is_in_test_with_results)
9399
->withDisabledAction(

components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,14 @@ public function buildFileDownloadLink(): string
20672067
return $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class, 'downloadFile');
20682068
}
20692069

2070+
public function supportsAdjustment(): bool
2071+
{
2072+
return ($this instanceof ilGuiQuestionScoringAdjustable
2073+
|| $this instanceof ilGuiAnswerScoringAdjustable)
2074+
&& ($this->getObject() instanceof ilObjQuestionScoringAdjustable
2075+
|| $this->getObject() instanceof ilObjAnswerScoringAdjustable);
2076+
}
2077+
20702078
protected function resetSavedPreviewSession(): void
20712079
{
20722080
$this->preview_session = new ilAssQuestionPreviewSession(

0 commit comments

Comments
 (0)