]> git.mjollnir.org Git - moodle.git/commitdiff
matching qtype: MDL-14420 Could not use '0' as a question stem. Bloody PHP!
authortjhunt <tjhunt>
Thu, 11 Dec 2008 04:57:39 +0000 (04:57 +0000)
committertjhunt <tjhunt>
Thu, 11 Dec 2008 04:57:39 +0000 (04:57 +0000)
question/type/match/questiontype.php

index 0bef45ef8a98d34316182b706b7892732f0a26ab..408f03c9a50e02cbebecabfc2903020050fbccbe 100644 (file)
@@ -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)) {