Skip to content

Commit

Permalink
Merge branch 'MDL-43000_24' of git://github.com/timhunt/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_24_STABLE
  • Loading branch information
danpoltawski committed Nov 26, 2013
2 parents e5ca507 + 70127f1 commit 7d784e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions question/type/shortanswer/question.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ public static function compare_string_with_wildcard($string, $pattern, $ignoreca
$pattern = self::safe_normalize($pattern); $pattern = self::safe_normalize($pattern);
$string = self::safe_normalize($string); $string = self::safe_normalize($string);


// Break the string on non-escaped asterisks. // Break the string on non-escaped runs of asterisks.
$bits = preg_split('/(?<!\\\\)\*/', $pattern); // ** is equivalent to *, but people were doing that, and with many *s it breaks preg.
$bits = preg_split('/(?<!\\\\)\*+/', $pattern);

// Escape regexp special characters in the bits. // Escape regexp special characters in the bits.
$excapedbits = array(); $excapedbits = array();
foreach ($bits as $bit) { foreach ($bits as $bit) {
Expand Down
6 changes: 6 additions & 0 deletions question/type/shortanswer/tests/question_test.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ public function test_compare_0_with_wildcard() {
'0', '*0*', false)); '0', '*0*', false));
} }


public function test_compare_string_with_wildcard_many_stars() {
// Test the classic PHP problem case with '0'.
$this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard(
'<em></em>', '***********************************<em>***********************************</em>', false));
}

public function test_is_complete_response() { public function test_is_complete_response() {
$question = test_question_maker::make_question('shortanswer'); $question = test_question_maker::make_question('shortanswer');


Expand Down

0 comments on commit 7d784e4

Please sign in to comment.