Skip to content

Commit

Permalink
MDL-70842 mod_assign: Add more cases to add file to archive
Browse files Browse the repository at this point in the history
  • Loading branch information
TomoTsuyuki committed Mar 24, 2021
1 parent 4c26696 commit 9a46c4d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3654,8 +3654,15 @@ protected function download_submissions($userids = false) {
$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.
Expand Down

0 comments on commit 9a46c4d

Please sign in to comment.