Skip to content

Commit

Permalink
MDL-39283 GIFT and XML question export broken for unsupported qtypes
Browse files Browse the repository at this point in the history
Do no write any data to the export for unsupported qtypes
  • Loading branch information
Jean-Michel Vedrine committed Apr 23, 2013
1 parent dd8e2dd commit 5312d1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 0 additions & 4 deletions question/format/gift/format.php
Expand Up @@ -719,10 +719,6 @@ public function writequestion($question) {
// 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)));
}
}

Expand Down
15 changes: 10 additions & 5 deletions question/format/xml/format.php
Expand Up @@ -1095,6 +1095,7 @@ protected function presave_process($content) {
public function writequestion($question) {
global $CFG, $OUTPUT;

$invalidquestion = false;
$fs = get_file_storage();
$contextid = $question->contextid;
// Get files used by the questiontext.
Expand Down Expand Up @@ -1402,11 +1403,12 @@ public function writequestion($question) {
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.
Expand All @@ -1427,8 +1429,11 @@ public function writequestion($question) {

// close the question tag
$expout .= " </question>\n";

return $expout;
if ($invalidquestion) {
return '';
} else {
return $expout;
}
}

public function write_answers($answers) {
Expand Down

0 comments on commit 5312d1f

Please sign in to comment.