From 9376f7d68e5008323305859eaec42aa1d36ff8de Mon Sep 17 00:00:00 2001 From: willem Date: Fri, 6 Apr 2018 15:06:21 +0200 Subject: [PATCH] MDL-61709 mod_scorm: use student fullname when not in standards mode 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. --- mod/scorm/datamodels/scorm_12.php | 2 +- mod/scorm/datamodels/scorm_12lib.php | 6 +++++- mod/scorm/datamodels/scorm_13lib.php | 6 +++++- mod/scorm/db/upgrade.php | 7 +++++++ mod/scorm/lang/en/scorm.php | 5 ++--- mod/scorm/settings.php | 4 ++-- mod/scorm/version.php | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mod/scorm/datamodels/scorm_12.php b/mod/scorm/datamodels/scorm_12.php index 70f88144798..5618f7ebf41 100644 --- a/mod/scorm/datamodels/scorm_12.php +++ b/mod/scorm/datamodels/scorm_12.php @@ -43,7 +43,7 @@ if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id), 'sort } // 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 { diff --git a/mod/scorm/datamodels/scorm_12lib.php b/mod/scorm/datamodels/scorm_12lib.php index 306b9ac54d2..79db435f87a 100644 --- a/mod/scorm/datamodels/scorm_12lib.php +++ b/mod/scorm/datamodels/scorm_12lib.php @@ -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) { diff --git a/mod/scorm/datamodels/scorm_13lib.php b/mod/scorm/datamodels/scorm_13lib.php index 71ee8232466..0048cd49fc5 100644 --- a/mod/scorm/datamodels/scorm_13lib.php +++ b/mod/scorm/datamodels/scorm_13lib.php @@ -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. diff --git a/mod/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php index d8141b09781..77e00a6e99c 100644 --- a/mod/scorm/db/upgrade.php +++ b/mod/scorm/db/upgrade.php @@ -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; } diff --git a/mod/scorm/lang/en/scorm.php b/mod/scorm/lang/en/scorm.php index c6ad22ff722..cdbc7eae65a 100644 --- a/mod/scorm/lang/en/scorm.php +++ b/mod/scorm/lang/en/scorm.php @@ -343,9 +343,8 @@ $string['results'] = 'Results'; $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'; diff --git a/mod/scorm/settings.php b/mod/scorm/settings.php index 28965085bd4..0845e33cf05 100644 --- a/mod/scorm/settings.php +++ b/mod/scorm/settings.php @@ -129,8 +129,8 @@ if ($ADMIN->fulltree) { // 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)); diff --git a/mod/scorm/version.php b/mod/scorm/version.php index 12f79473732..de63ab5dba8 100644 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -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). \ No newline at end of file