diff --git a/question/format.php b/question/format.php
index 14f24839613..93280a78288 100644
--- a/question/format.php
+++ b/question/format.php
@@ -387,7 +387,7 @@ class qformat_default {
$question->modifiedby = $USER->id;
$question->timemodified = time();
$fileoptions = array(
- 'subdirs' => false,
+ 'subdirs' => true,
'maxfiles' => -1,
'maxbytes' => 0,
);
diff --git a/question/format/xml/format.php b/question/format/xml/format.php
index df9e6094bbe..304d3794c8c 100644
--- a/question/format/xml/format.php
+++ b/question/format/xml/format.php
@@ -169,11 +169,13 @@ class qformat_xml extends qformat_default {
}
$fs = get_file_storage();
$itemid = file_get_unused_draft_itemid();
- $filenames = array();
+ $filepaths = array();
foreach ($xml as $file) {
- $filename = $file['@']['name'];
- if (in_array($filename, $filenames)) {
- debugging('Duplicate file in XML: ' . $filename, DEBUG_DEVELOPER);
+ $filename = $this->getpath($file, array('@', 'name'), '', true);
+ $filepath = $this->getpath($file, array('@', 'path'), '/', true);
+ $fullpath = $filepath . $filename;
+ if (in_array($fullpath, $filepaths)) {
+ debugging('Duplicate file in XML: ' . $fullpath, DEBUG_DEVELOPER);
continue;
}
$filerecord = array(
@@ -181,11 +183,11 @@ class qformat_xml extends qformat_default {
'component' => 'user',
'filearea' => 'draft',
'itemid' => $itemid,
- 'filepath' => '/',
+ 'filepath' => $filepath,
'filename' => $filename,
);
$fs->create_file_from_string($filerecord, base64_decode($file['#']));
- $filenames[] = $filename;
+ $filepaths[] = $fullpath;
}
return $itemid;
}
@@ -1092,9 +1094,9 @@ class qformat_xml extends qformat_default {
if ($file->is_directory()) {
continue;
}
- $string .= '