Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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?
  • Loading branch information...
commit 2ad1b388f7117724bab07ebdfe087a4201d51558 1 parent ab98918
kaipe authored
View
1  mod/quiz/backuplib.php
@@ -419,6 +419,7 @@ function quiz_backup_calculated($bf,$preferences,$question,$level=6,$include_ans
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...
View
4 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;
}
View
1  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`)
View
4 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;
}
View
3  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
View
1  mod/quiz/restorelib.php
@@ -1012,6 +1012,7 @@ function quiz_restore_calculated ($old_question_id,$new_question_id,$info,$resto
$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);
View
2  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)?
Please sign in to comment.
Something went wrong with that request. Please try again.