]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11708 - Zero answers are not allowed in Matching questions - sometimes I hate...
authortjhunt <tjhunt>
Mon, 22 Oct 2007 16:57:19 +0000 (16:57 +0000)
committertjhunt <tjhunt>
Mon, 22 Oct 2007 16:57:19 +0000 (16:57 +0000)
question/type/match/edit_match_form.php
question/type/match/questiontype.php

index c05302993bc2f6097c27438431dc3fce4949d4f0..e60e10cafdcf35343696ed40c0c3df083e36f8f9 100644 (file)
@@ -78,10 +78,10 @@ class question_edit_match_form extends question_edit_form {
         foreach ($questions as $key => $question){
             $trimmedquestion = trim($question);
             $trimmedanswer = trim($answers[$key]);
-            if (!empty($trimmedanswer) && !empty($trimmedquestion)){
+            if ($trimmedanswer != '' && $trimmedquestion != ''){
                 $questioncount++;
             }
-            if (!empty($trimmedquestion) && empty($trimmedanswer)){
+            if ($trimmedquestion != '' && $trimmedanswer == ''){
                 $errors['subanswers['.$key.']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
             }
         }
index f4d9996deef4c29159c11f29856969e1d00fe4c1..8e90af878f5cb339959173f32b3fbb1a4b161e7d 100644 (file)
@@ -34,7 +34,7 @@ class question_match_qtype extends default_questiontype {
         // Insert all the new question+answer pairs
         foreach ($question->subquestions as $key => $questiontext) {
             $answertext = $question->subanswers[$key];
-            if (!empty($questiontext) or !empty($answertext)) {
+            if ($questiontext != '' || $answertext != '') {
                 if ($subquestion = array_shift($oldsubquestions)) {  // Existing answer, so reuse it
                     $subquestion->questiontext = $questiontext;
                     $subquestion->answertext   = $answertext;
@@ -59,7 +59,7 @@ class question_match_qtype extends default_questiontype {
                 }
                 $subquestions[] = $subquestion->id;
             }
-            if (!empty($questiontext) && empty($answertext)) {
+            if ($questiontext != '' && $answertext == '') {
                 $result->notice = get_string('nomatchinganswer', 'quiz', $questiontext);
             }
         }
@@ -223,7 +223,7 @@ class question_match_qtype extends default_questiontype {
         $responses = array();
         foreach ($state->options->subquestions as $sub) {
             foreach ($sub->options->answers as $answer) {
-                if (1 == $answer->fraction && $sub->questiontext) {
+                if (1 == $answer->fraction && $sub->questiontext != '') {
                     $responses[$sub->id] = $answer->id;
                 }
             }
@@ -272,7 +272,7 @@ class question_match_qtype extends default_questiontype {
 
         // Print the input controls
         foreach ($subquestions as $key => $subquestion) {
-            if ($subquestion->questiontext) {
+            if ($subquestion->questiontext != '') {
                 // Subquestion text:
                 $a = new stdClass;
                 $a->text = $this->format_text($subquestion->questiontext,