MDL-49025 assign: Submissions of an empty directory should not save

Before this change if only a folder was submitted the submission_is_empty
check would return true. This meant that the draft area would be saved.
The is_empty check would then be called which would return false. This
caused the submission form to indicate to the user that the submission
had failed.

Now is_empty and submission_is_empty should both return false if only
folders are submitted.
This commit is contained in:
Neill Magill 2018-06-01 10:53:06 +01:00
parent 3ebfab9810
commit 650779d609

View File

@ -513,8 +513,16 @@ class assign_submission_file extends assign_submission_plugin {
* @return bool
*/
public function submission_is_empty(stdClass $data) {
$files = file_get_drafarea_files($data->files_filemanager);
return count($files->list) == 0;
global $USER;
$fs = get_file_storage();
// Get a count of all the draft files, excluding any directories.
$files = $fs->get_area_files(context_user::instance($USER->id)->id,
'user',
'draft',
$data->files_filemanager,
'id',
false);
return count($files) == 0;
}
/**