From 9ce0983b0dd0f9789ec1a03a13d951af53a8dab6 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 11 Dec 2008 04:57:39 +0000 Subject: [PATCH] matching qtype: MDL-14420 Could not use '0' as a question stem. Bloody PHP! --- question/type/match/questiontype.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)) { -- 2.39.5