From: moodler Date: Thu, 10 Jul 2003 14:09:43 +0000 (+0000) Subject: Added a question field to numerical table for completeness X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9c02661096935b647a3db6211ab305701c6ffa21;p=moodle.git Added a question field to numerical table for completeness --- diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index 76ca101861..e641ca63a1 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -92,10 +92,11 @@ function quiz_upgrade($oldversion) { table_column("quiz", "", "shuffleanswers", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "shufflequestions"); } - if ($oldversion < 2003071000) { + if ($oldversion < 2003071001) { modify_database ("", " CREATE TABLE `prefix_quiz_numerical` ( `id` int(10) unsigned NOT NULL auto_increment, + `question` int(10) unsigned NOT NULL default '0', `answer` int(10) unsigned NOT NULL default '0', `min` varchar(255) NOT NULL default '', `max` varchar(255) NOT NULL default '', diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index 37d068795c..f20ecd8cdf 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -222,6 +222,7 @@ CREATE TABLE `prefix_quiz_shortanswer` ( CREATE TABLE `prefix_quiz_numerical` ( `id` int(10) unsigned NOT NULL auto_increment, + `question` int(10) unsigned NOT NULL default '0', `answer` int(10) unsigned NOT NULL default '0', `min` varchar(255) NOT NULL default '', `max` varchar(255) NOT NULL default '', diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index 073a86171f..c222b6bc78 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -59,6 +59,16 @@ function quiz_upgrade($oldversion) { );"); modify_database ("", "CREATE INDEX prefix_quiz_match_question_idx ON prefix_quiz_match (question);"); } + if ($oldversion < 2003071001) { + modify_database ("", " CREATE TABLE prefix_quiz_numerical ( + id SERIAL PRIMARY KEY, + question integer NOT NULL default '0', + answer integer NOT NULL default '0', + min varchar(255) NOT NULL default '', + max varchar(255) NOT NULL default '' + ); "); + modify_database ("", "CREATE INDEX prefix_quiz_numerical_answer_idx ON prefix_quiz_numerical (answer);"); + } return true; } diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index 2a28de3e5b..003eab5b99 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -129,6 +129,20 @@ CREATE TABLE prefix_quiz_multichoice ( # -------------------------------------------------------- CREATE INDEX prefix_quiz_multichoice_question_idx ON prefix_quiz_multichoice (question); +# +# Table structure for table quiz_numerical +# + +CREATE TABLE prefix_quiz_numerical ( + id SERIAL PRIMARY KEY, + question integer NOT NULL default '0', + answer integer NOT NULL default '0', + min varchar(255) NOT NULL default '', + max varchar(255) NOT NULL default '' +); +# -------------------------------------------------------- +CREATE INDEX prefix_quiz_numerical_answer_idx ON prefix_quiz_numerical (answer); + # # Table structure for table quiz_question_grades # diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 1a0682a846..8e7364b300 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -1720,9 +1720,10 @@ function quiz_save_question_options($question) { } } else { // completely new answer unset($options); - $options->min= $question->min[$key]; - $options->max= $question->max[$key]; - $options->answer= $answer->id; + $options->question = $question->id; + $options->answer = $answer->id; + $options->min = $question->min[$key]; + $options->max = $question->max[$key]; if (!insert_record("quiz_numerical", $options)) { $result->error = "Could not insert quiz numerical options!"; return $result; diff --git a/mod/quiz/version.php b/mod/quiz/version.php index ff93d62157..fc32d31176 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 = 2003071000; // The (date) version of this module +$module->version = 2003071001; // The (date) version of this module $module->cron = 0; // How often should cron check this module (seconds)? ?>