Skip to content

Commit

Permalink
MDL-46805 SCORM: AICC restricts allowed characters in the username
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Mar 30, 2015
1 parent 06122e4 commit ef88aa2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
8 changes: 6 additions & 2 deletions mod/scorm/datamodels/aicclib.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,12 @@ function scorm_aicc_generate_simple_sco($scorm) {
*/
function get_scorm_default (&$userdata, $scorm, $scoid, $attempt, $mode) {
global $USER;

$userdata->student_id = $USER->username;
$aiccuserid = get_config('scorm', 'aiccuserid');
if (!empty($aiccuserid)) {
$userdata->student_id = $USER->id;
} else {
$userdata->student_id = $USER->username;
}
$userdata->student_name = $USER->lastname .', '. $USER->firstname;

if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
Expand Down
18 changes: 18 additions & 0 deletions mod/scorm/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,24 @@ function xmldb_scorm_upgrade($oldversion) {
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2015031800) {

// 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, 2015031800, 'scorm');
}

return true;
}

Expand Down
3 changes: 3 additions & 0 deletions mod/scorm/lang/en/scorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
$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';
Expand Down
3 changes: 3 additions & 0 deletions mod/scorm/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
get_string('aicchacpkeepsessiondata', 'scorm'), get_string('aicchacpkeepsessiondata_desc', 'scorm'),
1, PARAM_INT));

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

Expand Down
2 changes: 1 addition & 1 deletion mod/scorm/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2014111000; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2015031800; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2014110400; // Requires this Moodle version.
$plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics).
$plugin->cron = 300;

0 comments on commit ef88aa2

Please sign in to comment.