From 65478eea3c40d916de7d675800f75f12eae3dc59 Mon Sep 17 00:00:00 2001 From: piers Date: Sun, 14 Dec 2008 23:45:54 +0000 Subject: [PATCH] MDL-16810 - amend upgrade process to preserve config values where possible. thanks for pointer Tim. --- mod/scorm/db/upgrade.php | 97 ++++++++++++++++++++++++++++++++-------- mod/scorm/version.php | 2 +- 2 files changed, 80 insertions(+), 19 deletions(-) diff --git a/mod/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php index 57462ac547..03705f2c0c 100644 --- a/mod/scorm/db/upgrade.php +++ b/mod/scorm/db/upgrade.php @@ -259,21 +259,25 @@ function xmldb_scorm_upgrade($oldversion) { if (!$dbman->field_exists($table,$field)) { $dbman->add_field($table, $field); } - + /// scorm savepoint reached upgrade_mod_savepoint($result, 2008090305, 'scorm'); } - + // remove redundant config values if ($result && $oldversion < 2008090306) { + /* + * comment this out as it is handled by the update mark 2008090310 below + * left for historical documentation as some early adopters may have done + * this already. $redundant_config = array( 'scorm_allowapidebug', 'scorm_allowtypeexternal', 'scorm_allowtypeimsrepository', - 'scorm_allowtypelocalsync', - 'scorm_apidebugmask', - 'scorm_frameheight', + 'scorm_allowtypelocalsync', + 'scorm_apidebugmask', + 'scorm_frameheight', 'scorm_framewidth', 'scorm_maxattempts', 'scorm_updatetime'); @@ -282,30 +286,35 @@ function xmldb_scorm_upgrade($oldversion) { unset_config($rcfg); } } + */ /// scorm savepoint reached upgrade_mod_savepoint($result, 2008090306, 'scorm'); } - - + + // remove redundant config values if ($result && $oldversion < 2008090307) { + /* + * comment this out as it is handled by the update mark 2008090310 below + * left for historical documentation as some early adopters may have done + * this already. $redundant_config = array( 'scorm_allowapidebug', 'scorm_allowtypeexternal', 'scorm_allowtypeimsrepository', - 'scorm_allowtypelocalsync', - 'scorm_apidebugmask', - 'scorm_frameheight', + 'scorm_allowtypelocalsync', + 'scorm_apidebugmask', + 'scorm_frameheight', 'scorm_framewidth', 'scorm_maxattempts', 'scorm_updatetime', - 'scorm_resizable', - 'scorm_scrollbars', - 'scorm_directories', + 'scorm_resizable', + 'scorm_scrollbars', + 'scorm_directories', 'scorm_location', - 'scorm_menubar', - 'scorm_toolbar', + 'scorm_menubar', + 'scorm_toolbar', 'scorm_status', 'scorm_grademethod', 'scorm_maxgrade', @@ -323,11 +332,12 @@ function xmldb_scorm_upgrade($oldversion) { unset_config($rcfg); } } - + */ + /// scorm savepoint reached upgrade_mod_savepoint($result, 2008090307, 'scorm'); } - + if ($result && $oldversion < 2008090308) { $table = new xmldb_table('scorm'); $field = new xmldb_field('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'height'); @@ -338,10 +348,61 @@ function xmldb_scorm_upgrade($oldversion) { if (!$dbman->field_exists($table,$field)) { $dbman->add_field($table, $field); } - + /// scorm savepoint reached upgrade_mod_savepoint($result, 2008090308, 'scorm'); } + + + if ($result && $oldversion < 2008090310) { + // take above blocks that delete config and move the values in to config_plugins + + $redundant_config = array( + 'scorm_allowapidebug', + 'scorm_allowtypeexternal', + 'scorm_allowtypeimsrepository', + 'scorm_allowtypelocalsync', + 'scorm_apidebugmask', + 'scorm_frameheight', + 'scorm_framewidth', + 'scorm_maxattempts', + 'scorm_updatetime', + 'scorm_resizable', + 'scorm_scrollbars', + 'scorm_directories', + 'scorm_location', + 'scorm_menubar', + 'scorm_toolbar', + 'scorm_status', + 'scorm_grademethod', + 'scorm_maxgrade', + 'scorm_whatgrade', + 'scorm_popup', + 'scorm_skipview', + 'scorm_hidebrowse', + 'scorm_hidetoc', + 'scorm_hidenav', + 'scorm_auto', + 'scorm_updatefreq', + 'scorm_displayattemptstatus', + 'scorm_displaycoursestructure', + 'scorm_forcecompleted', + 'scorm_forcenewattempt', + 'scorm_lastattemptlock' + ); + + foreach ($redundant_config as $rcfg) { + if (isset($CFG->$rcfg)) { + $shortname = substr($rcfg, 6); + $result = $result && set_config($shortname, $CFG->$rcfg, 'scorm'); + $result = $result && unset_config($rcfg); + } + } + + /// scorm savepoint reached + upgrade_mod_savepoint($result, 2008090310, 'scorm'); + } + return $result; } diff --git a/mod/scorm/version.php b/mod/scorm/version.php index fa5aed7ede..21df95ec5c 100755 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -10,7 +10,7 @@ // catch up now, so until 27th October please only increment in very tiny steps // in HEAD, until we get past that date.. -$module->version = 2008090309; // The (date) version of this module +$module->version = 2008090310; // The (date) version of this module $module->requires = 2008090108; // The version of Moodle that is required $module->cron = 300; // How often should cron check this module (seconds)? -- 2.39.5