From: tjhunt Date: Thu, 11 Dec 2008 04:57:39 +0000 (+0000) Subject: matching qtype: MDL-14420 Could not use '0' as a question stem. Bloody PHP! X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9ce0983b0dd0f9789ec1a03a13d951af53a8dab6;p=moodle.git matching qtype: MDL-14420 Could not use '0' as a question stem. Bloody PHP! --- diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index 0bef45ef8a..408f03c9a5 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -35,7 +35,8 @@ class question_match_qtype extends default_questiontype { // Insert all the new question+answer pairs foreach ($question->subquestions as $key => $questiontext) { - $answertext = $question->subanswers[$key]; + $questiontext = trim($questiontext); + $answertext = trim($question->subanswers[$key]); if ($questiontext != '' || $answertext != '') { if ($subquestion = array_shift($oldsubquestions)) { // Existing answer, so reuse it $subquestion->questiontext = $questiontext; @@ -199,7 +200,7 @@ class question_match_qtype extends default_questiontype { $responses = array(); foreach ($subquestions as $key => $subquestion) { $response = 0; - if ($subquestion->questiontext) { + if ($subquestion->questiontext !== '') { if ($state->responses[$key]) { $response = $state->responses[$key]; if (!array_key_exists($response, $subquestion->options->answers)) {