Index: questiontype.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/shortanswer/questiontype.php,v retrieving revision 1.20.2.8 diff -u -r1.20.2.8 questiontype.php --- questiontype.php 28 Aug 2008 01:46:48 -0000 1.20.2.8 +++ questiontype.php 16 Nov 2008 19:59:54 -0000 @@ -181,12 +181,13 @@ // ULPGC ecastro function check_response(&$question, &$state) { $answers = &$question->options->answers; - $testedstate = clone($state); - $teststate = clone($state); - foreach($answers as $aid => $answer) { - $teststate->responses[''] = trim($answer->answer); - if($this->compare_responses($question, $testedstate, $teststate)) { - return $aid; + if(isset($state->responses[''])){ + $trimmedresponse=trim(stripslashes_safe($state->responses[''])); + foreach($answers as $aid => $answer) { + if($this->compare_string_with_wildcard($trimmedresponse,trim($answer->answer), + !$question->options->usecase)) { + return $aid; + } } } return false; @@ -195,7 +196,7 @@ function compare_responses($question, $state, $teststate) { if (isset($state->responses['']) && isset($teststate->responses[''])) { return $this->compare_string_with_wildcard(stripslashes_safe($state->responses['']), - $teststate->responses[''], !$question->options->usecase); + $teststate->responses[''], !$question->options->usecase, false); } return false; } @@ -207,16 +208,20 @@ $answer->answer, !$question->options->usecase); } - function compare_string_with_wildcard($string, $pattern, $ignorecase) { - // Break the string on non-escaped asterisks. - $bits = preg_split('/(?