2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Upgrade script for the scorm module.
22 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 * @global moodle_database $DB
29 * @param int $oldversion
32 function xmldb_scorm_upgrade($oldversion) {
35 $dbman = $DB->get_manager();
38 // Moodle v2.2.0 release upgrade line
39 // Put any upgrade step following this
41 if ($oldversion < 2012032100) {
42 unset_config('updatetime', 'scorm');
43 upgrade_mod_savepoint(true, 2012032100, 'scorm');
46 // Adding completion fields to scorm table
47 if ($oldversion < 2012032101) {
48 $table = new xmldb_table('scorm');
50 $field = new xmldb_field('completionstatusrequired', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'timemodified');
51 if (!$dbman->field_exists($table, $field)) {
52 $dbman->add_field($table, $field);
55 $field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, 'completionstatusrequired');
56 if (!$dbman->field_exists($table, $field)) {
57 $dbman->add_field($table, $field);
60 upgrade_mod_savepoint(true, 2012032101, 'scorm');
63 // Moodle v2.3.0 release upgrade line
64 // Put any upgrade step following this
66 //rename config var from maxattempts to maxattempt
67 if ($oldversion < 2012061701) {
68 $maxattempts = get_config('scorm', 'maxattempts');
69 $maxattempts_adv = get_config('scorm', 'maxattempts_adv');
70 set_config('maxattempt', $maxattempts, 'scorm');
71 set_config('maxattempt_adv', $maxattempts_adv, 'scorm');
73 unset_config('maxattempts', 'scorm'); //remove old setting.
74 unset_config('maxattempts_adv', 'scorm'); //remove old setting.
75 upgrade_mod_savepoint(true, 2012061701, 'scorm');
79 // Moodle v2.4.0 release upgrade line
80 // Put any upgrade step following this
82 // Remove old imsrepository type - convert any existing records to external type to help prevent major errors.
83 if ($oldversion < 2013050101) {
84 $scorms = $DB->get_recordset('scorm', array('scormtype' => 'imsrepository'));
85 foreach($scorms as $scorm) {
86 $scorm->scormtype = SCORM_TYPE_EXTERNAL;
87 if (!empty($CFG->repository)) { // Fix path to imsmanifest if $CFG->repository is set.
88 $scorm->reference = $CFG->repository.substr($scorm->reference, 1).'/imsmanifest.xml';
89 $scorm->sha1hash = sha1($scorm->reference);
92 $DB->update_record('scorm', $scorm);
94 upgrade_mod_savepoint(true, 2013050101, 'scorm');
98 // Moodle v2.5.0 release upgrade line.
99 // Put any upgrade step following this.