]> git.mjollnir.org Git - moodle.git/commitdiff
matching qtype: MDL-17981 extra distractors feature was not working on MS SQL server...
authortjhunt <tjhunt>
Fri, 23 Jan 2009 02:19:30 +0000 (02:19 +0000)
committertjhunt <tjhunt>
Fri, 23 Jan 2009 02:19:30 +0000 (02:19 +0000)
question/type/match/questiontype.php

index 12c47b456f0d2df09e6c8b93e647154bba63ea0b..68340237fd3ffdf928fa732ad52c92fb181e277b 100644 (file)
@@ -200,11 +200,11 @@ class question_match_qtype extends default_questiontype {
         $responses = array();
         foreach ($subquestions as $key => $subquestion) {
             $response = 0;
-            if ($subquestion->questiontext !== '') {
+            if ($subquestion->questiontext !== '' && !is_null($subquestion->questiontext)) {
                 if ($state->responses[$key]) {
                     $response = $state->responses[$key];
                     if (!array_key_exists($response, $subquestion->options->answers)) {
-                        // If studen's answer did not match by id, but there may be
+                        // If student's answer did not match by id, but there may be
                         // two answers with the same text, but different ids,
                         // so we need to try matching the answer text.
                         $expected_answer = reset($subquestion->options->answers);
@@ -230,7 +230,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 != '' && !is_null($sub->questiontext)) {
                     $responses[$sub->id] = $answer->id;
                 }
             }
@@ -279,7 +279,7 @@ class question_match_qtype extends default_questiontype {
 
         // Print the input controls
         foreach ($subquestions as $key => $subquestion) {
-            if ($subquestion->questiontext !== '') {
+            if ($subquestion->questiontext !== '' && !is_null($subquestion->questiontext)) {
                 // Subquestion text:
                 $a = new stdClass;
                 $a->text = $this->format_text($subquestion->questiontext,
@@ -341,7 +341,7 @@ class question_match_qtype extends default_questiontype {
         $sumgrade = 0;
         $totalgrade = 0;
         foreach ($subquestions as $key => $sub) {
-            if ($sub->questiontext !== '') {
+            if ($sub->questiontext !== '' && !is_null($sub->questiontext)) {
                 $totalgrade += 1;
                 $response = $responses[$key];
                 if ($response && !array_key_exists($response, $sub->options->answers)) {
@@ -393,7 +393,7 @@ class question_match_qtype extends default_questiontype {
         $answers = array();
         if (is_array($question->options->subquestions)) {
             foreach ($question->options->subquestions as $aid => $answer) {
-                if ($answer->questiontext) {
+                if ($answer->questiontext !== '' && !is_null($answer->questiontext)) {
                     $r = new stdClass;
                     $r->answer = $answer->questiontext . ": " . $answer->answertext;
                     $r->credit = 1;