mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Added a time marker for tracks
This commit is contained in:
parent
c37c5280b9
commit
362a7d40e1
@ -5,22 +5,22 @@ function scorm_upgrade($oldversion) {
|
||||
/// older versions to match current functionality
|
||||
global $CFG;
|
||||
if ($oldversion < 2004033000) {
|
||||
table_column("scorm", "", "auto", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "summary");
|
||||
table_column("scorm", "", "auto", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "summary");
|
||||
}
|
||||
if ($oldversion < 2004040900) {
|
||||
table_column("scorm_sco_users", "", "cmi_core_score_raw", "FLOAT", "3", "", "0", "NOT NULL", "cmi_core_session_time");
|
||||
}
|
||||
if ($oldversion < 2004061800) {
|
||||
table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
|
||||
table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
|
||||
table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
|
||||
table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
|
||||
}
|
||||
if ($oldversion < 2004070800) {
|
||||
table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
|
||||
modify_database("", "ALTER TABLE `{$CFG->prefix}scorm_sco_users` DROP `cmi_launch_data`;");
|
||||
table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
|
||||
modify_database("", "ALTER TABLE `{$CFG->prefix}scorm_sco_users` DROP `cmi_launch_data`;");
|
||||
}
|
||||
if ($oldversion < 2004071700) {
|
||||
table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
|
||||
table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
|
||||
table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
|
||||
table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
|
||||
}
|
||||
if ($oldversion < 2004071900) {
|
||||
table_column("scorm", "", "maxgrade", "FLOAT", "3", "", "0", "NOT NULL", "reference");
|
||||
@ -44,17 +44,19 @@ function scorm_upgrade($oldversion) {
|
||||
if ($oldversion < 2005031300) {
|
||||
table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title");
|
||||
table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites");
|
||||
modify_database('',"ALTER TABLE prefix_scorm_scoes ADD timelimitaction SET('exit,message','exit,no message','continue,message','continue,no message') DEFAULT '' AFTER `maxtimeallowed`");
|
||||
modify_database('',"ALTER TABLE prefix_scorm_scoes ADD timelimitaction ".
|
||||
"SET('exit,message','exit,no message','continue,message','continue,no message') ".
|
||||
"DEFAULT '' AFTER 'maxtimeallowed'");
|
||||
table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms");
|
||||
|
||||
$oldscoes = get_records_select("scorm_scoes","1","id ASC");
|
||||
modify_database('',"ALTER TABLE prefix_scorm_scoes CHANGE type scormtype SET('sco','asset') DEFAULT '' NOT NULL");
|
||||
if(!empty($oldscoes)) {
|
||||
foreach ($oldscoes as $sco) {
|
||||
$sco->scormtype = $sco->type;
|
||||
unset($sco->type);
|
||||
update_record("scorm_scoes",$sco);
|
||||
}
|
||||
foreach ($oldscoes as $sco) {
|
||||
$sco->scormtype = $sco->type;
|
||||
unset($sco->type);
|
||||
update_record("scorm_scoes",$sco);
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
|
||||
@ -71,24 +73,29 @@ function scorm_upgrade($oldversion) {
|
||||
) TYPE=MyISAM;",false);
|
||||
|
||||
$oldtrackingdata = get_records_select("scorm_sco_users","1","id ASC");
|
||||
$oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
|
||||
$oldelements = array ('cmi_core_lesson_location',
|
||||
'cmi_core_lesson_status',
|
||||
'cmi_core_exit',
|
||||
'cmi_core_total_time',
|
||||
'cmi_core_score_raw',
|
||||
'cmi_suspend_data');
|
||||
|
||||
if(!empty($oldtrackingdata)) {
|
||||
foreach ($oldtrackingdata as $oldtrack) {
|
||||
$newtrack = '';
|
||||
$newtrack->userid = $oldtrack->userid;
|
||||
$newtrack->scormid = $oldtrack->scormid;
|
||||
$newtrack->scoid = $oldtrack->scoid;
|
||||
foreach ($oldtrackingdata as $oldtrack) {
|
||||
$newtrack = '';
|
||||
$newtrack->userid = $oldtrack->userid;
|
||||
$newtrack->scormid = $oldtrack->scormid;
|
||||
$newtrack->scoid = $oldtrack->scoid;
|
||||
|
||||
foreach ( $oldelements as $element) {
|
||||
$newtrack->element = $element;
|
||||
$newtrack->value = $oldtrack->$element;
|
||||
if ($newtrack->value == NULL) {
|
||||
$newtrack->value = '';
|
||||
}
|
||||
insert_record("scorm_scoes_track",$newtrack,false);
|
||||
}
|
||||
}
|
||||
foreach ( $oldelements as $element) {
|
||||
$newtrack->element = $element;
|
||||
$newtrack->value = $oldtrack->$element;
|
||||
if ($newtrack->value == NULL) {
|
||||
$newtrack->value = '';
|
||||
}
|
||||
insert_record("scorm_scoes_track",$newtrack,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modify_database('',"DROP TABLE prefix_scorm_sco_users");
|
||||
@ -119,16 +126,16 @@ function scorm_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2005041500) {
|
||||
if ($scorms = get_records_select("scorm","1","id ASC")) {
|
||||
foreach ($scorms as $scorm) {
|
||||
if (strlen($scorm->datadir) == 14) {
|
||||
$basedir = $CFG->dataroot.'/'.$scorm->course;
|
||||
if ($scorms = get_records_select("scorm","1","id ASC")) {
|
||||
foreach ($scorms as $scorm) {
|
||||
if (strlen($scorm->datadir) == 14) {
|
||||
$basedir = $CFG->dataroot.'/'.$scorm->course;
|
||||
$scormdir = '/moddata/scorm';
|
||||
rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `datadir`'); // Old field
|
||||
}
|
||||
}
|
||||
execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `datadir`'); // Old field
|
||||
}
|
||||
|
||||
if ($oldversion < 2005041600) {
|
||||
@ -138,8 +145,18 @@ function scorm_upgrade($oldversion) {
|
||||
if ($oldversion < 2005042700) {
|
||||
$trackingdata = get_records_select("scorm_scoes_track","1","id ASC");
|
||||
if (!empty($trackingdata)) {
|
||||
$oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
|
||||
$newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data');
|
||||
$oldelements = array ('cmi_core_lesson_location',
|
||||
'cmi_core_lesson_status',
|
||||
'cmi_core_exit',
|
||||
'cmi_core_total_time',
|
||||
'cmi_core_score_raw',
|
||||
'cmi_suspend_data');
|
||||
$newelements = array ('cmi.core.lesson_location',
|
||||
'cmi.core.lesson_status',
|
||||
'cmi.core.exit',
|
||||
'cmi.core.total_time',
|
||||
'cmi.core.score.raw',
|
||||
'cmi.suspend_data');
|
||||
foreach ($trackingdata as $track) {
|
||||
if (($pos = array_search($track->element,$oldelements)) !== false) {
|
||||
$track->element = $newelements[$pos];
|
||||
@ -158,6 +175,10 @@ function scorm_upgrade($oldversion) {
|
||||
table_column("scorm", "", "height", "INT", "10", "", "600", "NOT NULL", "width");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005052200) {
|
||||
table_column("scorm_scoes_track", "", "timemodified", "INT", "10", "UNSIGNED", "0", "NOT NULL", "value");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
|
@ -52,6 +52,7 @@ CREATE TABLE prefix_scorm_scoes_track (
|
||||
scoid int(10) unsigned NOT NULL default '0',
|
||||
element varchar(255) NOT NULL default '',
|
||||
value longtext NOT NULL default '',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
KEY userid (userid),
|
||||
KEY scormid (scormid),
|
||||
|
@ -5,22 +5,22 @@ function scorm_upgrade($oldversion) {
|
||||
// older versions to match current functionality
|
||||
global $CFG;
|
||||
if ($oldversion < 2004033000) {
|
||||
table_column("scorm", "", "auto", "integer", "1", "", "0", "NOT NULL", "summary");
|
||||
table_column("scorm", "", "auto", "integer", "1", "", "0", "NOT NULL", "summary");
|
||||
}
|
||||
if ($oldversion < 2004040900) {
|
||||
table_column("scorm_sco_users", "", "cmi_core_score_raw", "real", "3", "", "0", "NOT NULL", "cmi_core_session_time");
|
||||
}
|
||||
if ($oldversion < 2004061800) {
|
||||
table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
|
||||
table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
|
||||
table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
|
||||
table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
|
||||
}
|
||||
if ($oldversion < 2004070800) {
|
||||
table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
|
||||
modify_database("", "ALTER TABLE {$CFG->prefix}scorm_sco_users DROP cmi_launch_data;");
|
||||
table_column("scorm_scoes", "", "datafromlms", "TEXT", "", "", "", "NOT NULL", "title");
|
||||
modify_database("", "ALTER TABLE {$CFG->prefix}scorm_sco_users DROP cmi_launch_data;");
|
||||
}
|
||||
if ($oldversion < 2004071700) {
|
||||
table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
|
||||
table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
|
||||
table_column("scorm_scoes", "", "manifest", "VARCHAR", "255", "", "", "NOT NULL", "scorm");
|
||||
table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest");
|
||||
}
|
||||
if ($oldversion < 2004071900) {
|
||||
table_column("scorm", "", "maxgrade", "real", "3", "", "0", "NOT NULL", "reference");
|
||||
@ -50,11 +50,11 @@ function scorm_upgrade($oldversion) {
|
||||
$oldscoes = get_records_select("scorm_scoes",null,"id ASC");
|
||||
table_column("scorm_scoes", "type", "scormtype", "VARCHAR", "5", "", "", "NOT NULL");
|
||||
if(!empty($oldscoes)) {
|
||||
foreach ($oldscoes as $sco) {
|
||||
$sco->scormtype = $sco->type;
|
||||
unset($sco->type);
|
||||
update_record("scorm_scoes",$sco);
|
||||
}
|
||||
foreach ($oldscoes as $sco) {
|
||||
$sco->scormtype = $sco->type;
|
||||
unset($sco->type);
|
||||
update_record("scorm_scoes",$sco);
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track (
|
||||
@ -71,24 +71,29 @@ function scorm_upgrade($oldversion) {
|
||||
modify_database('','CREATE INDEX prefix_scorm_scoes_track_userdata_idx ON prefix_scorm_scoes_track (userid, scormid, scoid);');
|
||||
|
||||
$oldtracking = get_records_select('scorm_sco_users',null,'id ASC');
|
||||
$oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
|
||||
$oldelements = array ('cmi_core_lesson_location',
|
||||
'cmi_core_lesson_status',
|
||||
'cmi_core_exit',
|
||||
'cmi_core_total_time',
|
||||
'cmi_core_score_raw',
|
||||
'cmi_suspend_data');
|
||||
|
||||
if(!empty($oldtrackings)) {
|
||||
foreach ($oldtrackings as $oldtrack) {
|
||||
$newtrack = '';
|
||||
$newtrack->userid = $oldtrack->userid;
|
||||
$newtrack->scormid = $oldtrack->scormid;
|
||||
$newtrack->scoid = $oldtrack->scoid;
|
||||
foreach ($oldtrackings as $oldtrack) {
|
||||
$newtrack = '';
|
||||
$newtrack->userid = $oldtrack->userid;
|
||||
$newtrack->scormid = $oldtrack->scormid;
|
||||
$newtrack->scoid = $oldtrack->scoid;
|
||||
|
||||
foreach ( $oldelements as $element) {
|
||||
$newtrack->element = $element;
|
||||
$newtrack->value = $oldtrack->$element;
|
||||
if ($newtrack->value == NULL) {
|
||||
$newtrack->value = '';
|
||||
}
|
||||
insert_record('scorm_scoes_track',$newtrack,false);
|
||||
}
|
||||
}
|
||||
foreach ( $oldelements as $element) {
|
||||
$newtrack->element = $element;
|
||||
$newtrack->value = $oldtrack->$element;
|
||||
if ($newtrack->value == NULL) {
|
||||
$newtrack->value = '';
|
||||
}
|
||||
insert_record('scorm_scoes_track',$newtrack,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modify_database('',"DROP TABLE prefix_scorm_sco_users");
|
||||
@ -106,8 +111,8 @@ function scorm_upgrade($oldversion) {
|
||||
if ($oldversion < 2005040700) {
|
||||
//execute_sql('DROP PRIMARY KEY '.$CFG->prefix.'scorm_scoes_track_pkey;',false);
|
||||
execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userdata_idx;',false);
|
||||
execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userid_key;',false);
|
||||
modify_database('','CREATE UNIQUE INDEX prefix_scorm_scoes_track_track_idx ON prefix_scorm_scoes_track (userid, scormid, scoid, element);');
|
||||
execute_sql('DROP INDEX '.$CFG->prefix.'scorm_scoes_track_userid_key;',false);
|
||||
modify_database('','CREATE UNIQUE INDEX prefix_scorm_scoes_track_track_idx ON prefix_scorm_scoes_track (userid, scormid, scoid, element);');
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'scorm_scoes_track ADD PRIMARY KEY ("id");',false);
|
||||
modify_database('','CREATE INDEX prefix_scorm_scoes_track_scormid_idx ON prefix_scorm_scoes_track (scormid);');
|
||||
modify_database('','CREATE INDEX prefix_scorm_scoes_track_userid_idx ON prefix_scorm_scoes_track (userid);');
|
||||
@ -116,16 +121,16 @@ function scorm_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2005041500) {
|
||||
if ($scorms = get_records_select('scorm',null,'id ASC')) {
|
||||
foreach ($scorms as $scorm) {
|
||||
if (strlen($scorm->datadir) == 14) {
|
||||
$basedir = $CFG->dataroot.'/'.$scorm->course;
|
||||
if ($scorms = get_records_select('scorm',null,'id ASC')) {
|
||||
foreach ($scorms as $scorm) {
|
||||
if (strlen($scorm->datadir) == 14) {
|
||||
$basedir = $CFG->dataroot.'/'.$scorm->course;
|
||||
$scormdir = '/moddata/scorm';
|
||||
rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'scorm DROP datadir'); // Old field
|
||||
}
|
||||
}
|
||||
execute_sql('ALTER TABLE '.$CFG->prefix.'scorm DROP datadir'); // Old field
|
||||
}
|
||||
|
||||
if ($oldversion < 2005041600) {
|
||||
@ -135,8 +140,18 @@ function scorm_upgrade($oldversion) {
|
||||
if ($oldversion < 2005042700) {
|
||||
$trackingdata = get_records_select("scorm_scoes_track",null,"id ASC");
|
||||
if (!empty($trackingdata)) {
|
||||
$oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data');
|
||||
$newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data');
|
||||
$oldelements = array ('cmi_core_lesson_location',
|
||||
'cmi_core_lesson_status',
|
||||
'cmi_core_exit',
|
||||
'cmi_core_total_time',
|
||||
'cmi_core_score_raw',
|
||||
'cmi_suspend_data');
|
||||
$newelements = array ('cmi.core.lesson_location',
|
||||
'cmi.core.lesson_status',
|
||||
'cmi.core.exit',
|
||||
'cmi.core.total_time',
|
||||
'cmi.core.score.raw',
|
||||
'cmi.suspend_data');
|
||||
foreach ($trackingdata as $track) {
|
||||
if (($pos = array_search($track->element,$oldelements)) !== false) {
|
||||
$track->element = $newelements[$pos];
|
||||
@ -155,7 +170,10 @@ function scorm_upgrade($oldversion) {
|
||||
table_column("scorm", "", "height", "integer", "", "", "600", "NOT NULL", "width");
|
||||
}
|
||||
|
||||
if ($oldversion < 2005052200) {
|
||||
table_column("scorm_scoes_track", "", "timemodified", "integer", "", "", "0", "NOT NULL", "value");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -49,6 +49,7 @@ CREATE TABLE prefix_scorm_scoes_track (
|
||||
scoid integer NOT NULL default '0',
|
||||
element varchar(255) NOT NULL default '',
|
||||
value text NOT NULL default '',
|
||||
timemodified integer NOT NULL default '0'
|
||||
UNIQUE (userid, scormid, scoid, element)
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user