Permalink
Browse files

DB UPGRADE for SCORM 2004

  • Loading branch information...
1 parent db8e700 commit 730d42b336e065b1fd014ec5c76d2cbfdf55c9f4 csantossaenz committed Apr 4, 2007
Showing with 560 additions and 0 deletions.
  1. +207 −0 mod/scorm/backuplib.php
  2. +353 −0 mod/scorm/restorelib.php
View
207 mod/scorm/backuplib.php
@@ -72,6 +72,9 @@ function scorm_backup_one_mod($bf,$preferences,$scorm) {
fwrite ($bf,full_tag('OPTIONS',4,false,$scorm->options));
fwrite ($bf,full_tag('WIDTH',4,false,$scorm->width));
fwrite ($bf,full_tag('HEIGHT',4,false,$scorm->height));
+ fwrite ($bf,full_tag('MD5HASH',4,false,$scorm->md5hash));
+ fwrite ($bf,full_tag("MAXATTEMPT",4,false,$scorm->maxattempt));
+ fwrite ($bf,full_tag("UPDATEFREQ",4,false,$scorm->updatefreq));
fwrite ($bf,full_tag('TIMEMODIFIED',4,false,$scorm->timemodified));
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);
@@ -114,6 +117,9 @@ function backup_scorm_scoes ($bf,$preferences,$scorm) {
fwrite ($bf,full_tag('SCORMTYPE',6,false,$sco->scormtype));
fwrite ($bf,full_tag('TITLE',6,false,$sco->title));
$status = backup_scorm_scoes_data($bf,$preferences,$sco->id);
+ $status = backup_scorm_seq_ruleconds($bf,$preferences,$sco->id);
+ $status = backup_scorm_seq_rolluprule($bf,$preferences,$sco->id);
+ $status = backup_scorm_seq_objective($bf,$preferences,$sco->id);
//End sco
$status =fwrite ($bf,end_tag('SCO',5,true));
}
@@ -141,6 +147,7 @@ function backup_scorm_scoes_data ($bf,$preferences,$sco) {
$status =fwrite ($bf,start_tag('SCO_DATA',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$sco_data->id));
+ fwrite ($bf,full_tag('SCOID',6,false,$sco_data->scoid));
fwrite ($bf,full_tag('NAME',6,false,$sco_data->name));
fwrite ($bf,full_tag('VALUE',6,false,$sco_data->value));
//End sco track
@@ -174,6 +181,8 @@ function backup_scorm_scoes_track ($bf,$preferences,$scorm) {
fwrite ($bf,full_tag('SCOID',6,false,$sco_track->scoid));
fwrite ($bf,full_tag('ELEMENT',6,false,$sco_track->element));
fwrite ($bf,full_tag('VALUE',6,false,$sco_track->value));
+ fwrite ($bf,full_tag('ATTEMPT',6,false,$sco_track->attempt));
+ fwrite ($bf,full_tag('TIMEMODIFIED',6,false,$sco_track->timemodified));
//End sco track
$status =fwrite ($bf,end_tag('SCO_TRACK',5,true));
}
@@ -182,6 +191,204 @@ function backup_scorm_scoes_track ($bf,$preferences,$scorm) {
}
return $status;
}
+
+
+ function backup_scorm_seq_ruleconds ($bf,$preferences,$sco) {
+
+ global $CFG;
+
+ $status = true;
+
+ $scorm_seq_ruleconditions = get_records('scorm_seq_ruleconds','scoid',$sco,'id');
+ //If there is rulecondition
+ if ($scorm_seq_ruleconditions) {
+ //Write start tag
+ $status =fwrite ($bf,start_tag('SEQ_RULECONDS',4,true));
+ //Iterate over each sco
+ foreach ($scorm_seq_ruleconditions as $seq_rulecondition) {
+ //Start sco
+ $status =fwrite ($bf,start_tag('SEQ_RULECOND',5,true));
+ //Print track contents
+ fwrite ($bf,full_tag('ID',6,false,$seq_rulecondition->id));
+ fwrite ($bf,full_tag('SCOID',6,false,$seq_rulecondition->scoid));
+ fwrite ($bf,full_tag('CONDITIONCOMBINATION',6,false,$seq_rulecondition->conditioncombination));
+ fwrite ($bf,full_tag('RULETYPE',6,false,$seq_rulecondition->ruletype));
+ fwrite ($bf,full_tag('ACTION',6,false,$seq_rulecondition->action));
+
+ $status = backup_scorm_seq_rulecond($bf,$preferences,$seq_rulecondition->id);
+ //End sco track
+ $status =fwrite ($bf,end_tag('SEQ_RULECOND',5,true));
+ }
+ //Write end tag
+ $status =fwrite ($bf,end_tag('SEQ_RULECOND',4,true));
+ }
+ return $status;
+ }
+
+
+ function backup_scorm_seq_rulecond ($bf,$preferences,$ruleconditions) {
+
+ global $CFG;
+
+ $status = true;
+
+ $scorm_seq_ruleconditions = get_records('scorm_seq_rulecond','ruleconditionsid',$ruleconditions,'id');
+ //If there is rulecondition
+ if ($scorm_seq_ruleconditions) {
+ //Write start tag
+ $status =fwrite ($bf,start_tag('SEQ_RULECOND_DATAS',4,true));
+ //Iterate over each sco
+ foreach ($scorm_seq_ruleconditions as $seq_rulecondition) {
+ //Start sco
+ $status =fwrite ($bf,start_tag('SEQ_RULECOND_DATA',5,true));
+ //Print track contents
+ fwrite ($bf,full_tag('ID',6,false,$seq_rulecondition->id));
+ fwrite ($bf,full_tag('SCOID',6,false,$seq_rulecondition->scoid));
+ fwrite ($bf,full_tag('RULECONDITIONSID',6,false,$seq_rulecondition->ruleconditionsid));
+ fwrite ($bf,full_tag('REFRENCEDOBJECTIVE',6,false,$seq_rulecondition->refrencedobjective));
+ fwrite ($bf,full_tag('MEASURETHRESHOLD',6,false,$seq_rulecondition->measurethreshold));
+ fwrite ($bf,full_tag('OPERATOR',6,false,$seq_rulecondition->operator));
+ fwrite ($bf,full_tag('COND',6,false,$seq_rulecondition->cond));
+ //End sco track
+ $status =fwrite ($bf,end_tag('SEQ_RULECOND_DATA',5,true));
+ }
+ //Write end tag
+ $status =fwrite ($bf,end_tag('SEQ_RULECOND_DATAS',4,true));
+ }
+ return $status;
+ }
+
+ function backup_scorm_seq_rolluprule ($bf,$preferences,$sco) {
+
+ global $CFG;
+
+ $status = true;
+
+ $scorm_seq_rolluprules = get_records('scorm_seq_rolluprule','scoid',$sco,'id');
+ //If there is rulecondition
+ if ($scorm_seq_rolluprules) {
+ //Write start tag
+ $status =fwrite ($bf,start_tag('SEQ_ROLLUPRULES',4,true));
+ //Iterate over each sco
+ foreach ($scorm_seq_rolluprules as $seq_rolluprule) {
+ //Start sco
+ $status =fwrite ($bf,start_tag('SEQ_ROLLUPRULE',5,true));
+ //Print track contents
+ fwrite ($bf,full_tag('ID',6,false,$seq_rolluprule->id));
+ fwrite ($bf,full_tag('SCOID',6,false,$seq_rolluprule->scoid));
+ fwrite ($bf,full_tag('CHILDACTIVITYSET',6,false,$seq_rolluprule->childactivityset));
+ fwrite ($bf,full_tag('MINIMUMCOUNT',6,false,$seq_rolluprule->minimumcount));
+ fwrite ($bf,full_tag('MINIMUMPERCENT',6,false,$seq_rolluprule->minimumpercent));
+ fwrite ($bf,full_tag('CONDITIONCOMBINATION',6,false,$seq_rolluprule->conditioncomnination));
+ fwrite ($bf,full_tag('ACTION',6,false,$seq_rolluprule->action));
+ $status = backup_scorm_seq_rolluprulecond($bf,$preferences,$seq_rolluprule->id);
+ //End sco track
+ $status =fwrite ($bf,end_tag('SEQ_ROLLUPRULE',5,true));
+ }
+ //Write end tag
+ $status =fwrite ($bf,end_tag('SEQ_ROLLUPRULES',4,true));
+ }
+ return $status;
+ }
+
+
+ function backup_scorm_seq_rolluprulecond ($bf,$preferences,$rolluprule) {
+
+ global $CFG;
+
+ $status = true;
+
+ $scorm_seq_rollupruleconditions = get_records('scorm_seq_rolluprulecond','rollupruleid',$rolluprule,'id');
+ //If there is rulecondition
+ if ($scorm_seq_rollupruleconditions) {
+ //Write start tag
+ $status =fwrite ($bf,start_tag('SEQ_ROLLUPRULECONDS',4,true));
+ //Iterate over each sco
+ foreach ($scorm_seq_rollupruleconditions as $seq_rolluprulecondition) {
+ //Start sco
+ $status =fwrite ($bf,start_tag('SEQ_ROLLUPRULECOND',5,true));
+ //Print track contents
+ fwrite ($bf,full_tag('ID',6,false,$seq_rolluprulecondition->id));
+ fwrite ($bf,full_tag('SCOID',6,false,$seq_rolluprulecondition->scoid));
+ fwrite ($bf,full_tag('ROLLUPRULEID',6,false,$seq_rolluprulecondition->rollupruleid));
+ fwrite ($bf,full_tag('COND',6,false,$seq_rolluprulecondition->condition));
+ fwrite ($bf,full_tag('OPERATOR',6,false,$seq_rolluprulecondition->operator));
+
+ //End sco track
+ $status =fwrite ($bf,end_tag('SEQ_ROLLUPRULECOND',5,true));
+ }
+ //Write end tag
+ $status =fwrite ($bf,end_tag('SEQ_ROLLUPRULECONDS',4,true));
+ }
+ return $status;
+ }
+
+
+function backup_scorm_seq_objective ($bf,$preferences,$sco) {
+
+ global $CFG;
+
+ $status = true;
+
+ $scorm_seq_objectives = get_records('scorm_seq_objective','scoid',$sco,'id');
+ //If there is rulecondition
+ if ($scorm_seq_objectives) {
+ //Write start tag
+ $status =fwrite ($bf,start_tag('SEQ_OBJECTIVES',4,true));
+ //Iterate over each sco
+ foreach ($scorm_seq_objectives as $seq_objective) {
+ //Start sco
+ $status =fwrite ($bf,start_tag('SEQ_OBJECTIVE',5,true));
+ //Print track contents
+ fwrite ($bf,full_tag('ID',6,false,$seq_objective->id));
+ fwrite ($bf,full_tag('SCOID',6,false,$seq_objective->scoid));
+ fwrite ($bf,full_tag('PRIMARYOBJ',6,false,$seq_objective->primaryobj));
+ fwrite ($bf,full_tag('OBJECTIVEID',6,false,$seq_objective->objectiveid));
+ fwrite ($bf,full_tag('MINNORMALIZEDMEASURE',6,false,$seq_objective->minnormalizedmeasure));
+ fwrite ($bf,full_tag('SATISFIEDBYMEASURE',6,false,$seq_objective->objectivemeasureweight));
+
+ $status = backup_scorm_seq_mapinfo($bf,$preferences,$seq_objective->id);
+ //End sco track
+ $status =fwrite ($bf,end_tag('SEQ_OBJECTIVE',5,true));
+ }
+ //Write end tag
+ $status =fwrite ($bf,end_tag('SEQ_OBJECTIVES',4,true));
+ }
+ return $status;
+ }
+
+ function backup_scorm_seq_mapinfo ($bf,$preferences,$objectives) {
+
+ global $CFG;
+
+ $status = true;
+
+ $scorm_seq_objectives = get_records('scorm_seq_mapinfo','objectiveid',$objectives,'id');
+ //If there is rulecondition
+ if ($scorm_seq_objectives) {
+ //Write start tag
+ $status =fwrite ($bf,start_tag('SEQ_MAPINFO',4,true));
+ //Iterate over each sco
+ foreach ($scorm_seq_objectives as $seq_objective) {
+ //Start sco
+ $status =fwrite ($bf,start_tag('SEQ_MAPINF',5,true));
+ //Print track contents
+ fwrite ($bf,full_tag('ID',6,false,$seq_objective->id));
+ fwrite ($bf,full_tag('SCOID',6,false,$seq_objective->scoid));
+ fwrite ($bf,full_tag('OBJECTIVEID',6,false,$seq_objective->objectiveid));
+ fwrite ($bf,full_tag('TARGETOBJECTIVEID',6,false,$seq_objective->targetobjectiveid));
+ fwrite ($bf,full_tag('READSATISFIEDSTATUS',6,false,$seq_objective->readsatisfiedstatus));
+ fwrite ($bf,full_tag('READNORMALIZEDMEASURE',6,false,$seq_objective->readnormalizedmeasure));
+ fwrite ($bf,full_tag('WRITESATISFIEDSTATUS',6,false,$seq_objective->writesatisfiedstatus));
+ fwrite ($bf,full_tag('WRITENORMALIZEDMEASURE',6,false,$seq_objective->writenormalizedmeasure));
+ //End sco track
+ $status =fwrite ($bf,end_tag('SEQ_MAPINF',5,true));
+ }
+ //Write end tag
+ $status =fwrite ($bf,end_tag('SEQ_MAPINFO',4,true));
+ }
+ return $status;
+ }
////Return an array of info (name,value)
function scorm_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
View
353 mod/scorm/restorelib.php
@@ -48,10 +48,19 @@ function scorm_restore_mods($mod,$restore) {
$scorm->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$scorm->reference = backup_todb($info['MOD']['#']['REFERENCE']['0']['#']);
$scorm->version = backup_todb($info['MOD']['#']['VERSION']['0']['#']);
+ $scorm->md5hash = backup_todb($info['MOD']['#']['MD5HASH']['0']['#']);
$scorm->maxgrade = backup_todb($info['MOD']['#']['MAXGRADE']['0']['#']);
if (!is_int($scorm->maxgrade)) {
$scorm->maxgrade = 0;
}
+ $scorm->updatefreq = backup_todb($info['MOD']['#']['UPDATEFREQ']['0']['#']);
+ if (!is_int($scorm->updatefreq)) {
+ $scorm->updatefreq = 0;
+ }
+ $scorm->maxattempt = backup_todb($info['MOD']['#']['MAXATTEMPT']['0']['#']);
+ if (!is_int($scorm->maxattempt)) {
+ $scorm->maxattempt = 0;
+ }
$scorm->grademethod = backup_todb($info['MOD']['#']['GRADEMETHOD']['0']['#']);
if (!is_int($scorm->grademethod)) {
$scorm->grademethod = 0;
@@ -193,6 +202,9 @@ function scorm_scoes_restore_mods($scorm_id,$info,$restore,$oldmodid) {
}
//Now check if want to restore user data and do it.
+ scorm_scoes_seq_objective_restore_mods ($newid,$info,$restore);
+ scorm_scoes_seq_rolluprule_restore_mods ($newid,$info,$restore);
+ scorm_scoes_seq_ruleconds_restore_mods ($newid,$info,$restore);
if (restore_userdata_selected($restore,'scorm',$oldmodid)) {
//Restore scorm_scoes
if ($status) {
@@ -207,6 +219,345 @@ function scorm_scoes_restore_mods($scorm_id,$info,$restore,$oldmodid) {
return $status;
}
+
+ function scorm_scoes_seq_objective_restore_mods($sco_id,$info,$restore) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Get the discussions array
+ $objectives = array();
+
+ if (!empty($info['MOD']['#']['SEQ_OBJECTIVES']['0']['#']['SEQ_OBJECTIVE'])) {
+ $objectives = $info['MOD']['#']['SEQ_OBJECTIVES']['0']['#']['SEQ_OBJECTIVE'];
+ }
+
+ //Iterate over discussions
+ for($i = 0; $i < sizeof($objectives); $i++) {
+ $obj_info = $objectives[$i];
+ //Debug
+
+ //We'll need this later!!
+ $oldid = backup_todb($obj_info['#']['ID']['0']['#']);
+ //Now, build the FORUM_DISCUSSIONS record structure
+ $objective->scoid = $sco_id;
+ $objective->primaryobj = backup_todb($obj_info['#']['PRIMARYOBJ']['0']['#']);
+ $objective->objectiveid = backup_todb($obj_info['#']['OBJECTIVEID']['0']['#']);
+ $objective->satisfiedbymeasure = backup_todb($obj_info['#']['SATISFIEDBYMEASURE']['0']['#']);
+ $objective->minnormalizedmeasure = backup_todb($obj_info['#']['MINNORMALIZEDMEASURE']['0']['#']);
+
+ //The structure is equal to the db, so insert the forum_discussions
+ $newid = insert_record ("scorm_seq_objective",$objective);
+
+ if ($newid) {
+ //We have the newid, update backup_ids
+ backup_putid($restore->backup_unique_code,"scorm_seq_objective", $oldid, $newid);
+ } else {
+ $status = false;
+ }
+
+ //Do some output
+ if (($i+1) % 50 == 0) {
+ if (!defined('RESTORE_SILENTLY')) {
+ echo ".";
+ if (($i+1) % 1000 == 0) {
+ echo "<br />";
+ }
+ }
+ backup_flush(300);
+ }
+
+ //Now restore the scorm_seq_mapinfo for each objective
+
+ $status = scorm_seq_mapinfo_restore_mods ($sco_id,$newid,$obj_info,$restore);
+
+ }
+
+ return $status;
+ }
+
+
+
+ function scorm_scoes_seq_rolluprule_restore_mods($sco_id,$info,$restore) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Get the discussions array
+ $rolluprules = array();
+
+ if (!empty($info['MOD']['#']['SEQ_ROLLUPRULES']['0']['#']['SEQ_ROLLUPRULE'])) {
+ $rolluprules = $info['MOD']['#']['SEQ_ROLLUPRULES']['0']['#']['SEQ_ROLLUPRULE'];
+ }
+
+ //Iterate over discussions
+ for($i = 0; $i < sizeof($rolluprules); $i++) {
+ $rol_info = $rolluprules[$i];
+ //Debug
+
+ //We'll need this later!!
+ $oldid = backup_todb($rol_info['#']['ID']['0']['#']);
+ //Now, build the FORUM_DISCUSSIONS record structure
+ $rolluprule->scoid = $sco_id;
+ $rolluprule->childactivityset = backup_todb($rol_info['#']['CHILDACTIVITYSET']['0']['#']);
+ $rolluprule->minimumrule = backup_todb($rol_info['#']['MINIMUMCOUNT']['0']['#']);
+ $rolluprule->minimumpercent = backup_todb($rol_info['#']['MINIMUMPERCENT']['0']['#']);
+ $rolluprule->conditioncombination = backup_todb($rol_info['#']['CONDITIONCOMBINATION']['0']['#']);
+ $rolluprule->action = backup_todb($rol_info['#']['ACTION']['0']['#']);
+
+ //The structure is equal to the db, so insert the forum_discussions
+ $newid = insert_record ("scorm_seq_rolluprule",$rolluprule);
+
+ if ($newid) {
+ //We have the newid, update backup_ids
+ backup_putid($restore->backup_unique_code,"scorm_seq_rolluprule", $oldid, $newid);
+ } else {
+ $status = false;
+ }
+
+ //Do some output
+ if (($i+1) % 50 == 0) {
+ if (!defined('RESTORE_SILENTLY')) {
+ echo ".";
+ if (($i+1) % 1000 == 0) {
+ echo "<br />";
+ }
+ }
+ backup_flush(300);
+ }
+
+ //Now restore the scorm_seq_mapinfo for each objective
+
+ $status = scorm_seq_rolluprulecond_restore_mods ($sco_id, $newid,$obj_info,$restore);
+
+ }
+
+ return $status;
+ }
+
+ function scorm_scoes_seq_ruleconds_restore_mods($sco_id,$info,$restore) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Get the discussions array
+ $ruleconds = array();
+
+ if (!empty($info['MOD']['#']['SEQ_RULECONDS']['0']['#']['SEQ_RULECOND'])) {
+ $ruleconds = $info['MOD']['#']['SEQ_RULECONDS']['0']['#']['SEQ_RULECOND'];
+ }
+
+ //Iterate over discussions
+ for($i = 0; $i < sizeof($ruleconds); $i++) {
+ $rul_info = $ruleconds[$i];
+ //Debug
+
+ //We'll need this later!!
+ $oldid = backup_todb($rul_info['#']['ID']['0']['#']);
+
+ $rulecond->scoid = $sco_id;
+ $rulecond->conditioncombination = backup_todb($rul_info['#']['CONDITIONCOMBINATION']['0']['#']);
+ $rulecond->minimumpercent = backup_todb($rul_info['#']['RULETYPE']['0']['#']);
+ $rulecond->action = backup_todb($rul_info['#']['ACTION']['0']['#']);
+
+ //The structure is equal to the db, so insert the forum_discussions
+ $newid = insert_record ("scorm_seq_ruleconds",$rulecond);
+
+ if ($newid) {
+ //We have the newid, update backup_ids
+ backup_putid($restore->backup_unique_code,"scorm_seq_ruleconds", $oldid, $newid);
+ } else {
+ $status = false;
+ }
+
+ //Do some output
+ if (($i+1) % 50 == 0) {
+ if (!defined('RESTORE_SILENTLY')) {
+ echo ".";
+ if (($i+1) % 1000 == 0) {
+ echo "<br />";
+ }
+ }
+ backup_flush(300);
+ }
+
+ //Now restore the scorm_seq_mapinfo for each objective
+
+ $status = scorm_seq_rulecond_restore_mods ($sco_id, $newid,$obj_info,$restore);
+
+ }
+
+ return $status;
+ }
+
+ function scorm_scoes_seq_rulecond_restore_mods($sco_id,$rulecondid,$info,$restore) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Get the discussions array
+ $rulecondsd = array();
+
+ if (!empty($info['MOD']['#']['SEQ_RULECOND_DATAS']['0']['#']['SEQ_RULECOND_DATA'])) {
+ $rulecondsd = $info['MOD']['#']['SEQ_RULECOND_DATAS']['0']['#']['SEQ_RULECOND_DATA'];
+ }
+
+
+ for($i = 0; $i < sizeof($rulecondsd); $i++) {
+ $ruld_info = $rulecondsd[$i];
+ //Debug
+
+ //We'll need this later!!
+ $oldid = backup_todb($rul_info['#']['ID']['0']['#']);
+
+ $rulecondd->scoid = $sco_id;
+ $rulecondd->ruleconditions = $rulecondid;
+ $rulecondd->refrencedobjective = backup_todb($ruld_info['#']['REFRENCEDOBJECTIVE']['0']['#']);
+ $rulecondd->measurethreshold = backup_todb($ruld_info['#']['MEASURETHRESHOLD']['0']['#']);
+ $rulecondd->operator = backup_todb($ruld_info['#']['OPERATOR']['0']['#']);
+ $rulecondd->cond = backup_todb($ruld_info['#']['COND']['0']['#']);
+
+ //The structure is equal to the db, so insert the forum_discussions
+ $newid = insert_record ("scorm_seq_rulecond",$rulecondd);
+
+ if ($newid) {
+ //We have the newid, update backup_ids
+ backup_putid($restore->backup_unique_code,"scorm_seq_rulecond", $oldid, $newid);
+ } else {
+ $status = false;
+ }
+
+ //Do some output
+ if (($i+1) % 50 == 0) {
+ if (!defined('RESTORE_SILENTLY')) {
+ echo ".";
+ if (($i+1) % 1000 == 0) {
+ echo "<br />";
+ }
+ }
+ backup_flush(300);
+ }
+
+ //Now restore the scorm_seq_mapinfo for each objective
+
+ }
+
+ return $status;
+ }
+
+ function scorm_scoes_seq_rolluprulecond_restore_mods($sco_id,$rolluprule,$info,$restore) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Get the discussions array
+ $rollupruleconds = array();
+
+ if (!empty($info['MOD']['#']['SEQ_ROLLUPRULECONDS']['0']['#']['SEQ_ROLLUPRULECOND'])) {
+ $rollupruleconds = $info['MOD']['#']['SEQ_ROLLUPRULECONDS']['0']['#']['SEQ_ROLLUPRULECOND'];
+ }
+
+
+ for($i = 0; $i < sizeof($rollupruleconds); $i++) {
+ $rulc_info = $rollupruleconds[$i];
+ //Debug
+
+ //We'll need this later!!
+ $oldid = backup_todb($rulc_info['#']['ID']['0']['#']);
+
+ $rolluprulecond->scoid = $sco_id;
+ $rolluprulecond->ruleconditions = $rolluprule;
+ $rolluprulecond->cond = backup_todb($rulc_info['#']['COND']['0']['#']);
+ $rolluprulecond->operator = backup_todb($rulc_info['#']['OPERATOR']['0']['#']);
+
+
+ //The structure is equal to the db, so insert the forum_discussions
+ $newid = insert_record ("scorm_seq_rolluprulecond",$rolluprulecond);
+
+ if ($newid) {
+ //We have the newid, update backup_ids
+ backup_putid($restore->backup_unique_code,"scorm_seq_rolluprulecond", $oldid, $newid);
+ } else {
+ $status = false;
+ }
+
+ //Do some output
+ if (($i+1) % 50 == 0) {
+ if (!defined('RESTORE_SILENTLY')) {
+ echo ".";
+ if (($i+1) % 1000 == 0) {
+ echo "<br />";
+ }
+ }
+ backup_flush(300);
+ }
+
+ //Now restore the scorm_seq_mapinfo for each objective
+
+ }
+
+ return $status;
+ }
+
+ function scorm_scoes_seq_mapinfo_restore_mods($sco_id,$objectiveid,$info,$restore) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Get the discussions array
+ $mapinfos = array();
+
+ if (!empty($info['MOD']['#']['SEQ_MAPINFO']['0']['#']['SEQ_MAPINF'])) {
+ $mapinfos = $info['MOD']['#']['SEQ_MAPINFO']['0']['#']['SEQ_MAPINF'];
+ }
+
+
+ for($i = 0; $i < sizeof($mapinfos); $i++) {
+ $map_info = $mapinfos[$i];
+ //Debug
+
+ //We'll need this later!!
+ $oldid = backup_todb($map_info['#']['ID']['0']['#']);
+
+ $mapinfo->scoid = $sco_id;
+ $mapinfo->objectiveid = $ojectiveid;
+ $mapinfo->targetobjectiveid = backup_todb($map_info['#']['TARGETOBJECTIVEID']['0']['#']);
+ $mapinfo->readsatisfiedstatus = backup_todb($map_info['#']['READSATISFIEDSTATUS']['0']['#']);
+ $mapinfo->readnormalizedmeasure = backup_todb($map_info['#']['READNORMALIZEDMEASURE']['0']['#']);
+ $mapinfo->writesatisfiedstatus = backup_todb($map_info['#']['WRITESATISFIEDSTATUS']['0']['#']);
+ $mapinfo->writenormalizedmeasure = backup_todb($map_info['#']['WRITENORMALIZEDMEASURE']['0']['#']);
+
+
+ //The structure is equal to the db, so insert the forum_discussions
+ $newid = insert_record ("scorm_seq_mapinfo",$mapinfo);
+
+ if ($newid) {
+ //We have the newid, update backup_ids
+ backup_putid($restore->backup_unique_code,"scorm_seq_mapinfo", $oldid, $newid);
+ } else {
+ $status = false;
+ }
+
+ //Do some output
+ if (($i+1) % 50 == 0) {
+ if (!defined('RESTORE_SILENTLY')) {
+ echo ".";
+ if (($i+1) % 1000 == 0) {
+ echo "<br />";
+ }
+ }
+ }
+ }
+
+ return $status;
+ }
+
//This function restores the scorm_scoes_track
function scorm_scoes_tracks_restore_mods($scorm_id,$info,$restore) {
@@ -229,6 +580,7 @@ function scorm_scoes_tracks_restore_mods($scorm_id,$info,$restore) {
$scotrack->userid = backup_todb($sub_info['#']['USERID']['0']['#']);
$scotrack->scoid = backup_todb($sub_info['#']['SCOID']['0']['#']);
$scotrack->element = backup_todb($sub_info['#']['ELEMENT']['0']['#']);
+ $scotrack->attempt = backup_todb($sub_info['#']['ATTEMPT']['0']['#']);
$scotrack->value = backup_todb($sub_info['#']['VALUE']['0']['#']);
//We have to recode the userid field
@@ -243,6 +595,7 @@ function scorm_scoes_tracks_restore_mods($scorm_id,$info,$restore) {
$scotrack->scoid = $sco->new_id;
}
+ $scotrack->timemodified = time();
//The structure is equal to the db, so insert the scorm_scoes_track
$newid = insert_record ("scorm_scoes_track",$scotrack);

0 comments on commit 730d42b

Please sign in to comment.