MDL-59954 mod_course: Remove file size restriction on D&D on course page

Remove file size restrictions for teachers on course page.
Use user_max_upload_file_size instead of the max_file_size
This commit is contained in:
Peter 2018-12-07 12:26:46 +08:00
parent 33a388eff7
commit 6afbdf2778
2 changed files with 3 additions and 3 deletions

View file

@ -744,7 +744,7 @@ M.course_dndupload = {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var self = this; var self = this;
if (file.size > this.maxbytes) { if (this.maxbytes > 0 && file.size > this.maxbytes) {
new M.core.alert({message: M.util.get_string('namedfiletoolarge', 'moodle', {filename: file.name})}); new M.core.alert({message: M.util.get_string('namedfiletoolarge', 'moodle', {filename: file.name})});
return; return;
} }

View file

@ -73,7 +73,7 @@ function dndupload_add_to_course($course, $modnames) {
); );
$vars = array( $vars = array(
array('courseid' => $course->id, array('courseid' => $course->id,
'maxbytes' => get_max_upload_file_size($CFG->maxbytes, $course->maxbytes), 'maxbytes' => get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $course->maxbytes),
'handlers' => $handler->get_js_data(), 'handlers' => $handler->get_js_data(),
'showstatus' => $showstatus) 'showstatus' => $showstatus)
); );
@ -488,7 +488,7 @@ class dndupload_ajax_processor {
// Add the file to a draft file area. // Add the file to a draft file area.
$draftitemid = file_get_unused_draft_itemid(); $draftitemid = file_get_unused_draft_itemid();
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $this->course->maxbytes); $maxbytes = get_user_max_upload_file_size($this->context, $CFG->maxbytes, $this->course->maxbytes);
$types = $this->dnduploadhandler->get_handled_file_types($this->module->name); $types = $this->dnduploadhandler->get_handled_file_types($this->module->name);
$repo = repository::get_instances(array('type' => 'upload', 'currentcontext' => $this->context)); $repo = repository::get_instances(array('type' => 'upload', 'currentcontext' => $this->context));
if (empty($repo)) { if (empty($repo)) {