3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Keeps track of upgrades to the workshop accumulative grading strategy
21 * @package workshopform
22 * @subpackage accumulative
23 * @copyright 2010 David Mudrak <david@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 * Performs upgrade of the database structure and data
30 * @param int $oldversion the version we are upgrading from
33 function xmldb_workshopform_accumulative_upgrade($oldversion) {
34 global $CFG, $DB, $OUTPUT;
36 $dbman = $DB->get_manager();
38 if ($oldversion < 2010091700) {
39 // clean up orphaned dimensions
40 $orphans = $DB->get_records_sql("SELECT d.id
41 FROM {workshopform_accumulative} d
42 LEFT JOIN {workshop} w ON d.workshopid = w.id
44 if (!empty($orphans)) {
45 echo $OUTPUT->notification('Orphaned assessment form elements found - cleaning...');
46 $DB->delete_records_list('workshopform_accumulative', 'id', array_keys($orphans));
49 upgrade_plugin_savepoint(true, 2010091700, 'workshopform', 'accumulative');
52 // Moodle v2.1.0 release upgrade line
53 // Put any upgrade step following this