mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-39359 - mod/assign: Allow zipped folder to be uploaded for returning feedback files
The "Upload multiple feedback files in a zip" feature is convenient, but requires that the files sit directly within the zip file. As the files will most likely be extracted to a folder after downloading, it's quite reasonable to expect teachers to zip the folder up rather than selecting all files and zipping them. This patch allows for a zipped folder to be uploaded; if the only file found after extracting is a directory, the contents of the directory are used instead of the results of the extraction.
This commit is contained in:
parent
ffc3f5308b
commit
381e6d7359
1 changed files with 13 additions and 6 deletions
|
@ -194,6 +194,17 @@ class assignfeedback_file_zip_importer {
|
||||||
$USER->id,
|
$USER->id,
|
||||||
'/import/');
|
'/import/');
|
||||||
|
|
||||||
|
$keys = array_keys($files);
|
||||||
|
if (count($files) == 1 && $files[$keys[0]]->is_directory()) {
|
||||||
|
// An entire folder was zipped, rather than its contents.
|
||||||
|
// We need to return the contents of the folder instead, so the import can continue.
|
||||||
|
$files = $fs->get_directory_files($contextid,
|
||||||
|
'assignfeedback_file',
|
||||||
|
ASSIGNFEEDBACK_FILE_IMPORT_FILEAREA,
|
||||||
|
$USER->id,
|
||||||
|
$files[$keys[0]]->get_filepath());
|
||||||
|
}
|
||||||
|
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +216,7 @@ class assignfeedback_file_zip_importer {
|
||||||
* @return string - The html response
|
* @return string - The html response
|
||||||
*/
|
*/
|
||||||
public function import_zip_files($assignment, $fileplugin) {
|
public function import_zip_files($assignment, $fileplugin) {
|
||||||
global $USER, $CFG, $PAGE, $DB;
|
global $CFG, $PAGE, $DB;
|
||||||
|
|
||||||
@set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
|
@set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
|
||||||
$packer = get_file_packer('application/zip');
|
$packer = get_file_packer('application/zip');
|
||||||
|
@ -216,11 +227,7 @@ class assignfeedback_file_zip_importer {
|
||||||
$contextid = $assignment->get_context()->id;
|
$contextid = $assignment->get_context()->id;
|
||||||
|
|
||||||
$fs = get_file_storage();
|
$fs = get_file_storage();
|
||||||
$files = $fs->get_directory_files($contextid,
|
$files = $this->get_import_files($contextid);
|
||||||
'assignfeedback_file',
|
|
||||||
ASSIGNFEEDBACK_FILE_IMPORT_FILEAREA,
|
|
||||||
$USER->id,
|
|
||||||
'/import/');
|
|
||||||
|
|
||||||
$currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
|
$currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
|
||||||
$allusers = $assignment->list_participants($currentgroup, false);
|
$allusers = $assignment->list_participants($currentgroup, false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue