From b398b77c5cf3b75365b9031413ee9de1e2a382e9 Mon Sep 17 00:00:00 2001 From: "DLM Office unipd.it" <107851847+DLM-unipd@users.noreply.github.com> Date: Wed, 6 Aug 2025 13:52:34 +0200 Subject: [PATCH 1/2] Fix numerical response value Removed the is_numeric() check since the preg_replace() function already handles the extraction of valid numeric values. This fix properly processes inputs with comma decimal separators and maintains the intended behavior while simplifying the code. --- classes/responsetype/numericaltext.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/responsetype/numericaltext.php b/classes/responsetype/numericaltext.php index be14d4e3d..fbaeec94b 100644 --- a/classes/responsetype/numericaltext.php +++ b/classes/responsetype/numericaltext.php @@ -34,7 +34,8 @@ class numericaltext extends text { */ public static function answers_from_webform($responsedata, $question) { $answers = []; - if (isset($responsedata->{'q'.$question->id}) && is_numeric($responsedata->{'q'.$question->id})) { + // Do not check with is_numeric, all the characters replacing needs to be done for non-numeric + if (isset($responsedata->{'q'.$question->id})) { $val = $responsedata->{'q' . $question->id}; // Allow commas as well as points in decimal numbers. $val = str_replace(",", ".", $responsedata->{'q' . $question->id}); From 67e2e91b193d429b24f3703cd269cd11bd7086b1 Mon Sep 17 00:00:00 2001 From: "DLM Office unipd.it" <107851847+DLM-unipd@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:04:11 +0200 Subject: [PATCH 2/2] fix comment --- classes/responsetype/numericaltext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/responsetype/numericaltext.php b/classes/responsetype/numericaltext.php index fbaeec94b..f94dd7d1d 100644 --- a/classes/responsetype/numericaltext.php +++ b/classes/responsetype/numericaltext.php @@ -34,7 +34,7 @@ class numericaltext extends text { */ public static function answers_from_webform($responsedata, $question) { $answers = []; - // Do not check with is_numeric, all the characters replacing needs to be done for non-numeric + // Do not check with is_numeric, all the characters replacing needs to be done for non-numeric. if (isset($responsedata->{'q'.$question->id})) { $val = $responsedata->{'q' . $question->id}; // Allow commas as well as points in decimal numbers.