MDL-39283 GIFT and XML question export broken for unsupported qtypes
authorJean-Michel Vedrine <vedrine@vedrine.org>
Mon, 22 Apr 2013 14:21:54 +0000 (16:21 +0200)
committerJean-Michel Vedrine <vedrine@vedrine.org>
Tue, 23 Apr 2013 07:59:31 +0000 (09:59 +0200)
Do no write any data to the export for unsupported qtypes

question/format/gift/format.php
question/format/xml/format.php

index ecca6e2..cac8374 100644 (file)
@@ -719,10 +719,6 @@ class qformat_gift extends qformat_default {
             // Check for plugins
             if ($out = $this->try_exporting_using_qtypes($question->qtype, $question)) {
                 $expout .= $out;
-            } else {
-                $expout .= "Question type $question->qtype is not supported\n";
-                echo $OUTPUT->notification(get_string('nohandler', 'qformat_gift',
-                        question_bank::get_qtype_name($question->qtype)));
             }
         }
 
index 9c8304c..9acb480 100644 (file)
@@ -1095,6 +1095,7 @@ class qformat_xml extends qformat_default {
     public function writequestion($question) {
         global $CFG, $OUTPUT;
 
+        $invalidquestion = false;
         $fs = get_file_storage();
         $contextid = $question->contextid;
         // Get files used by the questiontext.
@@ -1402,11 +1403,12 @@ class qformat_xml extends qformat_default {
                 break;
 
             default:
-                // try support by optional plugin
+                // Try support by optional plugin.
                 if (!$data = $this->try_exporting_using_qtypes($question->qtype, $question)) {
-                    notify(get_string('unsupportedexport', 'qformat_xml', $question->qtype));
+                    $invalidquestion = true;
+                } else {
+                    $expout .= $data;
                 }
-                $expout .= $data;
         }
 
         // Output any hints.
@@ -1427,8 +1429,11 @@ class qformat_xml extends qformat_default {
 
         // close the question tag
         $expout .= "  </question>\n";
-
-        return $expout;
+        if ($invalidquestion) {
+            return '';
+        } else {
+            return $expout;
+        }
     }
 
     public function write_answers($answers) {