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
 * This file keeps track of upgrades to the completion status block
19
 *
20
 * @package block_dedication
21
 * @copyright Catalyst IT
22
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
/**
26
 * Handles upgrading instances of this block.
27
 *
28
 * @param int $oldversion
29
 * @param object $block
30
 */
31
function xmldb_block_dedication_upgrade($oldversion, $block) {
32
    global $DB;
33
    $dbman = $DB->get_manager();
34
 
35
    if ($oldversion < 2022122100) {
36
 
37
        // Define table block_dedication to be created.
38
        $table = new xmldb_table('block_dedication');
39
 
40
        // Adding fields to table block_dedication.
41
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
42
        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
43
        $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
44
        $table->add_field('timespent', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
45
        $table->add_field('timestart', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
46
 
47
        // Adding keys to table block_dedication.
48
        $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
49
 
50
        // Adding indexes to table block_dedication.
51
        $table->add_index('block_dedication', XMLDB_INDEX_NOTUNIQUE, ['userid', 'courseid']);
52
 
53
        // Conditionally launch create table for block_dedication.
54
        if (!$dbman->table_exists($table)) {
55
            $dbman->create_table($table);
56
        }
57
 
58
        // Dedication savepoint reached.
59
        upgrade_block_savepoint(true, 2022122100, 'dedication');
60
    }
61
 
62
    return true;
63
}