Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed the order of db updates. now the order is old to new.

  • Loading branch information...
commit 1663b64f1e250229966629b7f4be2c95efc049c6 1 parent 7143a28
michaelpenne authored
Showing with 72 additions and 71 deletions.
  1. +72 −71 mod/lesson/db/mysql.php
View
143 mod/lesson/db/mysql.php
@@ -6,44 +6,41 @@ function lesson_upgrade($oldversion) {
global $CFG;
+ if ($oldversion < 2004021600) {
+
+ delete_records("log_display", "module", "lesson");
+
+ modify_database ("", "INSERT INTO prefix_log_display VALUES ('lesson', 'start', 'lesson', 'name');");
+ modify_database ("", "INSERT INTO prefix_log_display VALUES ('lesson', 'end', 'lesson', 'name');");
+ modify_database ("", "INSERT INTO prefix_log_display VALUES ('lesson', 'view', 'lesson_pages', 'title');");
+
+ }
+
+ if ($oldversion < 2004022200) {
+
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxattempts` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxanswers");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `nextpagedefault` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxpages` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER nextpagedefault");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `qtype` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER lessonid");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `qoption` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER qtype");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_answers` ADD `grade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER jumpto");
+
+ }
+
+ if ($oldversion < 2004032000) { // Upgrade some old beta lessons
+ execute_sql(" UPDATE `{$CFG->prefix}lesson_pages` SET qtype = 3 WHERE qtype = 0");
+ }
+
+ if ($oldversion < 2004032400) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `usemaxgrade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER grade");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `minquestions` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER nextpagedefault");
+ }
+
+ if ($oldversion < 2004032700) {
+ table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
+ }
+
// CDC-FLAG
- if ($oldversion < 2004081700) {
- execute_sql("CREATE TABLE `mdl_lesson_default`
- ( `id` int(10) unsigned NOT NULL auto_increment,
- `course` int(10) unsigned NOT NULL default '0',
- `practice` tinyint(3) unsigned NOT NULL default '0',
- `password` varchar(32) NOT NULL default '',
- `usepassword` int(3) unsigned NOT NULL default '0',
- `grade` tinyint(3) NOT NULL default '0',
- `custom` int(3) unsigned NOT NULL default '0',
- `ongoing` int(3) unsigned NOT NULL default '0',
- `usemaxgrade` tinyint(3) unsigned NOT NULL default '0',
- `maxanswers` int(3) unsigned NOT NULL default '4',
- `maxattempts` int(3) unsigned NOT NULL default '5',
- `review` tinyint(3) unsigned NOT NULL default '0',
- `nextpagedefault` int(3) unsigned NOT NULL default '0',
- `minquestions` tinyint(3) unsigned NOT NULL default '0',
- `maxpages` int(3) unsigned NOT NULL default '0',
- `timed` int(3) unsigned NOT NULL default '0',
- `maxtime` int(10) unsigned NOT NULL default '0',
- `retake` int(3) unsigned NOT NULL default '1',
- `tree` int(3) unsigned NOT NULL default '0',
- `slideshow` int(3) unsigned NOT NULL default '0',
- `width` int(10) unsigned NOT NULL default '640',
- `height` int(10) unsigned NOT NULL default '480',
- `bgcolor` varchar(7) default '#FFFFFF',
- `displayleft` int(3) unsigned NOT NULL default '0',
- `highscores` int(3) unsigned NOT NULL default '0',
- `maxhighscores` int(10) NOT NULL default '0',
- PRIMARY KEY (`id`)
- ) COMMENT = 'Defines lesson_default'");
- }
-
- if ($oldversion < 2004081100) {
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `practice` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `review` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
- }
-
if ($oldversion < 2004072100) {
execute_sql(" create table mdl_lesson_high_scores
( id int(10) unsigned not null auto_increment,
@@ -113,42 +110,46 @@ function lesson_upgrade($oldversion) {
execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxhighscores` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER highscores");
}
- // CDC-FLAG end
-
- if ($oldversion < 2004021600) {
-
- delete_records("log_display", "module", "lesson");
-
- modify_database ("", "INSERT INTO prefix_log_display VALUES ('lesson', 'start', 'lesson', 'name');");
- modify_database ("", "INSERT INTO prefix_log_display VALUES ('lesson', 'end', 'lesson', 'name');");
- modify_database ("", "INSERT INTO prefix_log_display VALUES ('lesson', 'view', 'lesson_pages', 'title');");
- }
-
- if ($oldversion < 2004022200) {
-
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxattempts` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxanswers");
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `nextpagedefault` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `maxpages` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER nextpagedefault");
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `qtype` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER lessonid");
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_pages` ADD `qoption` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER qtype");
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson_answers` ADD `grade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER jumpto");
-
- }
+ if ($oldversion < 2004081100) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `practice` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `review` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
+ }
+
+ if ($oldversion < 2004081700) {
+ execute_sql("CREATE TABLE `mdl_lesson_default`
+ ( `id` int(10) unsigned NOT NULL auto_increment,
+ `course` int(10) unsigned NOT NULL default '0',
+ `practice` tinyint(3) unsigned NOT NULL default '0',
+ `password` varchar(32) NOT NULL default '',
+ `usepassword` int(3) unsigned NOT NULL default '0',
+ `grade` tinyint(3) NOT NULL default '0',
+ `custom` int(3) unsigned NOT NULL default '0',
+ `ongoing` int(3) unsigned NOT NULL default '0',
+ `usemaxgrade` tinyint(3) unsigned NOT NULL default '0',
+ `maxanswers` int(3) unsigned NOT NULL default '4',
+ `maxattempts` int(3) unsigned NOT NULL default '5',
+ `review` tinyint(3) unsigned NOT NULL default '0',
+ `nextpagedefault` int(3) unsigned NOT NULL default '0',
+ `minquestions` tinyint(3) unsigned NOT NULL default '0',
+ `maxpages` int(3) unsigned NOT NULL default '0',
+ `timed` int(3) unsigned NOT NULL default '0',
+ `maxtime` int(10) unsigned NOT NULL default '0',
+ `retake` int(3) unsigned NOT NULL default '1',
+ `tree` int(3) unsigned NOT NULL default '0',
+ `slideshow` int(3) unsigned NOT NULL default '0',
+ `width` int(10) unsigned NOT NULL default '640',
+ `height` int(10) unsigned NOT NULL default '480',
+ `bgcolor` varchar(7) default '#FFFFFF',
+ `displayleft` int(3) unsigned NOT NULL default '0',
+ `highscores` int(3) unsigned NOT NULL default '0',
+ `maxhighscores` int(10) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+ ) COMMENT = 'Defines lesson_default'");
+ }
+ // CDC-FLAG end
- if ($oldversion < 2004032000) { // Upgrade some old beta lessons
- execute_sql(" UPDATE `{$CFG->prefix}lesson_pages` SET qtype = 3 WHERE qtype = 0");
- }
-
- if ($oldversion < 2004032400) {
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `usemaxgrade` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER grade");
- execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `minquestions` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER nextpagedefault");
- }
-
- if ($oldversion < 2004032700) {
- table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
- }
-
+
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.