mirror of
https://github.com/moodle/moodle.git
synced 2025-01-22 08:11:26 +01:00
29d5d0b40c
The code for reviewing an existing attempt is now separate in review.php and now has a log entry of it's own. The overview and regrade reports are now in separate subdirectories under the "report" directory. Each has a primary "report.php" file which implements the report as a class. These existing reports are very simple, but now more complex ones can easily be written. (I am about to do one).
116 lines
5.7 KiB
PHP
116 lines
5.7 KiB
PHP
<?PHP // $Id$
|
|
|
|
function quiz_upgrade($oldversion) {
|
|
// This function does anything necessary to upgrade
|
|
// older versions to match current functionality
|
|
|
|
global $CFG;
|
|
|
|
if ($oldversion < 2002101800) {
|
|
execute_sql(" ALTER TABLE `quiz_attempts` ".
|
|
" ADD `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `sumgrades` , ".
|
|
" ADD `timefinish` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timestart` ");
|
|
execute_sql(" UPDATE `quiz_attempts` SET timestart = timemodified ");
|
|
execute_sql(" UPDATE `quiz_attempts` SET timefinish = timemodified ");
|
|
}
|
|
if ($oldversion < 2002102101) {
|
|
execute_sql(" DELETE FROM log_display WHERE module = 'quiz' ");
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'view', 'quiz', 'name') ");
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'report', 'quiz', 'name') ");
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'attempt', 'quiz', 'name') ");
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'submit', 'quiz', 'name') ");
|
|
}
|
|
if ($oldversion < 2002102600) {
|
|
execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL ");
|
|
}
|
|
|
|
if ($oldversion < 2002122300) {
|
|
execute_sql("ALTER TABLE `quiz_grades` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
|
execute_sql("ALTER TABLE `quiz_attempts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
|
}
|
|
|
|
// prefixes required from here on, or use table_column()
|
|
|
|
if ($oldversion < 2003010100) {
|
|
execute_sql(" ALTER TABLE {$CFG->prefix}quiz ADD review TINYINT(4) UNSIGNED DEFAULT '0' NOT NULL AFTER `grademethod` ");
|
|
}
|
|
|
|
if ($oldversion < 2003010301) {
|
|
table_column("quiz_truefalse", "true", "trueanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
|
|
table_column("quiz_truefalse", "false", "falseanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
|
|
table_column("quiz_questions", "type", "qtype", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
|
|
}
|
|
|
|
if ($oldversion < 2003022303) {
|
|
modify_database ("", "CREATE TABLE `prefix_quiz_randommatch` (
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
`question` int(10) unsigned NOT NULL default '0',
|
|
`choose` INT UNSIGNED DEFAULT '4' NOT NULL,
|
|
PRIMARY KEY ( `id` )
|
|
);");
|
|
}
|
|
|
|
if ($oldversion < 2003030303) {
|
|
table_column("quiz_questions", "", "defaultgrade", "INTEGER", "6", "UNSIGNED", "1", "NOT NULL", "image");
|
|
}
|
|
|
|
if ($oldversion < 2003032601) {
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_answers` ADD INDEX(question) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_attempts` ADD INDEX(quiz) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_attempts` ADD INDEX(userid) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_grades` ADD INDEX(quiz) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_grades` ADD INDEX(userid) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_question_grades` ADD INDEX(quiz) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_question_grades` ADD INDEX(question) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_randommatch` ADD INDEX(question) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_responses` ADD INDEX(attempt) ");
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_responses` ADD INDEX(question) ");
|
|
}
|
|
|
|
if ($oldversion < 2003033100) {
|
|
modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_quiz_randomsamatch ");
|
|
modify_database ("", "CREATE TABLE `prefix_quiz_match` (
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
`question` int(10) unsigned NOT NULL default '0',
|
|
`subquestions` varchar(255) NOT NULL default '',
|
|
PRIMARY KEY (`id`),
|
|
KEY `question` (`question`)
|
|
);");
|
|
|
|
modify_database ("", "CREATE TABLE `prefix_quiz_match_sub` (
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
`question` int(10) unsigned NOT NULL default '0',
|
|
`questiontext` text NOT NULL,
|
|
`answertext` varchar(255) NOT NULL default '',
|
|
PRIMARY KEY (`id`),
|
|
KEY `question` (`question`)
|
|
);");
|
|
}
|
|
|
|
if ($oldversion < 2003040901) {
|
|
table_column("quiz", "", "shufflequestions", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "review");
|
|
table_column("quiz", "", "shuffleanswers", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "shufflequestions");
|
|
}
|
|
|
|
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 '',
|
|
PRIMARY KEY (`id`),
|
|
KEY `answer` (`answer`)
|
|
) TYPE=MyISAM COMMENT='Options for numerical questions'; ");
|
|
}
|
|
|
|
if ($oldversion < 2003072400) {
|
|
execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('quiz', 'review', 'quiz', 'name') ");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
?>
|