Skip to content
Browse files

Merge branch 'MDL-38542_23' of git://github.com/timhunt/moodle into M…

…OODLE_23_STABLE
  • Loading branch information...
2 parents 6211a05 + e24cb35 commit b2b512671d55ae6654896a21c7d8905f0ab681c9 @stronk7 stronk7 committed Mar 19, 2013
Showing with 14 additions and 2 deletions.
  1. +2 −2 question/type/shortanswer/question.php
  2. +12 −0 question/type/shortanswer/tests/question_test.php
View
4 question/type/shortanswer/question.php
@@ -117,7 +117,7 @@ public static function compare_string_with_wildcard($string, $pattern, $ignoreca
* @return string the normalised string.
*/
protected static function safe_normalize($string) {
- if (!$string) {
+ if ($string === '') {
return '';
}
@@ -126,7 +126,7 @@ protected static function safe_normalize($string) {
}
$normalised = normalizer_normalize($string, Normalizer::FORM_C);
- if (!$normalised) {
+ if (is_null($normalised)) {
// An error occurred in normalizer_normalize, but we have no idea what.
debugging('Failed to normalise string: ' . $string, DEBUG_DEVELOPER);
return $string; // Return the original string, since it is the best we have.
View
12 question/type/shortanswer/tests/question_test.php
@@ -120,6 +120,18 @@ public function test_compare_string_with_wildcard() {
}
}
+ public function test_compare_0_with_wildcard() {
+ // Test the classic PHP problem case with '0'.
+ $this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard(
+ '0', '0', false));
+ $this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard(
+ '0', '0*', false));
+ $this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard(
+ '0', '*0', false));
+ $this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard(
+ '0', '*0*', false));
+ }
+
public function test_is_complete_response() {
$question = test_question_maker::make_question('shortanswer');

0 comments on commit b2b5126

Please sign in to comment.
Something went wrong with that request. Please try again.