MDL-51434 mod_scorm: New global setting for enabling package downloads

This commit is contained in:
Juan Leyva 2015-09-30 10:44:07 +02:00
parent fd57d685c7
commit 8b06acf76c
5 changed files with 13 additions and 2 deletions

View File

@ -679,6 +679,8 @@ class mod_scorm_external extends external_api {
} }
} }
$module['protectpackagedownloads'] = get_config('scorm', 'protectpackagedownloads');
$viewablefields = array('version', 'maxgrade', 'grademethod', 'whatgrade', 'maxattempt', 'forcecompleted', $viewablefields = array('version', 'maxgrade', 'grademethod', 'whatgrade', 'maxattempt', 'forcecompleted',
'forcenewattempt', 'lastattemptlock', 'displayattemptstatus', 'displaycoursestructure', 'forcenewattempt', 'lastattemptlock', 'displayattemptstatus', 'displaycoursestructure',
'sha1hash', 'md5hash', 'revision', 'launch', 'skipview', 'hidebrowse', 'hidetoc', 'nav', 'sha1hash', 'md5hash', 'revision', 'launch', 'skipview', 'hidebrowse', 'hidetoc', 'nav',
@ -766,6 +768,8 @@ class mod_scorm_external extends external_api {
VALUE_OPTIONAL), VALUE_OPTIONAL),
'scormtype' => new external_value(PARAM_ALPHA, 'SCORM type', VALUE_OPTIONAL), 'scormtype' => new external_value(PARAM_ALPHA, 'SCORM type', VALUE_OPTIONAL),
'reference' => new external_value(PARAM_NOTAGS, 'Reference to the package', VALUE_OPTIONAL), 'reference' => new external_value(PARAM_NOTAGS, 'Reference to the package', VALUE_OPTIONAL),
'protectpackagedownloads' => new external_value(PARAM_BOOL, 'Protect package downloads?',
VALUE_OPTIONAL),
'updatefreq' => new external_value(PARAM_INT, 'Auto-update frequency for remote packages', 'updatefreq' => new external_value(PARAM_INT, 'Auto-update frequency for remote packages',
VALUE_OPTIONAL), VALUE_OPTIONAL),
'options' => new external_value(PARAM_RAW, 'Additional options', VALUE_OPTIONAL), 'options' => new external_value(PARAM_RAW, 'Additional options', VALUE_OPTIONAL),

View File

@ -311,6 +311,8 @@ $string['position_error'] = 'The {$a->tag} tag can\'t be child of {$a->parent} t
$string['preferencesuser'] = 'Preferences for this report'; $string['preferencesuser'] = 'Preferences for this report';
$string['preferencespage'] = 'Preferences just for this page'; $string['preferencespage'] = 'Preferences just for this page';
$string['prev'] = 'Previous'; $string['prev'] = 'Previous';
$string['protectpackagedownloads'] = 'Protect package downloads';
$string['protectpackagedownloads_desc'] = 'If enabled, SCORM packages can be downloaded only if the user has the course:manageactivities capability. If disabled, SCORM packages can always be downloaded (by mobile or other means).';
$string['raw'] = 'Raw score'; $string['raw'] = 'Raw score';
$string['regular'] = 'Regular manifest'; $string['regular'] = 'Regular manifest';
$string['report'] = 'Report'; $string['report'] = 'Report';

View File

@ -947,7 +947,9 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
// TODO: add any other access restrictions here if needed! // TODO: add any other access restrictions here if needed!
} else if ($filearea === 'package') { } else if ($filearea === 'package') {
if (!has_capability('moodle/course:manageactivities', $context)) { // Check if the global setting for disabling package downloads is enabled.
$protectpackagedownloads = get_config('scorm', 'protectpackagedownloads');
if ($protectpackagedownloads and !has_capability('moodle/course:manageactivities', $context)) {
return false; return false;
} }
$revision = (int)array_shift($args); // Prevents caching problems - ignored here. $revision = (int)array_shift($args); // Prevents caching problems - ignored here.

View File

@ -157,4 +157,7 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtext('scorm/apidebugmask', get_string('apidebugmask', 'scorm'), '', '.*')); $settings->add(new admin_setting_configtext('scorm/apidebugmask', get_string('apidebugmask', 'scorm'), '', '.*'));
$settings->add(new admin_setting_configcheckbox('scorm/protectpackagedownloads', get_string('protectpackagedownloads', 'scorm'),
get_string('protectpackagedownloads_desc', 'scorm'), 0));
} }

View File

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2015092200; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2015092201; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2015050500; // Requires this Moodle version. $plugin->requires = 2015050500; // Requires this Moodle version.
$plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics). $plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics).
$plugin->cron = 300; $plugin->cron = 300;