From 847de86adf0ce8cb692f32668f167b99eba25eff Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 14 Aug 2014 20:06:27 +1200 Subject: [PATCH] MDL-46805 SCORM: AICC restricts allowed characters in the username --- mod/scorm/aicc.php | 6 +++++- mod/scorm/db/upgrade.php | 18 ++++++++++++++++++ mod/scorm/lang/en/scorm.php | 3 +++ mod/scorm/settings.php | 6 +++++- mod/scorm/version.php | 2 +- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/mod/scorm/aicc.php b/mod/scorm/aicc.php index a73a7172001..0b74088c4a2 100644 --- a/mod/scorm/aicc.php +++ b/mod/scorm/aicc.php @@ -111,7 +111,11 @@ if (!empty($command)) { $userdata->status = ''; $userdata->score_raw = ''; } - $userdata->student_id = $aiccuser->username; + if (!empty($cfg_scorm->aiccuserid)) { + $userdata->student_id = $aiccuser->id; + } else { + $userdata->student_id = $aiccuser->username; + } $userdata->student_name = $aiccuser->lastname .', '. $aiccuser->firstname; $userdata->mode = $mode; if ($userdata->mode == 'normal') { diff --git a/mod/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php index 2beabb78e85..6cc4fd44198 100644 --- a/mod/scorm/db/upgrade.php +++ b/mod/scorm/db/upgrade.php @@ -279,6 +279,24 @@ function xmldb_scorm_upgrade($oldversion) { // Moodle v2.7.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2014051201) { + + // Check to see if this site has any AICC packages - if so set the aiccuserid to pass the username + // so that the data remains consistent with existing packages. + $alreadyset = $DB->record_exists('config_plugins', array('plugin' => 'scorm', 'name' => 'aiccuserid')); + if (!$alreadyset) { + $hasaicc = $DB->record_exists('scorm', array('version' => 'AICC')); + if ($hasaicc) { + set_config('aiccuserid', 0, 'scorm'); + } else { + // We set the config value to hide this from upgrades as most users will not know what AICC is anyway. + set_config('aiccuserid', 1, 'scorm'); + } + } + // Scorm savepoint reached. + upgrade_mod_savepoint(true, 2014051201, 'scorm'); + } + return true; } diff --git a/mod/scorm/lang/en/scorm.php b/mod/scorm/lang/en/scorm.php index ca6b997efd9..41094b6537e 100644 --- a/mod/scorm/lang/en/scorm.php +++ b/mod/scorm/lang/en/scorm.php @@ -27,6 +27,9 @@ $string['aicchacptimeout'] = 'AICC HACP timeout'; $string['aicchacptimeout_desc'] = 'Length of time in minutes that an external AICC HACP session can remain open'; $string['aicchacpkeepsessiondata'] = 'AICC HACP session data'; $string['aicchacpkeepsessiondata_desc'] = 'Length of time in days to keep the external AICC HACP session data (a high setting will fill up the table with old data but may be useful when debugging)'; +$string['aiccuserid'] = 'AICC pass numeric user id'; +$string['aiccuserid_desc'] = 'The AICC standard for usernames is very restrictive compared with Moodle so we pass the user->id instead. If disabled this passes the moodle username to the AICC package. +The AICC standard allows for alpha-numeric characters with the two additional characters dash(-) and the underscore(_). Periods, spaces and the @ symbol are not permitted.'; $string['activation'] = 'Activation'; $string['activityloading'] = 'You will be automatically redirected to the activity in'; $string['activityoverview'] = 'You have SCORM packages that need attention'; diff --git a/mod/scorm/settings.php b/mod/scorm/settings.php index 2f7993cb584..057a06ce23e 100644 --- a/mod/scorm/settings.php +++ b/mod/scorm/settings.php @@ -141,7 +141,11 @@ if ($ADMIN->fulltree) { get_string('aicchacpkeepsessiondata', 'scorm'), get_string('aicchacpkeepsessiondata_desc', 'scorm'), 1, PARAM_INT)); - $settings->add(new admin_setting_configcheckbox('scorm/forcejavascript', get_string('forcejavascript', 'scorm'), get_string('forcejavascript_desc', 'scorm'), 1)); + $settings->add(new admin_setting_configcheckbox('scorm/aiccuserid', get_string('aiccuserid', 'scorm'), + get_string('aiccuserid_desc', 'scorm'), 1)); + + $settings->add(new admin_setting_configcheckbox('scorm/forcejavascript', get_string('forcejavascript', 'scorm'), + get_string('forcejavascript_desc', 'scorm'), 1)); $settings->add(new admin_setting_configcheckbox('scorm/allowapidebug', get_string('allowapidebug', 'scorm'), '', 0)); diff --git a/mod/scorm/version.php b/mod/scorm/version.php index abca922b864..fcdc4505269 100644 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014051200; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2014051201; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2014050800; // Requires this Moodle version. $plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics). $plugin->cron = 300;