Skip to content

Commit

Permalink
MDL-69559 admin: Add course download admin settings and lang strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mickhawkins committed Oct 26, 2020
1 parent aed0ee0 commit 11456d7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
28 changes: 28 additions & 0 deletions admin/settings/courses.php
Expand Up @@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use core_admin\local\settings\filesize;

$capabilities = array(
'moodle/backup:backupcourse',
'moodle/category:manage',
Expand Down Expand Up @@ -75,6 +77,17 @@
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
1, $choices));

// Enable/disable download course content.
$choices = [
DOWNLOAD_COURSE_CONTENT_DISABLED => new lang_string('no'),
DOWNLOAD_COURSE_CONTENT_ENABLED => new lang_string('yes'),
];
$downloadcontentsitedefault = new admin_setting_configselect('moodlecourse/downloadcontentsitedefault',
new lang_string('enabledownloadcoursecontent', 'course'),
new lang_string('downloadcoursecontent_help', 'course'), 0, $choices);
$downloadcontentsitedefault->add_dependent_on('downloadcoursecontentallowed');
$temp->add($downloadcontentsitedefault);

// Course format.
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));

Expand Down Expand Up @@ -161,6 +174,21 @@

$ADMIN->add('courses', $temp);

// Download course content.
$downloadcoursedefaulturl = new moodle_url('/admin/settings.php', ['section' => 'coursesettings']);
$temp = new admin_settingpage('downloadcoursecontent', new lang_string('downloadcoursecontent', 'course'));
$temp->add(new admin_setting_configcheckbox('downloadcoursecontentallowed',
new lang_string('downloadcoursecontentallowed', 'admin'),
new lang_string('downloadcoursecontentallowed_desc', 'admin', $downloadcoursedefaulturl->out()), 0));

// 50MB default maximum size per file when downloading course content.
$defaultmaxdownloadsize = 50 * filesize::UNIT_MB;
$temp->add(new filesize('maxsizeperdownloadcoursefile', new lang_string('maxsizeperdownloadcoursefile', 'admin'),
new lang_string('maxsizeperdownloadcoursefile_desc', 'admin'), $defaultmaxdownloadsize, filesize::UNIT_MB));
$temp->hide_if('maxsizeperdownloadcoursefile', 'downloadcoursecontentallowed');

$ADMIN->add('courses', $temp);

// "courserequests" settingpage.
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
$temp->add(new admin_setting_configcheckbox('enablecourserequests',
Expand Down
5 changes: 5 additions & 0 deletions course/lib.php
Expand Up @@ -71,6 +71,11 @@
// Course activity chooser footer default display option.
define('COURSE_CHOOSER_FOOTER_NONE', 'hidden');

// Download course content options.
define('DOWNLOAD_COURSE_CONTENT_DISABLED', 0);
define('DOWNLOAD_COURSE_CONTENT_ENABLED', 1);
define('DOWNLOAD_COURSE_CONTENT_SITE_DEFAULT', 2);

function make_log_url($module, $url) {
switch ($module) {
case 'course':
Expand Down
4 changes: 4 additions & 0 deletions lang/en/admin.php
Expand Up @@ -516,6 +516,8 @@
$string['doesnotfit'] = 'Email display settings';
$string['doesnotfitdetail'] = 'Display settings for email leaving Moodle.';
$string['download'] = 'Download';
$string['downloadcoursecontentallowed'] = 'Download course content feature available';
$string['downloadcoursecontentallowed_desc'] = 'Whether the download course content feature is available to courses. When available, course content downloads can be enabled/disabled using the "Enable download course content" setting within the course edit menu (the default for this can be set in <a href={$a} target="_blank">Course default settings</a>).';
$string['durationunits'] = 'duration units';
$string['edithelpdocs'] = 'Edit help documents';
$string['editlang'] = '<b>Edit</b>';
Expand Down Expand Up @@ -802,6 +804,8 @@
from a STABLE branch of the Moodle code. See Moodle Docs for more details.';
$string['maxbytes'] = 'Maximum uploaded file size';
$string['maxconsecutiveidentchars'] = 'Consecutive identical characters';
$string['maxsizeperdownloadcoursefile'] = 'Maximum size per file';
$string['maxsizeperdownloadcoursefile_desc'] = 'The maximum size of each file when downloading course content. Files exceeding this size will be omitted from the download.';
$string['maxeditingtime'] = 'Maximum time to edit posts';
$string['maxusersperpage'] = ' Maximum users per page';
$string['configmaxusersperpage'] = 'Maximum number of users displayed within user selector in course, group, cohort, webservice etc.';
Expand Down
3 changes: 3 additions & 0 deletions lang/en/course.php
Expand Up @@ -54,6 +54,9 @@
$string['customfield_visibletoall'] = 'Everyone';
$string['customfield_visibletoteachers'] = 'Teachers';
$string['customfieldsettings'] = 'Common course custom fields settings';
$string['downloadcoursecontent'] = 'Download course content';
$string['downloadcoursecontent_help'] = 'This setting determines whether course content may be downloaded by users with the download course content capability (by default users with the role of student or teacher).';
$string['enabledownloadcoursecontent'] = 'Enable download course content';
$string['errorendbeforestart'] = 'The end date ({$a}) is before the course start date.';
$string['favourite'] = 'Starred course';
$string['gradetopassnotset'] = 'This course does not have a grade to pass set. It may be set in the grade item of the course (Gradebook setup).';
Expand Down

0 comments on commit 11456d7

Please sign in to comment.