From efa9b7fa01ef37de6d0fb226c7797e87c0c86ecd Mon Sep 17 00:00:00 2001 From: kaipe Date: Mon, 17 Jan 2005 20:14:16 +0000 Subject: [PATCH] Fixed a bug that was reported by James Balfour: Numerical/Calculated questions failed to grade negative responses on questions with units. --- mod/quiz/questiontypes/numerical/questiontype.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/quiz/questiontypes/numerical/questiontype.php b/mod/quiz/questiontypes/numerical/questiontype.php index 5afbd93d7030b..b6e519da1c23f 100644 --- a/mod/quiz/questiontypes/numerical/questiontype.php +++ b/mod/quiz/questiontypes/numerical/questiontype.php @@ -163,7 +163,7 @@ function grade_response($question, $nameprefix, $addedanswercondition='') { unset($responsenum); // Answer is not numeric } } else if (ereg( - '^(([0-9]+(\\.[0-9]*)?|[.][0-9]+)([eE][-+]?[0-9]+)?)([^0-9].*)?$', + '^([+-]?([0-9]+(\\.[0-9]*)?|[.][0-9]+)([eE][-+]?[0-9]+)?)([^0-9].*)?$', $responsenum, $responseparts)) { $responsenum = (float)$responseparts[1]; if ($responseparts[5]) {