From: stronk7 Date: Mon, 16 Feb 2004 20:42:16 +0000 (+0000) Subject: Now label, quiz, resource and survey logs X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4130af7552ac081affae702a0ec63e0f0d72595f;p=moodle.git Now label, quiz, resource and survey logs are restored properly (I think) :-) --- diff --git a/backup/version.php b/backup/version.php index 10d5764a60..25f04c2d29 100644 --- a/backup/version.php +++ b/backup/version.php @@ -5,6 +5,6 @@ // database (backup_version) to determine whether upgrades should // be performed (see db/backup_*.php) -$backup_version = 2004021500; // The current version is a date (YYYYMMDDXX) +$backup_version = 2004021501; // The current version is a date (YYYYMMDDXX) $backup_release = "1.2 development"; // User-friendly version number diff --git a/mod/label/restorelib.php b/mod/label/restorelib.php index 32a35ecff9..45e4b6b8fb 100644 --- a/mod/label/restorelib.php +++ b/mod/label/restorelib.php @@ -64,5 +64,45 @@ return $status; } - + + //This function returns a log record with all the necessay transformations + //done. It's used by restore_log_module() to restore modules log. + function label_restore_logs($restore,$log) { + + $status = false; + + //Depending of the action, we recode different things + switch ($log->action) { + case "add": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "update": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + default: + echo "action (".$log->module."-".$log->action.") unknow. Not restored
"; //Debug + break; + } + + if ($status) { + $status = $log; + } + return $status; + } ?> diff --git a/mod/quiz/restorelib.php b/mod/quiz/restorelib.php index 839b621fb2..c9edc53c8d 100644 --- a/mod/quiz/restorelib.php +++ b/mod/quiz/restorelib.php @@ -1543,4 +1543,109 @@ return $status; } + //This function returns a log record with all the necessay transformations + //done. It's used by restore_log_module() to restore modules log. + function quiz_restore_logs($restore,$log) { + + $status = false; + + //Depending of the action, we recode different things + switch ($log->action) { + case "add": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "update": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view all": + $log->url = "index.php?id=".$log->course; + $status = true; + break; + case "report": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "report.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "attempt": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "attempt.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "submit": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "attempt.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "review": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + //Extract the attempt id from the url field + $attid = substr(strrchr($log->url,"="),1); + //Get the new_id of the attempt (to recode the url field) + $att = backup_getid($restore->backup_unique_code,"quiz_attempts",$attid); + if ($mod) { + $log->url = "review.php?id=".$log->cmid."&attempt=".$att->new_id; + $log->info = $mod->new_id; + $status = true; + } + } + } + break; + default: + echo "action (".$log->module."-".$log->action.") unknow. Not restored
"; //Debug + break; + } + + if ($status) { + $status = $log; + } + return $status; + } ?> diff --git a/mod/resource/restorelib.php b/mod/resource/restorelib.php index d47ffe30c8..f57296e1dd 100644 --- a/mod/resource/restorelib.php +++ b/mod/resource/restorelib.php @@ -67,5 +67,60 @@ return $status; } - + + //This function returns a log record with all the necessay transformations + //done. It's used by restore_log_module() to restore modules log. + function resource_restore_logs($restore,$log) { + + $status = false; + + //Depending of the action, we recode different things + switch ($log->action) { + case "add": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "update": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view all": + $log->url = "index.php?id=".$log->course; + $status = true; + break; + default: + echo "action (".$log->module."-".$log->action.") unknow. Not restored
"; //Debug + break; + } + + if ($status) { + $status = $log; + } + return $status; + } ?> diff --git a/mod/survey/restorelib.php b/mod/survey/restorelib.php index 9b0c826713..d8eeda7c0f 100644 --- a/mod/survey/restorelib.php +++ b/mod/survey/restorelib.php @@ -197,4 +197,93 @@ return $status; } + + //This function returns a log record with all the necessay transformations + //done. It's used by restore_log_module() to restore modules log. + function survey_restore_logs($restore,$log) { + + $status = false; + + //Depending of the action, we recode different things + switch ($log->action) { + case "add": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "submit": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "update": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view form": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view graph": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "view.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view report": + if ($log->cmid) { + //Get the new_id of the module (to recode the info field) + $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info); + if ($mod) { + $log->url = "report.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "view all": + $log->url = "index.php?id=".$log->course; + $status = true; + break; + default: + echo "action (".$log->module."-".$log->action.") unknow. Not restored
"; //Debug + break; + } + + if ($status) { + $status = $log; + } + return $status; + } ?>