diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index de1b93e216a..8a84c6128b5 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -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.