]> git.mjollnir.org Git - moodle.git/commitdiff
Now logs from:
authorstronk7 <stronk7>
Sun, 15 Feb 2004 21:18:52 +0000 (21:18 +0000)
committerstronk7 <stronk7>
Sun, 15 Feb 2004 21:18:52 +0000 (21:18 +0000)
- Assignments
- Choices
- Workshops
are restored too.

backup/restorelib.php
backup/version.php
mod/assignment/restorelib.php
mod/choice/restorelib.php
mod/workshop/restorelib.php

index 5b7ffcfed420fa4c19589215159eb7e895babdcc..8b7b2789f184dc53453f36b25ed647abe9a33618 100644 (file)
             }
             break;
         default:
-            //echo "action (".$log->action.") unknow. Not restored<br>";                 //Debug
+            echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>";                 //Debug
             break;
         }
 
index d60a3739e1e16f22b6ebe62a50b8681eb9d7698a..10d5764a60fd06c35f238f55b746159a7a10c428 100644 (file)
@@ -5,6 +5,6 @@
 // database (backup_version) to determine whether upgrades should
 // be performed (see db/backup_*.php)
 
-$backup_version = 2004021400;   // The current version is a date (YYYYMMDDXX)
+$backup_version = 2004021500;   // The current version is a date (YYYYMMDDXX)
 
 $backup_release = "1.2 development";  // User-friendly version number
index 4ba64b5436d5f3acda956427192b0ca91c85c2a7..f93cc6cff07f75b148843868f36e81fe3eda1c67 100644 (file)
        
         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 assignment_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 "upload":
+            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?a=".$mod->new_id;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "view submission":
+            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 = "submissions.php?id=".$mod->new_id;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "update grades":
+            if ($log->cmid) {
+                //Extract the assignment id from the url field                             
+                $assid = substr(strrchr($log->url,"="),1);
+                //Get the new_id of the module (to recode the info field)
+                $mod = backup_getid($restore->backup_unique_code,$log->module,$assid);
+                if ($mod) {
+                    $log->url = "submissions.php?id=".$mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        default:
+            echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>";                 //Debug
+            break;
+        }
+
+        if ($status) {
+            $status = $log;
+        }
+        return $status;
+    }
 ?>
index 4be35a645e87e975eed41cd2e519441c1ca51aba..ddca3f52d2fe477d6fb76b09a366450516a2c3d3 100644 (file)
 
         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 choice_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<br>";                 //Debug
+            break;
+        }
 
+        if ($status) {
+            $status = $log;
+        }
+        return $status;
+    }
 ?>
index 642c3edb1019819dee57b6ad0ad3a83a4fa15daa..f94cf7634cd59b9a7ea62af2ab969f940203403e 100644 (file)
        
         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 workshop_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 "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 "resubmit":
+            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 "league table":
+            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 "submissions":
+            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 "allow both":
+            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 "set up":
+            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 "assessments onl":
+            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 "close":
+            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 "display grades":
+            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 "over allocation":
+            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 "assess":
+            if ($log->cmid) {
+                //Get the new_id of the workshop assessments
+                $ass = backup_getid($restore->backup_unique_code,"workshop_assessments",$log->info);
+                if ($ass) {
+                    $log->url = "assessments.php?action=viewassessment&id=".$log->cmid."&aid=".$ass->new_id;
+                    $log->info = $ass->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "grade":
+            if ($log->cmid) {
+                //Get the new_id of the workshop assessments
+                $ass = backup_getid($restore->backup_unique_code,"workshop_assessments",$log->info);
+                if ($ass) {
+                    $log->url = "assessments.php?action=viewassessment&id=".$log->cmid."&aid=".$ass->new_id;
+                    $log->info = $ass->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        default:
+            echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>";                 //Debug
+            break;
+        }
+
+        if ($status) {
+            $status = $log;
+        }
+        return $status;
+    }
 ?>