Permalink
Browse files

Fixed some bugs in restore procedure, added backup and restore for fi…

…eld popup
  • Loading branch information...
1 parent 96ca8c6 commit f91f72167eef5b37577e6847c2ec0689d70b1586 bobopinna committed Jun 29, 2005
Showing with 27 additions and 6 deletions.
  1. +1 −0 mod/scorm/backuplib.php
  2. +26 −6 mod/scorm/restorelib.php
View
1 mod/scorm/backuplib.php
@@ -50,6 +50,7 @@ function scorm_backup_mods($bf,$preferences) {
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("BROWSEMODE",4,false,$scorm->browsemode));
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
+ fwrite ($bf,full_tag("POPUP",4,false,$scorm->popup));
fwrite ($bf,full_tag("WIDTH",4,false,$scorm->width));
fwrite ($bf,full_tag("HEIGHT",4,false,$scorm->height));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
View
32 mod/scorm/restorelib.php
@@ -56,9 +56,24 @@ function scorm_restore_mods($mod,$restore) {
if (!is_int($scorm->grademethod)) {
$scorm->grademethod = 0;
}
- $scorm->launch = backup_todb($info['MOD']['#']['LAUNCH']['0']['#']);
+ if ($restore->backup_version < 2005041500) {
+ $scorm->datadir = substr(backup_todb($info['MOD']['#']['DATADIR']['0']['#']),1);
+ } else {
+ $scorm->datadir = backup_todb($info['MOD']['#']['ID']['0']['#']);
+ }
+ $oldlaunch = backup_todb($info['MOD']['#']['LAUNCH']['0']['#']);
$scorm->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
$scorm->auto = backup_todb($info['MOD']['#']['AUTO']['0']['#']);
+ if ($restore->backup_version < 2005040200) {
+ $oldpopup = backup_todb($info['MOD']['#']['POPUP']['0']['#']);
+ if (!empty($oldpopup)) {
+ $scorm->popup = 1;
+ } else {
+ $scorm->popup = 0;
+ }
+ } else {
+ $scorm->popup = backup_todb($info['MOD']['#']['POPUP']['0']['#']);
+ }
$scorm->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']);
if ($scorm->width == 0) {
$scorm->width = 800;
@@ -79,13 +94,19 @@ function scorm_restore_mods($mod,$restore) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
-
+ $scorm->id = $newid;
//Now copy moddata associated files
$status = scorm_restore_files ($scorm, $restore);
- if ($status)
+ if ($status) {
$status = scorm_scoes_restore_mods ($newid,$info,$restore);
-
+ if ($status) {
+ $launchsco = backup_getid($restore->backup_unique_code,"scorm_scoes",$oldlaunch);
+ $scorm->launch = $launchsco->new_id;
+ update_record('scorm',$scorm);
+ }
+ }
+
} else {
$status = false;
}
@@ -325,7 +346,7 @@ function scorm_restore_files ($package, $restore) {
//Now locate the temp dir we are restoring from
if ($status) {
$temp_path = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code.
- "/moddata/scorm/".$package->id;
+ "/moddata/scorm/".$package->datadir;
//Check it exists
if (is_dir($temp_path)) {
$todo = true;
@@ -336,7 +357,6 @@ function scorm_restore_files ($package, $restore) {
if ($status and $todo) {
//Make scorm package directory path
$this_scorm_path = $scorm_path."/".$package->id;
-
$status = backup_copy_file($temp_path, $this_scorm_path);
}

0 comments on commit f91f721

Please sign in to comment.