Skip to content

Commit

Permalink
Indexes for lesson and version bump (honoring partial freeze)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjollnir_ committed Nov 19, 2004
1 parent b55be22 commit 0d3a8fa
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
10 changes: 10 additions & 0 deletions mod/lesson/db/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ function lesson_upgrade($oldversion) {
if ($oldversion < 2004032700) {
table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
}

if ($oldversion < 2004060401) {
modify_database('','ALTER TABLE prefix_lesson ADD INDEX course (course);');
modify_database('','ALTER TABLE prefix_lesson_answers ADD INDEX lessonid (lessonid);');
modify_database('','ALTER TABLE prefix_lesson_attempts ADD INDEX lessonid (lessonid);');
modify_database('','ALTER TABLE prefix_lesson_attempts ADD INDEX pageid (pageid);');
modify_database('','ALTER TABLE prefix_lesson_grades ADD INDEX lessonid (lessonid);');
modify_database('','ALTER TABLE prefix_lesson_grades ADD INDEX userid (userid);');
modify_database('','ALTER TABLE prefix_lesson_pages ADD INDEX lessonid (lessonid);');
}

return true;
}
Expand Down
17 changes: 12 additions & 5 deletions mod/lesson/db/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ CREATE TABLE `prefix_lesson` (
`available` int(10) unsigned NOT NULL default '0',
`deadline` int(10) unsigned NOT NULL default '0',
`timemodified` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `course` (`course`)
) COMMENT='Defines lesson';
# --------------------------------------------------------

Expand All @@ -34,7 +35,8 @@ CREATE TABLE `prefix_lesson_pages` (
`timemodified` int(10) unsigned NOT NULL default '0',
`title` varchar(255) NOT NULL default '',
`contents` text NOT NULL default '',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `lessonid` (`lessonid`)
) COMMENT='Defines lesson_pages';
# --------------------------------------------------------

Expand All @@ -50,7 +52,8 @@ CREATE TABLE `prefix_lesson_answers` (
`answer` text NOT NULL default '',
`response` text NOT NULL default '',
PRIMARY KEY (`id`),
KEY (`pageid`)
KEY (`pageid`),
KEY `lessonid` (`lessonid`)
) COMMENT='Defines lesson_answers';
# --------------------------------------------------------

Expand All @@ -64,7 +67,9 @@ CREATE TABLE `prefix_lesson_attempts` (
`correct` int(10) unsigned NOT NULL default '0',
`timeseen` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY (`userid`)
KEY (`userid`),
KEY `lessonid` (`lessonid`),
KEY `pageid` (`pageid`)
) COMMENT='Defines lesson_attempts';
# --------------------------------------------------------

Expand All @@ -75,7 +80,9 @@ CREATE TABLE `prefix_lesson_grades` (
`grade` int(3) unsigned NOT NULL default '0',
`late` int(3) unsigned NOT NULL default '0',
`completed` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `lessonid` (`lessonid`),
KEY `userid` (`userid`)
) COMMENT='Defines lesson_grades';
# --------------------------------------------------------

Expand Down
12 changes: 12 additions & 0 deletions mod/lesson/db/postgres7.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ function lesson_upgrade($oldversion) {
if ($oldversion < 2004032700) {
table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
}

if ($oldversion < 2004060401) {
modify_database('','CREATE INDEX prefix_lesson_course_idx ON prefix_lesson (course);');
modify_database('','CREATE INDEX prefix_lesson_answers_lessonid_idx ON prefix_lesson_answers (lessonid);');
modify_database('','CREATE INDEX prefix_lesson_answers_pageid_idx ON prefix_lesson_answers (pageid);');
modify_database('','CREATE INDEX prefix_lesson_attempts_lessonid_idx ON prefix_lesson_attempts (lessonid);');
modify_database('','CREATE INDEX prefix_lesson_attempts_pageid_idx ON prefix_lesson_attempts (pageid);');
modify_database('','CREATE INDEX prefix_lesson_attempts_userid_idx ON prefix_lesson_attempts (userid);');
modify_database('','CREATE INDEX prefix_lesson_grades_lessonid_idx ON prefix_lesson_grades (lessonid);');
modify_database('','CREATE INDEX prefix_lesson_grades_userid_idx ON prefix_lesson_grades (userid);');
modify_database('','CREATE INDEX prefix_lesson_pages_lessonid_idx ON prefix_lesson_pages (lessonid);');
}

return true;
}
Expand Down
19 changes: 19 additions & 0 deletions mod/lesson/db/postgres7.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ CREATE TABLE prefix_lesson (
deadline INT8 NOT NULL default '0',
timemodified INT8 NOT NULL default '0'
);

CREATE INDEX prefix_lesson_course_idx ON prefix_lesson (course);

# --------------------------------------------------------

CREATE TABLE prefix_lesson_pages (
Expand All @@ -33,6 +36,9 @@ CREATE TABLE prefix_lesson_pages (
title varchar(255) NOT NULL default '',
contents text NOT NULL default ''
);

CREATE INDEX prefix_lesson_pages_lessonid_idx ON prefix_lesson_pages (lessonid);

# COMMENT='Defines lesson_pages';
# --------------------------------------------------------

Expand All @@ -48,6 +54,10 @@ CREATE TABLE prefix_lesson_answers (
answer text NOT NULL default '',
response text NOT NULL default ''
);

CREATE INDEX prefix_lesson_answers_lessonid_idx ON prefix_lesson_answers (lessonid);
CREATE INDEX prefix_lesson_answers_pageid_idx ON prefix_lesson_answers (pageid);

# COMMENT='Defines lesson_answers';
# --------------------------------------------------------

Expand All @@ -61,6 +71,11 @@ CREATE TABLE prefix_lesson_attempts (
correct INT8 NOT NULL default '0',
timeseen INT8 NOT NULL default '0'
);

CREATE INDEX prefix_lesson_attempts_lessonid_idx ON prefix_lesson_attempts (lessonid);
CREATE INDEX prefix_lesson_attempts_pageid_idx ON prefix_lesson_attempts (pageid);
CREATE INDEX prefix_lesson_attempts_userid_idx ON prefix_lesson_attempts (userid);

#COMMENT='Defines lesson_attempts';
# --------------------------------------------------------

Expand All @@ -72,6 +87,10 @@ CREATE TABLE prefix_lesson_grades (
late INT NOT NULL default '0',
completed INT8 NOT NULL default '0'
);

CREATE INDEX prefix_lesson_grades_lessonid_idx ON prefix_lesson_grades (lessonid);
CREATE INDEX prefix_lesson_grades_userid_idx ON prefix_lesson_grades (userid);

# COMMENT='Defines lesson_grades';
# --------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////

$module->version = 2004060400; // The current module version (Date: YYYYMMDDXX)
$module->version = 2004060401; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2004052505; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)

Expand Down

0 comments on commit 0d3a8fa

Please sign in to comment.