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.
21 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
28 * @global moodle_database $DB
29 * @param int $oldversion
32 function xmldb_scorm_upgrade($oldversion) {
35 $dbman = $DB->get_manager();
37 if ($oldversion < 2014072500) {
39 // Define field autocommit to be added to scorm.
40 $table = new xmldb_table('scorm');
41 $field = new xmldb_field('autocommit', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'displayactivityname');
43 // Conditionally launch add field autocommit.
44 if (!$dbman->field_exists($table, $field)) {
45 $dbman->add_field($table, $field);
48 // Scorm savepoint reached.
49 upgrade_mod_savepoint(true, 2014072500, 'scorm');
52 // Moodle v2.8.0 release upgrade line.
53 // Put any upgrade step following this.
55 if ($oldversion < 2015031800) {
57 // Check to see if this site has any AICC packages - if so set the aiccuserid to pass the username
58 // so that the data remains consistent with existing packages.
59 $alreadyset = $DB->record_exists('config_plugins', array('plugin' => 'scorm', 'name' => 'aiccuserid'));
61 $hasaicc = $DB->record_exists('scorm', array('version' => 'AICC'));
63 set_config('aiccuserid', 0, 'scorm');
65 // We set the config value to hide this from upgrades as most users will not know what AICC is anyway.
66 set_config('aiccuserid', 1, 'scorm');
69 // Scorm savepoint reached.
70 upgrade_mod_savepoint(true, 2015031800, 'scorm');
73 // Moodle v2.9.0 release upgrade line.
74 // Put any upgrade step following this.
76 if ($oldversion < 2015091400) {
77 $table = new xmldb_table('scorm');
79 // Changing the default of field forcecompleted on table scorm to 0.
80 $field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'maxattempt');
81 // Launch change of default for field forcecompleted.
82 $dbman->change_field_default($table, $field);
84 // Changing the default of field displaycoursestructure on table scorm to 0.
85 $field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'displayattemptstatus');
86 // Launch change of default for field displaycoursestructure.
87 $dbman->change_field_default($table, $field);
89 // Scorm savepoint reached.
90 upgrade_mod_savepoint(true, 2015091400, 'scorm');
93 // Moodle v3.0.0 release upgrade line.
94 // Put any upgrade step following this.
96 // MDL-50620 Add mastery override option.
97 if ($oldversion < 2016021000) {
98 $table = new xmldb_table('scorm');
100 $field = new xmldb_field('masteryoverride', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'lastattemptlock');
101 if (!$dbman->field_exists($table, $field)) {
102 $dbman->add_field($table, $field);
105 upgrade_mod_savepoint(true, 2016021000, 'scorm');