Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a time marker for tracks

  • Loading branch information...
commit 362a7d40e1bdd32e23133ab9d87390b9b4c79cea 1 parent c37c528
bobopinna authored
95 mod/scorm/db/mysql.php
@@ -5,22 +5,22 @@ function scorm_upgrade($oldversion) {
5 5 /// older versions to match current functionality
6 6 global $CFG;
7 7 if ($oldversion < 2004033000) {
8   - table_column("scorm", "", "auto", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "summary");
  8 + table_column("scorm", "", "auto", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "summary");
9 9 }
10 10 if ($oldversion < 2004040900) {
11 11 table_column("scorm_sco_users", "", "cmi_core_score_raw", "FLOAT", "3", "", "0", "NOT NULL", "cmi_core_session_time");
12 12 }
13 13 if ($oldversion < 2004061800) {
14   - table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
15   - table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
  14 + table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
  15 + table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
16 16 }
17 17 if ($oldversion < 2004070800) {
18   - table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
19   - modify_database("", "ALTER TABLE `{$CFG->prefix}scorm_sco_users` DROP `cmi_launch_data`;");
  18 + table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
  19 + modify_database("", "ALTER TABLE `{$CFG->prefix}scorm_sco_users` DROP `cmi_launch_data`;");
20 20 }
21 21 if ($oldversion < 2004071700) {
22   - table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
23   - table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
  22 + table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
  23 + table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
24 24 }
25 25 if ($oldversion < 2004071900) {
26 26 table_column("scorm", "", "maxgrade", "FLOAT", "3", "", "0", "NOT NULL", "reference");
@@ -44,17 +44,19 @@ function scorm_upgrade($oldversion) {
44 44 if ($oldversion < 2005031300) {
45 45 table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title");
46 46 table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites");
47   - modify_database('',"ALTER TABLE prefix_scorm_scoes ADD timelimitaction SET('exit,message','exit,no message','continue,message','continue,no message') DEFAULT '' AFTER `maxtimeallowed`");
  47 + modify_database('',"ALTER TABLE prefix_scorm_scoes ADD timelimitaction ".
  48 + "SET('exit,message','exit,no message','continue,message','continue,no message') ".
  49 + "DEFAULT '' AFTER 'maxtimeallowed'");
48 50 table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms");
49 51
50 52 $oldscoes = get_records_select("scorm_scoes","1","id ASC");
51 53 modify_database('',"ALTER TABLE prefix_scorm_scoes CHANGE type scormtype SET('sco','asset') DEFAULT '' NOT NULL");
52 54 if(!empty($oldscoes)) {
53   - foreach ($oldscoes as $sco) {
54   - $sco->scormtype = $sco->type;
55   - unset($sco->type);
56   - update_record("scorm_scoes",$sco);
57   - }
  55 + foreach ($oldscoes as $sco) {
  56 + $sco->scormtype = $sco->type;
  57 + unset($sco->type);
  58 + update_record("scorm_scoes",$sco);
  59 + }
58 60 }
59 61
60 62 execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
@@ -71,24 +73,29 @@ function scorm_upgrade($oldversion) {
71 73 ) TYPE=MyISAM;",false);
72 74
73 75 $oldtrackingdata = get_records_select("scorm_sco_users","1","id ASC");
74   - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
  76 + $oldelements = array ('cmi_core_lesson_location',
  77 + 'cmi_core_lesson_status',
  78 + 'cmi_core_exit',
  79 + 'cmi_core_total_time',
  80 + 'cmi_core_score_raw',
  81 + 'cmi_suspend_data');
75 82
76 83 if(!empty($oldtrackingdata)) {
77   - foreach ($oldtrackingdata as $oldtrack) {
78   - $newtrack = '';
79   - $newtrack->userid = $oldtrack->userid;
80   - $newtrack->scormid = $oldtrack->scormid;
81   - $newtrack->scoid = $oldtrack->scoid;
  84 + foreach ($oldtrackingdata as $oldtrack) {
  85 + $newtrack = '';
  86 + $newtrack->userid = $oldtrack->userid;
  87 + $newtrack->scormid = $oldtrack->scormid;
  88 + $newtrack->scoid = $oldtrack->scoid;
82 89
83   - foreach ( $oldelements as $element) {
84   - $newtrack->element = $element;
85   - $newtrack->value = $oldtrack->$element;
86   - if ($newtrack->value == NULL) {
87   - $newtrack->value = '';
88   - }
89   - insert_record("scorm_scoes_track",$newtrack,false);
90   - }
91   - }
  90 + foreach ( $oldelements as $element) {
  91 + $newtrack->element = $element;
  92 + $newtrack->value = $oldtrack->$element;
  93 + if ($newtrack->value == NULL) {
  94 + $newtrack->value = '';
  95 + }
  96 + insert_record("scorm_scoes_track",$newtrack,false);
  97 + }
  98 + }
92 99 }
93 100
94 101 modify_database('',"DROP TABLE prefix_scorm_sco_users");
@@ -119,16 +126,16 @@ function scorm_upgrade($oldversion) {
119 126 }
120 127
121 128 if ($oldversion < 2005041500) {
122   - if ($scorms = get_records_select("scorm","1","id ASC")) {
123   - foreach ($scorms as $scorm) {
124   - if (strlen($scorm->datadir) == 14) {
125   - $basedir = $CFG->dataroot.'/'.$scorm->course;
  129 + if ($scorms = get_records_select("scorm","1","id ASC")) {
  130 + foreach ($scorms as $scorm) {
  131 + if (strlen($scorm->datadir) == 14) {
  132 + $basedir = $CFG->dataroot.'/'.$scorm->course;
126 133 $scormdir = '/moddata/scorm';
127 134 rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id);
128 135 }
129   - }
130   - }
131   - execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `datadir`'); // Old field
  136 + }
  137 + }
  138 + execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `datadir`'); // Old field
132 139 }
133 140
134 141 if ($oldversion < 2005041600) {
@@ -138,8 +145,18 @@ function scorm_upgrade($oldversion) {
138 145 if ($oldversion < 2005042700) {
139 146 $trackingdata = get_records_select("scorm_scoes_track","1","id ASC");
140 147 if (!empty($trackingdata)) {
141   - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
142   - $newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data');
  148 + $oldelements = array ('cmi_core_lesson_location',
  149 + 'cmi_core_lesson_status',
  150 + 'cmi_core_exit',
  151 + 'cmi_core_total_time',
  152 + 'cmi_core_score_raw',
  153 + 'cmi_suspend_data');
  154 + $newelements = array ('cmi.core.lesson_location',
  155 + 'cmi.core.lesson_status',
  156 + 'cmi.core.exit',
  157 + 'cmi.core.total_time',
  158 + 'cmi.core.score.raw',
  159 + 'cmi.suspend_data');
143 160 foreach ($trackingdata as $track) {
144 161 if (($pos = array_search($track->element,$oldelements)) !== false) {
145 162 $track->element = $newelements[$pos];
@@ -158,6 +175,10 @@ function scorm_upgrade($oldversion) {
158 175 table_column("scorm", "", "height", "INT", "10", "", "600", "NOT NULL", "width");
159 176 }
160 177
  178 + if ($oldversion < 2005052200) {
  179 + table_column("scorm_scoes_track", "", "timemodified", "INT", "10", "UNSIGNED", "0", "NOT NULL", "value");
  180 + }
  181 +
161 182 return true;
162 183 }
163 184 ?>
1  mod/scorm/db/mysql.sql
@@ -52,6 +52,7 @@ CREATE TABLE prefix_scorm_scoes_track (
52 52 scoid int(10) unsigned NOT NULL default '0',
53 53 element varchar(255) NOT NULL default '',
54 54 value longtext NOT NULL default '',
  55 + timemodified int(10) unsigned NOT NULL default '0',
55 56 PRIMARY KEY (id),
56 57 KEY userid (userid),
57 58 KEY scormid (scormid),
96 mod/scorm/db/postgres7.php
@@ -5,22 +5,22 @@ function scorm_upgrade($oldversion) {
5 5 // older versions to match current functionality
6 6 global $CFG;
7 7 if ($oldversion < 2004033000) {
8   - table_column("scorm", "", "auto", "integer", "1", "", "0", "NOT NULL", "summary");
  8 + table_column("scorm", "", "auto", "integer", "1", "", "0", "NOT NULL", "summary");
9 9 }
10 10 if ($oldversion < 2004040900) {
11 11 table_column("scorm_sco_users", "", "cmi_core_score_raw", "real", "3", "", "0", "NOT NULL", "cmi_core_session_time");
12 12 }
13 13 if ($oldversion < 2004061800) {
14   - table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
15   - table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
  14 + table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
  15 + table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
16 16 }
17 17 if ($oldversion < 2004070800) {
18   - table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
19   - modify_database("", "ALTER TABLE {$CFG->prefix}scorm_sco_users DROP cmi_launch_data;");
  18 + table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
  19 + modify_database("", "ALTER TABLE {$CFG->prefix}scorm_sco_users DROP cmi_launch_data;");
20 20 }
21 21 if ($oldversion < 2004071700) {
22   - table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
23   - table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
  22 + table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
  23 + table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
24 24 }
25 25 if ($oldversion < 2004071900) {
26 26 table_column("scorm", "", "maxgrade", "real", "3", "", "0", "NOT NULL", "reference");
@@ -50,11 +50,11 @@ function scorm_upgrade($oldversion) {
50 50 $oldscoes = get_records_select("scorm_scoes",null,"id ASC");
51 51 table_column("scorm_scoes", "type", "scormtype", "VARCHAR", "5", "", "", "NOT NULL");
52 52 if(!empty($oldscoes)) {
53   - foreach ($oldscoes as $sco) {
54   - $sco->scormtype = $sco->type;
55   - unset($sco->type);
56   - update_record("scorm_scoes",$sco);
57   - }
  53 + foreach ($oldscoes as $sco) {
  54 + $sco->scormtype = $sco->type;
  55 + unset($sco->type);
  56 + update_record("scorm_scoes",$sco);
  57 + }
58 58 }
59 59
60 60 execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
@@ -71,24 +71,29 @@ function scorm_upgrade($oldversion) {
71 71 modify_database('','CREATE INDEX prefix_scorm_scoes_track_userdata_idx ON prefix_scorm_scoes_track (userid, scormid, scoid);');
72 72
73 73 $oldtracking = get_records_select('scorm_sco_users',null,'id ASC');
74   - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
  74 + $oldelements = array ('cmi_core_lesson_location',
  75 + 'cmi_core_lesson_status',
  76 + 'cmi_core_exit',
  77 + 'cmi_core_total_time',
  78 + 'cmi_core_score_raw',
  79 + 'cmi_suspend_data');
75 80
76 81 if(!empty($oldtrackings)) {
77   - foreach ($oldtrackings as $oldtrack) {
78   - $newtrack = '';
79   - $newtrack->userid = $oldtrack->userid;
80   - $newtrack->scormid = $oldtrack->scormid;
81   - $newtrack->scoid = $oldtrack->scoid;
  82 + foreach ($oldtrackings as $oldtrack) {
  83 + $newtrack = '';
  84 + $newtrack->userid = $oldtrack->userid;
  85 + $newtrack->scormid = $oldtrack->scormid;
  86 + $newtrack->scoid = $oldtrack->scoid;
82 87
83   - foreach ( $oldelements as $element) {
84   - $newtrack->element = $element;
85   - $newtrack->value = $oldtrack->$element;
86   - if ($newtrack->value == NULL) {
87   - $newtrack->value = '';
88   - }
89   - insert_record('scorm_scoes_track',$newtrack,false);
90   - }
91   - }
  88 + foreach ( $oldelements as $element) {
  89 + $newtrack->element = $element;
  90 + $newtrack->value = $oldtrack->$element;
  91 + if ($newtrack->value == NULL) {
  92 + $newtrack->value = '';
  93 + }
  94 + insert_record('scorm_scoes_track',$newtrack,false);
  95 + }
  96 + }
92 97 }
93 98
94 99 modify_database('',"DROP TABLE prefix_scorm_sco_users");
@@ -106,8 +111,8 @@ function scorm_upgrade($oldversion) {
106 111 if ($oldversion < 2005040700) {
107 112 //execute_sql('DROP PRIMARY KEY '.$CFG->prefix.'scorm_scoes_track_pkey;',false);
108 113 execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userdata_idx;',false);
109   - execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userid_key;',false);
110   - modify_database('','CREATE UNIQUE INDEX prefix_scorm_scoes_track_track_idx ON prefix_scorm_scoes_track (userid, scormid, scoid, element);');
  114 + execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userid_key;',false);
  115 + modify_database('','CREATE UNIQUE INDEX prefix_scorm_scoes_track_track_idx ON prefix_scorm_scoes_track (userid, scormid, scoid, element);');
111 116 execute_sql('ALTER TABLE '.$CFG->prefix.'scorm_scoes_track ADD PRIMARY KEY ("id");',false);
112 117 modify_database('','CREATE INDEX prefix_scorm_scoes_track_scormid_idx ON prefix_scorm_scoes_track (scormid);');
113 118 modify_database('','CREATE INDEX prefix_scorm_scoes_track_userid_idx ON prefix_scorm_scoes_track (userid);');
@@ -116,16 +121,16 @@ function scorm_upgrade($oldversion) {
116 121 }
117 122
118 123 if ($oldversion < 2005041500) {
119   - if ($scorms = get_records_select('scorm',null,'id ASC')) {
120   - foreach ($scorms as $scorm) {
121   - if (strlen($scorm->datadir) == 14) {
122   - $basedir = $CFG->dataroot.'/'.$scorm->course;
  124 + if ($scorms = get_records_select('scorm',null,'id ASC')) {
  125 + foreach ($scorms as $scorm) {
  126 + if (strlen($scorm->datadir) == 14) {
  127 + $basedir = $CFG->dataroot.'/'.$scorm->course;
123 128 $scormdir = '/moddata/scorm';
124 129 rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id);
125 130 }
126   - }
127   - }
128   - execute_sql('ALTER TABLE '.$CFG->prefix.'scorm DROP datadir'); // Old field
  131 + }
  132 + }
  133 + execute_sql('ALTER TABLE '.$CFG->prefix.'scorm DROP datadir'); // Old field
129 134 }
130 135
131 136 if ($oldversion < 2005041600) {
@@ -135,8 +140,18 @@ function scorm_upgrade($oldversion) {
135 140 if ($oldversion < 2005042700) {
136 141 $trackingdata = get_records_select("scorm_scoes_track",null,"id ASC");
137 142 if (!empty($trackingdata)) {
138   - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
139   - $newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data');
  143 + $oldelements = array ('cmi_core_lesson_location',
  144 + 'cmi_core_lesson_status',
  145 + 'cmi_core_exit',
  146 + 'cmi_core_total_time',
  147 + 'cmi_core_score_raw',
  148 + 'cmi_suspend_data');
  149 + $newelements = array ('cmi.core.lesson_location',
  150 + 'cmi.core.lesson_status',
  151 + 'cmi.core.exit',
  152 + 'cmi.core.total_time',
  153 + 'cmi.core.score.raw',
  154 + 'cmi.suspend_data');
140 155 foreach ($trackingdata as $track) {
141 156 if (($pos = array_search($track->element,$oldelements)) !== false) {
142 157 $track->element = $newelements[$pos];
@@ -155,7 +170,10 @@ function scorm_upgrade($oldversion) {
155 170 table_column("scorm", "", "height", "integer", "", "", "600", "NOT NULL", "width");
156 171 }
157 172
  173 + if ($oldversion < 2005052200) {
  174 + table_column("scorm_scoes_track", "", "timemodified", "integer", "", "", "0", "NOT NULL", "value");
  175 + }
  176 +
158 177 return true;
159 178 }
160 179 ?>
161   -
1  mod/scorm/db/postgres7.sql
@@ -49,6 +49,7 @@ CREATE TABLE prefix_scorm_scoes_track (
49 49 scoid integer NOT NULL default '0',
50 50 element varchar(255) NOT NULL default '',
51 51 value text NOT NULL default '',
  52 + timemodified integer NOT NULL default '0'
52 53 UNIQUE (userid, scormid, scoid, element)
53 54 );
54 55

0 comments on commit 362a7d4

Please sign in to comment.
Something went wrong with that request. Please try again.