Skip to content

Commit

Permalink
MDL-51434 mod_scorm: New global setting for enabling package downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Oct 1, 2015
1 parent fd57d68 commit 8b06acf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mod/scorm/classes/external.php
Expand Up @@ -679,6 +679,8 @@ public static function get_scorms_by_courses($courseids = array()) {
}
}

$module['protectpackagedownloads'] = get_config('scorm', 'protectpackagedownloads');

$viewablefields = array('version', 'maxgrade', 'grademethod', 'whatgrade', 'maxattempt', 'forcecompleted',
'forcenewattempt', 'lastattemptlock', 'displayattemptstatus', 'displaycoursestructure',
'sha1hash', 'md5hash', 'revision', 'launch', 'skipview', 'hidebrowse', 'hidetoc', 'nav',
Expand Down Expand Up @@ -766,6 +768,8 @@ public static function get_scorms_by_courses_returns() {
VALUE_OPTIONAL),
'scormtype' => new external_value(PARAM_ALPHA, 'SCORM type', 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',
VALUE_OPTIONAL),
'options' => new external_value(PARAM_RAW, 'Additional options', VALUE_OPTIONAL),
Expand Down
2 changes: 2 additions & 0 deletions mod/scorm/lang/en/scorm.php
Expand Up @@ -311,6 +311,8 @@
$string['preferencesuser'] = 'Preferences for this report';
$string['preferencespage'] = 'Preferences just for this page';
$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['regular'] = 'Regular manifest';
$string['report'] = 'Report';
Expand Down
4 changes: 3 additions & 1 deletion mod/scorm/lib.php
Expand Up @@ -947,7 +947,9 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
// TODO: add any other access restrictions here if needed!

} 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;
}
$revision = (int)array_shift($args); // Prevents caching problems - ignored here.
Expand Down
3 changes: 3 additions & 0 deletions mod/scorm/settings.php
Expand Up @@ -157,4 +157,7 @@

$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));

}
2 changes: 1 addition & 1 deletion mod/scorm/version.php
Expand Up @@ -24,7 +24,7 @@

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->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics).
$plugin->cron = 300;

0 comments on commit 8b06acf

Please sign in to comment.