Skip to content

Commit f20e2da

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

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
@@ -379,7 +379,7 @@ protected function checkQuestion(): bool
379379
return false;
380380
}
381381

382-
if (!$this->supportsAdjustment($this->question_gui)) {
382+
if (!$this->question_gui?->supportsAdjustment()) {
383383
return false;
384384
}
385385

@@ -450,9 +450,7 @@ protected function getQuestions(): array
450450
return array_reduce(
451451
$this->test_obj->getTestQuestions(),
452452
function (array $c, array $v): array {
453-
$question_gui = $this->getQuestionGUI($v['question_id']);
454-
455-
if (!$this->supportsAdjustment($question_gui)) {
453+
if (!$this->getQuestionGUI($v['question_id'])?->supportsAdjustment()) {
456454
return $c;
457455
}
458456

@@ -462,19 +460,4 @@ function (array $c, array $v): array {
462460
[]
463461
);
464462
}
465-
466-
/**
467-
* Returns if the given question object support scoring adjustment.
468-
*
469-
* @param $question_object assQuestionGUI
470-
*
471-
* @return bool True, if relevant interfaces are implemented to support scoring adjustment.
472-
*/
473-
protected function supportsAdjustment(\assQuestionGUI $question_object): bool
474-
{
475-
return ($question_object instanceof ilGuiQuestionScoringAdjustable
476-
|| $question_object instanceof ilGuiAnswerScoringAdjustable)
477-
&& ($question_object->getObject() instanceof ilObjQuestionScoringAdjustable
478-
|| $question_object->getObject() instanceof ilObjAnswerScoringAdjustable);
479-
}
480463
}

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\UI\Factory as UIFactory;
2526
use ILIAS\UI\Renderer as UIRenderer;
@@ -73,7 +74,8 @@ public function __construct(
7374
}
7475

7576
public function setDisabledActions(
76-
OrderingRow $row
77+
OrderingRow $row,
78+
Properties $record
7779
): OrderingRow {
7880
$disable_default_actions = $this->is_in_test_with_random_question_set
7981
|| $this->is_in_test_with_results;
@@ -85,7 +87,11 @@ public function setDisabledActions(
8587
->withDisabledAction(self::ACTION_EDIT_PAGE, $disable_default_actions)
8688
->withDisabledAction(
8789
self::ACTION_ADJUST,
88-
!$this->is_adjusting_questions_with_results_allowed || !$this->is_in_test_with_results
90+
!$this->is_adjusting_questions_with_results_allowed
91+
|| !$this->is_in_test_with_results
92+
|| !\assQuestion::instantiateQuestionGUI(
93+
$record->getGeneralQuestionProperties()->getQuestionId()
94+
)->supportsAdjustment()
8995
)->withDisabledAction(self::ACTION_FEEDBACK, $disable_default_actions)
9096
->withDisabledAction(self::ACTION_HINTS, $disable_default_actions)
9197
->withDisabledAction(self::ACTION_PRINT_ANSWERS, !$this->is_in_test_with_results)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,14 @@ public function getAutoSavedSolutionOutput(
20822082
);
20832083
}
20842084

2085+
public function supportsAdjustment(): bool
2086+
{
2087+
return ($this instanceof ilGuiQuestionScoringAdjustable
2088+
|| $this instanceof ilGuiAnswerScoringAdjustable)
2089+
&& ($this->getObject() instanceof ilObjQuestionScoringAdjustable
2090+
|| $this->getObject() instanceof ilObjAnswerScoringAdjustable);
2091+
}
2092+
20852093
protected function resetSavedPreviewSession(): void
20862094
{
20872095
$this->preview_session = new ilAssQuestionPreviewSession(

0 commit comments

Comments
 (0)