Skip to content

Commit

Permalink
fix: do not set faulty value for checkbox and radio
Browse files Browse the repository at this point in the history
  • Loading branch information
janbritz committed Sep 18, 2024
1 parent 7ddafcf commit fb1c843
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/question_ui_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit fb1c843

Please sign in to comment.