Skip to content

Commit

Permalink
Updating database and backup/restore in order to make it possible
Browse files Browse the repository at this point in the history
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
kaipe committed Dec 5, 2004
1 parent ab98918 commit 2ad1b38
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions mod/quiz/backuplib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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("TOLERANCE",$level+1,false,$calculated->tolerance));
fwrite ($bf,full_tag("TOLERANCETYPE",$level+1,false,$calculated->tolerancetype)); fwrite ($bf,full_tag("TOLERANCETYPE",$level+1,false,$calculated->tolerancetype));
fwrite ($bf,full_tag("CORRECTANSWERLENGTH",$level+1,false,$calculated->correctanswerlength)); fwrite ($bf,full_tag("CORRECTANSWERLENGTH",$level+1,false,$calculated->correctanswerlength));
fwrite ($bf,full_tag("CORRECTANSWERFORMAT",$level+1,false,$calculated->correctanswerformat));
//Now backup numerical_units //Now backup numerical_units
$status = quiz_backup_numerical_units($bf,$preferences,$question,7); $status = quiz_backup_numerical_units($bf,$preferences,$question,7);
//Now backup required dataset definitions and items... //Now backup required dataset definitions and items...
Expand Down
4 changes: 4 additions & 0 deletions mod/quiz/db/mysql.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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_numerical_units ADD INDEX question (question);');
modify_database('','ALTER TABLE prefix_quiz_questions ADD INDEX category (category);'); 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; return true;
} }
Expand Down
1 change: 1 addition & 0 deletions mod/quiz/db/mysql.sql
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ CREATE TABLE `prefix_quiz_calculated` (
`tolerance` varchar(20) NOT NULL default '0.0', `tolerance` varchar(20) NOT NULL default '0.0',
`tolerancetype` int(10) NOT NULL default '1', `tolerancetype` int(10) NOT NULL default '1',
`correctanswerlength` int(10) NOT NULL default '2', `correctanswerlength` int(10) NOT NULL default '2',
`correctanswerformat` int(10) NOT NULL default '2',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `question` (`question`), KEY `question` (`question`),
KEY `answer` (`answer`) KEY `answer` (`answer`)
Expand Down
4 changes: 4 additions & 0 deletions mod/quiz/db/postgres7.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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);'); 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; return true;
} }


Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/db/postgres7.sql
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ CREATE TABLE prefix_quiz_calculated (
answer INT8 NOT NULL default '0', answer INT8 NOT NULL default '0',
tolerance varchar(20) NOT NULL default '0.0', tolerance varchar(20) NOT NULL default '0.0',
tolerancetype INT8 NOT NULL default '1', 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 CREATE INDEX prefix_quiz_calculated_question_idx
Expand Down
1 change: 1 addition & 0 deletions mod/quiz/restorelib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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->tolerance = backup_todb($cal_info['#']['TOLERANCE']['0']['#']);
$calculated->tolerancetype = backup_todb($cal_info['#']['TOLERANCETYPE']['0']['#']); $calculated->tolerancetype = backup_todb($cal_info['#']['TOLERANCETYPE']['0']['#']);
$calculated->correctanswerlength = backup_todb($cal_info['#']['CORRECTANSWERLENGTH']['0']['#']); $calculated->correctanswerlength = backup_todb($cal_info['#']['CORRECTANSWERLENGTH']['0']['#']);
$calculated->correctanswerformat = backup_todb($cal_info['#']['CORRECTANSWERFORMAT']['0']['#']);


////We have to recode the answer field ////We have to recode the answer field
$answer = backup_getid($restore->backup_unique_code,"quiz_answers",$calculated->answer); $answer = backup_getid($restore->backup_unique_code,"quiz_answers",$calculated->answer);
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/version.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php // 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->requires = 2004112300; // Requires this Moodle version
$module->cron = 0; // How often should cron check this module (seconds)? $module->cron = 0; // How often should cron check this module (seconds)?
Expand Down

0 comments on commit 2ad1b38

Please sign in to comment.