Skip to content

Commit

Permalink
MDL-61709 mod_scorm: use student fullname when not in standards mode
Browse files Browse the repository at this point in the history
Changed the scorm12standard setting for SCORM 1.2 in a more generic
'use SCORM Standards' setting. New setting is off by default.

The student name passed into the module is formatted as
$USER->lastname .', '. $USER->firstname and thus ignores the
fullnamedisplay. This is per SCORM1.2 standards. If setting
'use SCORM Standards' is disabled fullname will be used instead.
  • Loading branch information
willem authored and Willem Roes committed Apr 7, 2018
1 parent 2bd2660 commit 9376f7d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mod/scorm/datamodels/scorm_12.php
Expand Up @@ -43,7 +43,7 @@
}

// If SCORM 1.2 standard mode is disabled allow higher datamodel limits.
if (intval(get_config("scorm", "scorm12standard"))) {
if (intval(get_config("scorm", "scormstandard"))) {
$cmistring256 = '^[\\u0000-\\uFFFF]{0,255}$';
$cmistring4096 = '^[\\u0000-\\uFFFF]{0,4096}$';
} else {
Expand Down
6 changes: 5 additions & 1 deletion mod/scorm/datamodels/scorm_12lib.php
Expand Up @@ -29,7 +29,11 @@ function get_scorm_default (&$userdata, $scorm, $scoid, $attempt, $mode) {
global $USER;

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

if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
foreach ($usertrack as $key => $value) {
Expand Down
6 changes: 5 additions & 1 deletion mod/scorm/datamodels/scorm_13lib.php
Expand Up @@ -1193,7 +1193,11 @@ function get_scorm_default (&$userdata, $scorm, $scoid, $attempt, $mode) {
global $DB, $USER;

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

if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
// According to SCORM 2004(RTE V1, 4.2.8), only cmi.exit==suspend should allow previous datamodel elements on re-launch.
Expand Down
7 changes: 7 additions & 0 deletions mod/scorm/db/upgrade.php
Expand Up @@ -55,5 +55,12 @@ function xmldb_scorm_upgrade($oldversion) {
// Automatically generated Moodle v3.4.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2018032300) {
set_config('scormstandard', get_config('scorm', 'scorm12standard'), 'scorm');
unset_config('scorm12standard', 'scorm');

upgrade_mod_savepoint(true, 2018032300, 'scorm');
}

return true;
}
5 changes: 2 additions & 3 deletions mod/scorm/lang/en/scorm.php
Expand Up @@ -343,9 +343,8 @@
$string['review'] = 'Review';
$string['reviewmode'] = 'Review mode';
$string['rightanswer'] = 'Right answer';
$string['scorm12standard'] = 'Enable SCORM 1.2 standard mode';
$string['scorm12standarddesc'] = 'Disabling this setting allows Moodle to store more data than the SCORM 1.2 specification allows.
If your SCORM packages allow users to enter large amounts of text or if your package tries to store large amounts of data in the suspend_data field disable this.';
$string['scormstandard'] = 'SCORM standards mode';
$string['scormstandarddesc'] = 'When disabled, Moodle allows SCORM 1.2 packages to store more than the specification allows, and uses Moodle full name format settings when passing the users name to the SCORM package.';
$string['scoes'] = 'Learning objects';
$string['score'] = 'Score';
$string['scorm:addinstance'] = 'Add a new SCORM package';
Expand Down
4 changes: 2 additions & 2 deletions mod/scorm/settings.php
Expand Up @@ -129,8 +129,8 @@
// Admin level settings.
$settings->add(new admin_setting_heading('scorm/adminsettings', get_string('adminsettings', 'scorm'), ''));

$settings->add(new admin_setting_configcheckbox('scorm/scorm12standard', get_string('scorm12standard', 'scorm'),
get_string('scorm12standarddesc', 'scorm'), 1));
$settings->add(new admin_setting_configcheckbox('scorm/scormstandard', get_string('scormstandard', 'scorm'),
get_string('scormstandarddesc', 'scorm'), 0));

$settings->add(new admin_setting_configcheckbox('scorm/allowtypeexternal', get_string('allowtypeexternal', 'scorm'), '', 0));

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

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

$plugin->version = 2017111300; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2018032300; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2017110800; // Requires this Moodle version.
$plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics).

0 comments on commit 9376f7d

Please sign in to comment.