From 49580a59d1d41a90746a3b09655730b694d29aa0 Mon Sep 17 00:00:00 2001 From: Pierre Pichet Date: Fri, 4 Jun 2010 12:28:45 +0000 Subject: [PATCH] MDL-20296 add isset() tests in function split_old_answer () lines 358-362 --- question/type/numerical/questiontype.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index 0dd1a61d8b500..a4526b1b1a4c6 100644 --- a/question/type/numerical/questiontype.php +++ b/question/type/numerical/questiontype.php @@ -356,8 +356,12 @@ function split_old_answer($rawresponse, $units, &$answer ,&$unit ) { $rawresponse = str_replace($search, $replace, trim($rawresponse)); if (preg_match('~^([+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][-+]?[0-9]+)?)([^0-9].*)?$~', $rawresponse, $responseparts)) { - $unit = $responseparts[5] ; - $answer = $responseparts[1] ; + if(isset($responseparts[5]) ){ + $unit = $responseparts[5] ; + } + if(isset($responseparts[1]) ){ + $answer = $responseparts[1] ; + } } return ; }