summaryrefslogtreecommitdiff
path: root/sqlbox/db/upgrade.php
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-24 13:06:19 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-24 14:47:06 +0100
commit588af7d081e11db69277612f196f8cb264ac1243 (patch)
treebbc8cf8078bf953c71bd1ebccccb31737bfd9d40 /sqlbox/db/upgrade.php
parent0d94307750159d8afce745064742a97485ad9094 (diff)
downloadsqltutor-plugin-588af7d081e11db69277612f196f8cb264ac1243.tar.gz
sqltutor-plugin-588af7d081e11db69277612f196f8cb264ac1243.tar.bz2
sqltutor-plugin-588af7d081e11db69277612f196f8cb264ac1243.zip
Store user query and if query was correct
Diffstat (limited to 'sqlbox/db/upgrade.php')
-rw-r--r--sqlbox/db/upgrade.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/sqlbox/db/upgrade.php b/sqlbox/db/upgrade.php
index fb0c671..08724e4 100644
--- a/sqlbox/db/upgrade.php
+++ b/sqlbox/db/upgrade.php
@@ -67,7 +67,49 @@ function xmldb_sqlbox_upgrade($oldversion) {
// http://docs.moodle.org/en/Development:XMLDB_Documentation
// and to play with the XMLDB Editor (in the admin menu) and its
// PHP generation posibilities.
+ if ($oldversion < 2013012402) {
+ $table = new xmldb_table('sqlbox_solutions');
+ $field = new xmldb_field('correct', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'query');
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+ upgrade_mod_savepoint(true, 2013012402, 'sqlbox');
+ }
+ if ($oldversion < 2013012401) {
+ $table = new xmldb_table('sqlbox_solutions');
+ $fieldold = new xmldb_field('correct');
+ if ($dbman->field_exists($table, $fieldold)) {
+ $dbman->drop_field($table, $fieldold);
+ }
+ // sqlbox savepoint reached
+ upgrade_mod_savepoint(true, 2013012401, 'sqlbox');
+ }
+ if ($oldversion < 2013012400) {
+ // Define table sqlbox_solutions to be created
+ $table = new xmldb_table('sqlbox_solutions');
+
+ // Adding fields to table sqlbox_solutions
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('sqlboxid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
+ $table->add_field('query', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
+ $table->add_field('correct', XMLDB_TYPE_BINARY, null, null, null, null, null);
+
+ // Adding keys to table sqlbox_solutions
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('sqlboxid', XMLDB_KEY_FOREIGN, array('sqlboxid'), 'sqlbox', array('id'));
+
+ // Adding indexes to table sqlbox_solutions
+ $table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
+
+ // Conditionally launch create table for sqlbox_solutions
+ if (!$dbman->table_exists($table)) {
+ $dbman->create_table($table);
+ }
+ // sqlbox savepoint reached
+ upgrade_mod_savepoint(true, 2013012400, 'sqlbox');
+ }
if ($oldversion < 20121223) {
// Define field query to be added to sqlbox
$table = new xmldb_table('sqlbox');