From bedbfd6dfa3cf51e364cac46a6aed0ab664093b4 Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Thu, 1 Nov 2012 11:16:01 +0100 Subject: [PATCH] MDL-32865 Backwards compatibility, deal with the old image tag --- question/format/xml/format.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/question/format/xml/format.php b/question/format/xml/format.php index cf3b7f7347f..71865829271 100644 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -443,6 +443,19 @@ class qformat_xml extends qformat_default { $qo->questiontextfiles = $this->import_files($this->getpath($question, array('#', 'questiontext', 0, '#', 'file'), array(), false)); + // Backwards compatibility, deal with the old image tag. + $filedata = $this->getpath($question, array('#', 'image_base64', '0', '#'), null, false); + $filename = $this->getpath($question, array('#', 'image', '0', '#'), null, false); + if ($filedata && $filename) { + $data = new stdClass(); + $data->content = $filedata; + $data->encoding = 'base64'; + // Question file areas don't support subdirs, so convert path to filename if necessary. + $data->name = clean_param(str_replace('/', '_', $filename), PARAM_FILE); + $qo->questiontextfiles[] = $data; + $qo->questiontext .= ' '; + } + // restore files in generalfeedback $qo->generalfeedback = $this->getpath($question, array('#', 'generalfeedback', 0, '#', 'text', 0, '#'), $qo->generalfeedback, true);