aboutsummaryrefslogtreecommitdiff
path: root/db/upgrade.php
diff options
context:
space:
mode:
Diffstat (limited to 'db/upgrade.php')
-rw-r--r--db/upgrade.php79
1 files changed, 46 insertions, 33 deletions
diff --git a/db/upgrade.php b/db/upgrade.php
index 371150b..ed8c060 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -1,59 +1,72 @@
-<?php // $Id: upgrade.php,v 1.1 2008/07/24 01:48:12 arborrow Exp $
-
-// This file keeps track of upgrades to
-// the algebra qtype plugin
-//
-// Sometimes, changes between versions involve
-// alterations to database structures and other
-// major things that may break installations.
+<?php
+// This file is part of Moodle - http://moodle.org/
//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older installtion to the current version.
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
//
-// If there's something it cannot do itself, it
-// will tell you what you need to do.
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
//
-// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * Algebra question type upgrade code.
+ *
+ * @package qtype_algebra
+ * @copyright Roger Moore
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
function xmldb_qtype_algebra_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
-
- $dbman = $DB->get_manager();
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
+ $dbman = $DB->get_manager();
// Add the field to store the string which is placed in front of the answer
- // box when the question is displayed
+ // box when the question is displayed.
if ($oldversion < 2008061500) {
$table = new xmldb_table('question_algebra');
$field = new xmldb_field('answerprefix', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, '', 'allowedfuncs');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- upgrade_plugin_savepoint(true, 2008061500, 'qtype', 'algebra');
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+ upgrade_plugin_savepoint(true, 2008061500, 'qtype', 'algebra');
}
- // Drop the answers and variables fields wich are totaly redundants
- if ($oldversion < 2011072800) {
- $table = new xmldb_table('question_algebra');
+ // Drop the answers and variables fields wich are totaly redundants.
+ if ($oldversion < 2011072800) {
+ $table = new xmldb_table('question_algebra');
$field = new xmldb_field('answers');
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
- $field = new xmldb_field('variables');
+ $field = new xmldb_field('variables');
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
- upgrade_plugin_savepoint(true, 2011072800, 'qtype', 'algebra');
- }
- return true;
+ upgrade_plugin_savepoint(true, 2011072800, 'qtype', 'algebra');
+ }
+
+ // Change tables names according to new standards for plugins.
+ if ($oldversion < 2012061701) {
+ // Renaming old tables.
+ $table = new xmldb_table('question_algebra');
+ if ($dbman->table_exists($table)) {
+ $dbman->rename_table($table, 'qtype_algebra');
+ }
+ $table = new xmldb_table('question_algebra_variables');
+ if ($dbman->table_exists($table)) {
+ $dbman->rename_table($table, 'qtype_algebra_variables');
+ }
+ upgrade_plugin_savepoint(true, 2012061701, 'qtype', 'algebra');
+ }
+ return true;
}