From 33047d22ffd778090fa85bd866d7f0e30912f9f4 Mon Sep 17 00:00:00 2001
From: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
Date: Sun, 30 Apr 2023 09:27:41 +0100
Subject: [PATCH] Use default penalty in automatic test case generation, rather
than fixing it.
---
questiontestform.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/questiontestform.php b/questiontestform.php
index 18fecd66a..be987c4d8 100644
--- a/questiontestform.php
+++ b/questiontestform.php
@@ -105,9 +105,15 @@ class qtype_stack_question_test_form extends moodleform {
foreach ($question->prts as $prtname => $prt) {
$result = $question->get_prt_result($prtname, $response, false);
$answernotes = $result->get_answernotes();
+ // In automatic test case generation set penalties as the default unless they differ.
+ // If they are the same as the detault, and you want this, you can change it later.
+ $prtpenalty = $result->get_penalty();
+ if ($prtpenalty == $question->penalty) {
+ $prtpenalty = '';
+ }
$mform->getElement($prtname . 'group')->setValue(array(
$prtname . 'score' => $result->get_score(),
- $prtname . 'penalty' => $result->get_penalty(),
+ $prtname . 'penalty' => $prtpenalty,
$prtname . 'answernote' => end($answernotes)));
}
}
--
GitLab