diff --git a/mod/scorm/db/mysql.php b/mod/scorm/db/mysql.php index 61e1b8d071a..f545478602a 100755 --- a/mod/scorm/db/mysql.php +++ b/mod/scorm/db/mysql.php @@ -103,6 +103,21 @@ function scorm_upgrade($oldversion) { table_column("scorm_scoes", "", "parameters", "VARCHAR", "255", "", "", "NOT NULL", "launch"); } + if ($oldversion < 2005040700) { + execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP PRIMARY KEY;"); + execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP KEY userdata;"); + execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX userid"); + modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD UNIQUE track (userid,scormid,scoid,element);'); + modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD PRIMARY KEY id (id);'); + modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX scormid (scormid);'); + modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX userid (userid);'); + modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX scoid (scoid);'); + modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX element (element);'); + execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX id;"); + table_column("scorm_scoes", "timelimitaction", "timelimitaction", "VARCHAR", "19", "", "", "NOT NULL"); + table_column("scorm_scoes", "scormtype", "scormtype", "VARCHAR", "5", "", "", "NOT NULL"); + } + return true; } diff --git a/mod/scorm/db/mysql.sql b/mod/scorm/db/mysql.sql index b0d2e3958aa..08475c4b9f0 100755 --- a/mod/scorm/db/mysql.sql +++ b/mod/scorm/db/mysql.sql @@ -28,10 +28,10 @@ CREATE TABLE prefix_scorm_scoes ( identifier varchar(255) NOT NULL default '', launch varchar(255) NOT NULL default '', parameters varchar(255) NOT NULL default '', - scormtype set('sco','asset') NOT NULL default '', + scormtype varchar(5) NOT NULL default '', title varchar(255) NOT NULL default '', prerequisites varchar(200) NOT NULL default '', - maxtimeallowed set('exit,message','exit,no message','continue,message','continue,no message'), + maxtimeallowed varchar(19) NOT NULL dafault '', timelimitaction varchar(19) NOT NULL default '', datafromlms varchar(255) NOT NULL default '', masteryscore varchar(200) NOT NULL default '', @@ -50,9 +50,11 @@ CREATE TABLE prefix_scorm_scoes_track ( element varchar(255) NOT NULL default '', value longtext NOT NULL default '', PRIMARY KEY (id), - UNIQUE (userid, scormid, scoid, element), - KEY userdata (userid, scormid, scoid), - KEY id (id) + KEY userid (userid), + KEY scormid (scormid), + KEY scoid (scoid), + KEY elemeny (element), + UNIQUE track (userid, scormid, scoid, element) ) TYPE=MyISAM; # diff --git a/mod/scorm/db/postgres7.sql b/mod/scorm/db/postgres7.sql index 2e3da71814f..c4213c03c54 100755 --- a/mod/scorm/db/postgres7.sql +++ b/mod/scorm/db/postgres7.sql @@ -29,7 +29,11 @@ CREATE TABLE prefix_scorm_scoes ( parameters varchar(255) NOT NULL default '', scormtype varchar(5) NOT NULL default '', title varchar(255) NOT NULL default '', - datafromlms text NOT NULL default '', + prerequisites varchar(200) NOT NULL default '', + maxtimeallowed varchar(19) NOT NULL dafault '', + timelimitaction varchar(19) NOT NULL default '', + datafromlms varchar(255) NOT NULL default '', + masteryscore varchar(200) NOT NULL default '', next integer NOT NULL default '0', previous integer NOT NULL default '0' ); @@ -37,17 +41,19 @@ CREATE TABLE prefix_scorm_scoes ( CREATE INDEX prefix_scorm_scoes_scorm_idx ON prefix_scorm_scoes (scorm); CREATE TABLE prefix_scorm_scoes_track ( - id SERIAL, + id SERIAL PRIMARY KEY, userid integer NOT NULL default '0', scormid integer NOT NULL default '0', scoid integer NOT NULL default '0', element varchar(255) NOT NULL default '', value text NOT NULL default '', - PRIMARY KEY (userid, scormid, scoid, element), UNIQUE (userid, scormid, scoid, element) ); -CREATE INDEX prefix_scorm_scoes_track_userdata_idx ON prefix_scorm_scoes_track (userid, scormid, scoid); +CREATE INDEX prefix_scorm_scoes_track_user_idx ON prefix_scorm_scoes_track (userid); +CREATE INDEX prefix_scorm_scoes_track_scorm_idx ON prefix_scorm_scoes_track (scormid); +CREATE INDEX prefix_scorm_scoes_track_sco_idx ON prefix_scorm_scoes_track (scoid); +CREATE INDEX prefix_scorm_scoes_track_element_idx ON prefix_scorm_scoes_track (element); # # Dumping data for table `log_display`