From 758a2cdf23f39888715e030809fdf5de9a02deab Mon Sep 17 00:00:00 2001
From: Chris Sangwin <C.J.Sangwin@ed.ac.uk>
Date: Tue, 14 Nov 2023 18:49:12 +0000
Subject: [PATCH] WIP fix to issue #1053: strings being used to define PRT
scores.
---
questiontype.php | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/questiontype.php b/questiontype.php
index 34a6af73e..57e265825 100644
--- a/questiontype.php
+++ b/questiontype.php
@@ -1085,13 +1085,16 @@ class qtype_stack extends question_type {
foreach ($q->prts as $index => $prt) {
foreach ($prt->get_nodes_summary() as $nodeid => $choices) {
- $parts[$index . '-' . $nodeid] = array(
- $choices->falseanswernote => new question_possible_response(
- $choices->falseanswernote, $choices->falsescore * $prt->get_value()),
- $choices->trueanswernote => new question_possible_response(
- $choices->trueanswernote, $choices->truescore * $prt->get_value()),
- null => question_possible_response::no_response(),
- );
+ // STACK allows variables in scores, which may not be evaluated.
+ if (is_numeric($choices->falsescore) && is_numeric($choices->truescore)) {
+ $parts[$index . '-' . $nodeid] = array(
+ $choices->falseanswernote => new question_possible_response(
+ $choices->falseanswernote, $choices->falsescore * $prt->get_value()),
+ $choices->trueanswernote => new question_possible_response(
+ $choices->trueanswernote, $choices->truescore * $prt->get_value()),
+ null => question_possible_response::no_response(),
+ );
+ }
}
}
--
GitLab