From: moodler Date: Sat, 23 Aug 2003 13:28:32 +0000 (+0000) Subject: New "stamp" field on quiz questions with a unique identifier, as well as X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e9d8777ffb7fc6eb46b4bb38a59c763072e3253f;p=moodle.git New "stamp" field on quiz questions with a unique identifier, as well as some PostgreSQL fixes (Multianswer stuff had not been done on Postgres yet) --- diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index 1bb4cb0fb0..3226625413 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -130,6 +130,19 @@ function quiz_upgrade($oldversion) { table_column("quiz", "eachattemptbuildsonthelast", "attemptonlast", "TINYINT", "4", "UNSIGNED", "0", "NOT NULL", ""); } + if ($oldversion < 2003082300) { + table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype"); + + if ($questions = get_records("quiz_questions")) { + foreach ($questions as $question) { + $stamp = make_unique_id_code(); + if (!set_field("quiz_questions", "stamp", $stamp, "id", $question->id)) { + notify("Error while adding stamp to question id = $question->id"); + } + } + } + } + return true; } diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index 87788d93c8..d4d5faff59 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -170,6 +170,7 @@ CREATE TABLE `prefix_quiz_questions` ( `image` varchar(255) NOT NULL default '', `defaultgrade` INT UNSIGNED DEFAULT '1' NOT NULL, `qtype` smallint(6) NOT NULL default '0', + `stamp` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) TYPE=MyISAM COMMENT='The quiz questions themselves'; # -------------------------------------------------------- diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index 062bb66517..7c852328f7 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -74,6 +74,31 @@ function quiz_upgrade($oldversion) { execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('quiz', 'review', 'quiz', 'name') "); } + if ($oldversion < 2003082300) { + modify_database ("", " CREATE TABLE prefix_quiz_multianswers ( + id SERIAL PRIMARY KEY, + question integer NOT NULL default '0', + answers varchar(255) NOT NULL default '', + positionkey varchar(255) NOT NULL default '', + answertype integer NOT NULL default '0', + norm integer NOT NULL default '1' + ); "); + modify_database ("", "CREATE INDEX prefix_quiz_multianswers_question_idx ON prefix_quiz_multianswers (question);"); + + table_column("quiz", "", "attemptonlast", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "attempts"); + + table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype"); + + if ($questions = get_records("quiz_questions")) { + foreach ($questions as $question) { + $stamp = make_unique_id_code(); + if (!set_field("quiz_questions", "stamp", $stamp, "id", $question->id)) { + notify("Error while adding stamp to question id = $question->id"); + } + } + } + } + return true; } diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index c9e8d8c7d1..d9d0a9e51d 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -21,6 +21,7 @@ CREATE TABLE prefix_quiz ( timeopen integer NOT NULL default '0', timeclose integer NOT NULL default '0', attempts integer NOT NULL default '0', + attemptonlast integer NOT NULL default '0', feedback integer NOT NULL default '0', correctanswers integer NOT NULL default '1', grademethod integer NOT NULL default '1', @@ -115,6 +116,21 @@ CREATE TABLE prefix_quiz_match_sub ( # -------------------------------------------------------- CREATE INDEX prefix_quiz_match_sub_question_idx ON prefix_quiz_match_sub (question); + +# +# Table structure for table `quiz_multianswers` +# + +CREATE TABLE prefix_quiz_multianswers ( + id SERIAL PRIMARY KEY, + question integer NOT NULL default '0', + answers varchar(255) NOT NULL default '', + positionkey varchar(255) NOT NULL default '', + answertype integer NOT NULL default '0', + norm integer NOT NULL default '1' +); +CREATE INDEX prefix_quiz_multianswers_question_idx ON prefix_quiz_multianswers (question); + # # Table structure for table quiz_multichoice # @@ -166,7 +182,8 @@ CREATE TABLE prefix_quiz_questions ( questiontext text NOT NULL default '', image varchar(255) NOT NULL default '', defaultgrade integer NOT NULL default '1', - qtype integer NOT NULL default '0' + qtype integer NOT NULL default '0', + stamp varchar(255) NOT NULL default '' ); # -------------------------------------------------------- diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 84ee54577a..65eb0a9107 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 = 2003080400; // The (date) version of this module +$module->version = 2003082300; // The (date) version of this module $module->cron = 0; // How often should cron check this module (seconds)? ?>