MDL-70842 mod_assign: Add more cases to add file to archive

This commit is contained in:
Tomo Tsuyuki 2021-03-24 16:00:00 +11:00
parent 4c26696e7e
commit 9a46c4da29

View File

@ -3654,8 +3654,15 @@ class assign {
$zipwriter = \core_files\archive_writer::get_stream_writer($filename, \core_files\archive_writer::ZIP_WRITER);
// Stream the files into the zip.
foreach ($filesforzipping as $pathinzip => $storedfile) {
$zipwriter->add_file_from_stored_file($pathinzip, $storedfile);
foreach ($filesforzipping as $pathinzip => $file) {
if ($file instanceof \stored_file) {
// Most of cases are \stored_file.
$zipwriter->add_file_from_stored_file($pathinzip, $file);
} else if (is_array($file)) {
// Save $file as contents, from onlinetext subplugin.
$content = reset($file);
$zipwriter->add_file_from_string($pathinzip, $content);
}
}
// Finish the archive.