From 6afbdf27789a48ae5d1dd620ddf1b61300eb1bf4 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 7 Dec 2018 12:26:46 +0800 Subject: [PATCH] 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 --- course/dndupload.js | 2 +- course/dnduploadlib.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/course/dndupload.js b/course/dndupload.js index 05b5e40c2c5..5d26d88ff25 100644 --- a/course/dndupload.js +++ b/course/dndupload.js @@ -744,7 +744,7 @@ M.course_dndupload = { var xhr = new XMLHttpRequest(); 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})}); return; } diff --git a/course/dnduploadlib.php b/course/dnduploadlib.php index 430f1e57dfc..11289b1b3f5 100644 --- a/course/dnduploadlib.php +++ b/course/dnduploadlib.php @@ -73,7 +73,7 @@ function dndupload_add_to_course($course, $modnames) { ); $vars = array( 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(), 'showstatus' => $showstatus) ); @@ -488,7 +488,7 @@ class dndupload_ajax_processor { // Add the file to a draft file area. $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); $repo = repository::get_instances(array('type' => 'upload', 'currentcontext' => $this->context)); if (empty($repo)) {