From 5312d1fbeb04ba9adade3dd32c8f4ab482afec43 Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Mon, 22 Apr 2013 16:21:54 +0200 Subject: [PATCH] MDL-39283 GIFT and XML question export broken for unsupported qtypes Do no write any data to the export for unsupported qtypes --- question/format/gift/format.php | 4 ---- question/format/xml/format.php | 15 ++++++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/question/format/gift/format.php b/question/format/gift/format.php index ecca6e2e852..cac8374f1ae 100644 --- a/question/format/gift/format.php +++ b/question/format/gift/format.php @@ -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))); } } diff --git a/question/format/xml/format.php b/question/format/xml/format.php index 9c8304c6a1f..9acb480a271 100644 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -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 .= " \n"; - - return $expout; + if ($invalidquestion) { + return ''; + } else { + return $expout; + } } public function write_answers($answers) { -- 2.43.0