From 6040798269964d98c9798a4df7f955f7e1fedf8b Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Tue, 21 Mar 2006 23:08:36 +0000 Subject: [PATCH] Abolished the qtype integers. The question types are now indexed by their name as specified by their directory name. This will avoid a lot of confusion in future when we have plugable question types. --- lib/questionlib.php | 24 ++++++++++++------------ mod/quiz/db/mysql.php | 16 ++++++++++++++++ mod/quiz/db/mysql.sql | 2 +- mod/quiz/db/postgres7.php | 16 ++++++++++++++++ mod/quiz/db/postgres7.sql | 2 +- mod/quiz/version.php | 2 +- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index ce837a6a69..0235b735db 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -38,18 +38,18 @@ define('QUESTION_EVENTCLOSE', '8'); // The response has been submitted and t /**#@+ * The core question types */ -define("SHORTANSWER", "1"); -define("TRUEFALSE", "2"); -define("MULTICHOICE", "3"); -define("RANDOM", "4"); -define("MATCH", "5"); -define("RANDOMSAMATCH", "6"); -define("DESCRIPTION", "7"); -define("NUMERICAL", "8"); -define("MULTIANSWER", "9"); -define("CALCULATED", "10"); -define("RQP", "11"); -define("ESSAY", "12"); +define("SHORTANSWER", "shortanswer"); +define("TRUEFALSE", "truefalse"); +define("MULTICHOICE", "multichoice"); +define("RANDOM", "random"); +define("MATCH", "match"); +define("RANDOMSAMATCH", "randomsamatch"); +define("DESCRIPTION", "description"); +define("NUMERICAL", "numerical"); +define("MULTIANSWER", "multianswer"); +define("CALCULATED", "calculated"); +define("RQP", "rqp"); +define("ESSAY", "essay"); /**#@-*/ /** diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index 737235246a..69a112f279 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -972,6 +972,22 @@ function quiz_upgrade($oldversion) { execute_sql("ALTER TABLE {$CFG->prefix}quiz_essay_states RENAME {$CFG->prefix}question_essay_states", false); } + if ($oldversion < 2006032100) { + table_column('question', 'qtype', 'qtype', 'varchar', 20, '', '', 'not null'); + set_field('question', 'qtype', 'shortanswer', 'qtype', 1); + set_field('question', 'qtype', 'truefalse', 'qtype', 2); + set_field('question', 'qtype', 'multichoice', 'qtype', 3); + set_field('question', 'qtype', 'random', 'qtype', 4); + set_field('question', 'qtype', 'match', 'qtype', 5); + set_field('question', 'qtype', 'randomsamatch', 'qtype', 6); + set_field('question', 'qtype', 'description', 'qtype', 7); + set_field('question', 'qtype', 'numerical', 'qtype', 8); + set_field('question', 'qtype', 'multianswer', 'qtype', 9); + set_field('question', 'qtype', 'calculated', 'qtype', 10); + set_field('question', 'qtype', 'rqp', 'qtype', 11); + set_field('question', 'qtype', 'essay', 'qtype', 12); + } + return true; } diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index 593412ce27..711f555a05 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -392,7 +392,7 @@ CREATE TABLE prefix_question ( image varchar(255) NOT NULL default '', defaultgrade int(10) unsigned NOT NULL default '1', penalty float NOT NULL default '0.1', - qtype smallint(6) NOT NULL default '0', + qtype varchar(20) NOT NULL default '', length int(10) unsigned NOT NULL default '1', stamp varchar(255) NOT NULL default '', version int(10) NOT NULL default '1', diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index 264f0c983c..dbc3abf80c 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -1141,6 +1141,22 @@ function quiz_upgrade($oldversion) { } + if ($oldversion < 2006032100) { + table_column('question', 'qtype', 'qtype', 'varchar', 20, '', '', 'not null'); + set_field('question', 'qtype', 'shortanswer', 'qtype', 1); + set_field('question', 'qtype', 'truefalse', 'qtype', 2); + set_field('question', 'qtype', 'multichoice', 'qtype', 3); + set_field('question', 'qtype', 'random', 'qtype', 4); + set_field('question', 'qtype', 'match', 'qtype', 5); + set_field('question', 'qtype', 'randomsamatch', 'qtype', 6); + set_field('question', 'qtype', 'description', 'qtype', 7); + set_field('question', 'qtype', 'numerical', 'qtype', 8); + set_field('question', 'qtype', 'multianswer', 'qtype', 9); + set_field('question', 'qtype', 'calculated', 'qtype', 10); + set_field('question', 'qtype', 'rqp', 'qtype', 11); + set_field('question', 'qtype', 'essay', 'qtype', 12); + } + return true; } diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index 42a0204990..a663b85193 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -382,7 +382,7 @@ CREATE TABLE prefix_question ( image varchar(255) NOT NULL default '', defaultgrade integer NOT NULL default '1', penalty real NOT NULL default '0.1', - qtype integer NOT NULL default '0', + qtype varchar(20) NOT NULL default '0', length integer NOT NULL DEFAULT '1', stamp varchar(255) NOT NULL default '', version integer NOT NULL default '1', diff --git a/mod/quiz/version.php b/mod/quiz/version.php index e89d3cb569..0d9be8ed15 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2006031202; // The (date) version of this module +$module->version = 2006032100; // The (date) version of this module $module->requires = 2006022400; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)? -- 2.39.5