MDL-32865 Backwards compatibility, deal with the old image tag

This commit is contained in:
Jean-Michel Vedrine 2012-11-01 11:16:01 +01:00
parent 7c86628de6
commit bedbfd6dfa

View File

@ -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 .= ' <img src="@@PLUGINFILE@@/' . $data->name . '" />';
}
// restore files in generalfeedback
$qo->generalfeedback = $this->getpath($question,
array('#', 'generalfeedback', 0, '#', 'text', 0, '#'), $qo->generalfeedback, true);