mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
Merge branch 'MDL-38542' of git://github.com/timhunt/moodle
This commit is contained in:
commit
b81d5eab90
2 changed files with 14 additions and 2 deletions
|
@ -117,7 +117,7 @@ class qtype_shortanswer_question extends question_graded_by_strategy
|
||||||
* @return string the normalised string.
|
* @return string the normalised string.
|
||||||
*/
|
*/
|
||||||
protected static function safe_normalize($string) {
|
protected static function safe_normalize($string) {
|
||||||
if (!$string) {
|
if ($string === '') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class qtype_shortanswer_question extends question_graded_by_strategy
|
||||||
}
|
}
|
||||||
|
|
||||||
$normalised = normalizer_normalize($string, Normalizer::FORM_C);
|
$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.
|
// An error occurred in normalizer_normalize, but we have no idea what.
|
||||||
debugging('Failed to normalise string: ' . $string, DEBUG_DEVELOPER);
|
debugging('Failed to normalise string: ' . $string, DEBUG_DEVELOPER);
|
||||||
return $string; // Return the original string, since it is the best we have.
|
return $string; // Return the original string, since it is the best we have.
|
||||||
|
|
|
@ -120,6 +120,18 @@ class qtype_shortanswer_question_test extends advanced_testcase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public function test_is_complete_response() {
|
||||||
$question = test_question_maker::make_question('shortanswer');
|
$question = test_question_maker::make_question('shortanswer');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue