Navigation Menu

Skip to content

Commit

Permalink
MDL-37967 Improve XML question import format handling of duplicated f…
Browse files Browse the repository at this point in the history
…iles
  • Loading branch information
Jean-Michel Vedrine committed Feb 18, 2013
1 parent 09de5eb commit ddc03b1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion question/format/xml/format.php
Expand Up @@ -170,16 +170,23 @@ public function import_files_as_draft($xml) {
}
$fs = get_file_storage();
$itemid = file_get_unused_draft_itemid();
$filenames = array();
foreach ($xml as $file) {
$filename = $file['@']['name'];
if (in_array($filename, $filenames)) {
debugging('Duplicate file in XML: ' . $filename, DEBUG_DEVELOPER);
continue;
}
$filerecord = array(
'contextid' => context_user::instance($USER->id)->id,
'component' => 'user',
'filearea' => 'draft',
'itemid' => $itemid,
'filepath' => '/',
'filename' => $file['@']['name'],
'filename' => $filename,
);
$fs->create_file_from_string($filerecord, base64_decode($file['#']));
$filenames[] = $filename;
}
return $itemid;
}
Expand Down

0 comments on commit ddc03b1

Please sign in to comment.