From fb1c84336d333b465aeb870e7aba13c8b48bec16 Mon Sep 17 00:00:00 2001 From: Jan Britz Date: Wed, 18 Sep 2024 15:39:41 +0200 Subject: [PATCH] fix: do not set faulty value for checkbox and radio --- classes/question_ui_renderer.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/question_ui_renderer.php b/classes/question_ui_renderer.php index 99b0a2b..bddb719 100644 --- a/classes/question_ui_renderer.php +++ b/classes/question_ui_renderer.php @@ -290,8 +290,10 @@ private function set_input_values_and_readonly(): void { // Set the last saved value. $lastvalue = $this->attempt->get_last_qt_var($name); if (!is_null($lastvalue)) { - if (($type === "checkbox" || $type === "radio") && $element->getAttribute("value") === $lastvalue) { - $element->setAttribute("checked", "checked"); + if ($type === "checkbox" || $type === "radio") { + if ($element->getAttribute("value") === $lastvalue) { + $element->setAttribute("checked", "checked"); + } } else if ($type == "select") { // Find the appropriate option and mark it as selected. /** @var DOMElement $option */