From: kaipe Date: Sun, 5 Dec 2004 12:56:01 +0000 (+0000) Subject: Updating database and backup/restore in order to make it possible X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2ad1b388f7117724bab07ebdfe087a4201d51558;p=moodle.git Updating database and backup/restore in order to make it possible for teachers to choose number of decimals for calculated questions. Can someone please check if the database update for postgres7 turns out alright? --- diff --git a/mod/quiz/backuplib.php b/mod/quiz/backuplib.php index a8da7ee5f1..ef181d58fd 100644 --- a/mod/quiz/backuplib.php +++ b/mod/quiz/backuplib.php @@ -419,6 +419,7 @@ fwrite ($bf,full_tag("TOLERANCE",$level+1,false,$calculated->tolerance)); fwrite ($bf,full_tag("TOLERANCETYPE",$level+1,false,$calculated->tolerancetype)); fwrite ($bf,full_tag("CORRECTANSWERLENGTH",$level+1,false,$calculated->correctanswerlength)); + fwrite ($bf,full_tag("CORRECTANSWERFORMAT",$level+1,false,$calculated->correctanswerformat)); //Now backup numerical_units $status = quiz_backup_numerical_units($bf,$preferences,$question,7); //Now backup required dataset definitions and items... diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index f0b4424c37..f0bcbf3a49 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -288,6 +288,10 @@ function quiz_upgrade($oldversion) { modify_database('','ALTER TABLE prefix_quiz_numerical_units ADD INDEX question (question);'); modify_database('','ALTER TABLE prefix_quiz_questions ADD INDEX category (category);'); } + + if ($oldversion < 2004120501) { + table_column("quiz_calculated", "", "correctanswerformat", "integer", "10", "", "2", "not null", "correctanswerlength"); + } return true; } diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index 105ee75c30..62ecb57d70 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -100,6 +100,7 @@ CREATE TABLE `prefix_quiz_calculated` ( `tolerance` varchar(20) NOT NULL default '0.0', `tolerancetype` int(10) NOT NULL default '1', `correctanswerlength` int(10) NOT NULL default '2', + `correctanswerformat` int(10) NOT NULL default '2', PRIMARY KEY (`id`), KEY `question` (`question`), KEY `answer` (`answer`) diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index ea1d496945..89b61ed436 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -274,6 +274,10 @@ function quiz_upgrade($oldversion) { modify_database('','ALTER TABLE prefix_quiz_attemptonlast_datasets ADD CONSTRAINT prefix_quiz_category_userid_unique UNIQUE (category,userid);'); } + if ($oldversion < 2004120501) { + table_column("quiz_calculated", "", "correctanswerformat", "integer", "10", "", "2", "not null", "correctanswerlength"); + } + return true; } diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index 68c2270d83..5a5be53048 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -327,7 +327,8 @@ CREATE TABLE prefix_quiz_calculated ( answer INT8 NOT NULL default '0', tolerance varchar(20) NOT NULL default '0.0', tolerancetype INT8 NOT NULL default '1', - correctanswerlength INT8 NOT NULL default '2' + correctanswerlength INT8 NOT NULL default '2', + correctanswerformat INT8 NOT NULL default '2' ); CREATE INDEX prefix_quiz_calculated_question_idx diff --git a/mod/quiz/restorelib.php b/mod/quiz/restorelib.php index ac2d9b8e56..d55a92a921 100644 --- a/mod/quiz/restorelib.php +++ b/mod/quiz/restorelib.php @@ -1012,6 +1012,7 @@ $calculated->tolerance = backup_todb($cal_info['#']['TOLERANCE']['0']['#']); $calculated->tolerancetype = backup_todb($cal_info['#']['TOLERANCETYPE']['0']['#']); $calculated->correctanswerlength = backup_todb($cal_info['#']['CORRECTANSWERLENGTH']['0']['#']); + $calculated->correctanswerformat = backup_todb($cal_info['#']['CORRECTANSWERFORMAT']['0']['#']); ////We have to recode the answer field $answer = backup_getid($restore->backup_unique_code,"quiz_answers",$calculated->answer); diff --git a/mod/quiz/version.php b/mod/quiz/version.php index ea700c8373..c6f043845c 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 = 2004112300; // The (date) version of this module +$module->version = 2004120501; // The (date) version of this module $module->requires = 2004112300; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)?