Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
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.
8
//
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.
13
//
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/>.
16
 
17
/**
18
 * Keeps track of upgrades to the subcourse module
19
 *
20
 * @package     mod_subcourse
21
 * @category    upgrade
22
 * @copyright   2008 David Mudrak <david@moodle.com>
23
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
/**
27
 * Performs upgrade of the database structure and data
28
 *
29
 * @param int $oldversion the version we are upgrading from
30
 * @return bool true
31
 */
32
function xmldb_subcourse_upgrade($oldversion=0) {
33
    global $DB;
34
 
35
    $dbman = $DB->get_manager();
36
 
37
    if ($oldversion < 2013102501) {
38
        // Drop the 'grade' field from the 'subcourse' table.
39
 
40
        $table = new xmldb_table('subcourse');
41
        $field = new xmldb_field('grade');
42
        if ($dbman->field_exists($table, $field)) {
43
            $dbman->drop_field($table, $field);
44
        }
45
 
46
        upgrade_mod_savepoint(true, 2013102501, 'subcourse');
47
    }
48
 
49
    if ($oldversion < 2014060900) {
50
        // Add the field 'instantredirect' to the table 'subcourse'.
51
        $table = new xmldb_table('subcourse');
52
        $field = new xmldb_field('instantredirect', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'refcourse');
53
 
54
        if (!$dbman->field_exists($table, $field)) {
55
            $dbman->add_field($table, $field);
56
        }
57
 
58
        upgrade_mod_savepoint(true, 2014060900, 'subcourse');
59
    }
60
 
61
    if ($oldversion < 2017071300) {
62
        // Add the field completioncourse to the table 'subcourse'.
63
        $table = new xmldb_table('subcourse');
64
        $field = new xmldb_field('completioncourse', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'instantredirect');
65
 
66
        if (!$dbman->field_exists($table, $field)) {
67
            $dbman->add_field($table, $field);
68
        }
69
 
70
        upgrade_mod_savepoint(true, 2017071300, 'subcourse');
71
    }
72
 
73
    if ($oldversion < 2018121600) {
74
        // Add field 'blankwindow' to the table 'subcourse'.
75
        $table = new xmldb_table('subcourse');
76
        $field = new xmldb_field('blankwindow', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'completioncourse');
77
 
78
        if (!$dbman->field_exists($table, $field)) {
79
            $dbman->add_field($table, $field);
80
        }
81
 
82
        upgrade_mod_savepoint(true, 2018121600, 'subcourse');
83
    }
84
 
85
    if ($oldversion < 2020071100) {
86
        // Add field 'fetchpercentage' to the table 'subcourse'.
87
        $table = new xmldb_table('subcourse');
88
        $field = new xmldb_field('fetchpercentage', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'blankwindow');
89
 
90
        if (!$dbman->field_exists($table, $field)) {
91
            $dbman->add_field($table, $field);
92
        }
93
 
94
        upgrade_mod_savepoint(true, 2020071100, 'subcourse');
95
    }
96
 
97
    if ($oldversion < 2021021400) {
98
        // Add the field 'coursepageprintgrade' to the table 'subcourse'.
99
        $table = new xmldb_table('subcourse');
100
        $field = new xmldb_field('coursepageprintgrade', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1',
101
            'fetchpercentage');
102
 
103
        if (!$dbman->field_exists($table, $field)) {
104
            $dbman->add_field($table, $field);
105
        }
106
 
107
        // Add the field 'coursepageprintprogress' to the table 'subcourse'.
108
        $field = new xmldb_field('coursepageprintprogress', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1',
109
            'coursepageprintgrade');
110
 
111
        if (!$dbman->field_exists($table, $field)) {
112
            $dbman->add_field($table, $field);
113
        }
114
 
115
        upgrade_mod_savepoint(true, 2021021400, 'subcourse');
116
    }
117
 
118
    return true;
119
}