]> git.mjollnir.org Git - moodle.git/commitdiff
Now more quiz actions are restored properly:
authorstronk7 <stronk7>
Wed, 3 May 2006 23:48:28 +0000 (23:48 +0000)
committerstronk7 <stronk7>
Wed, 3 May 2006 23:48:28 +0000 (23:48 +0000)
 -preview
 -start attempt
 -close attempt
 -continue attempt (too long. See Bug 5419)
Bug 5122
(http://moodle.org/bugs/bug.php?op=show&bugid=5122)

mod/quiz/restorelib.php

index 9a895808cd2f6d6948abc27a106a0628b2896c64..3f225a9c091be1e17a8db53e687111c5da52c87f 100644 (file)
                 }
             }
             break;
+        case "preview":
+            if ($log->cmid) {
+                //Get the new_id of the module (to recode the url 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 "start 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) {
+                    //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 ($att) {
+                        $log->url = "review.php?id=".$log->cmid."&attempt=".$att->new_id;
+                        $log->info = $mod->new_id;
+                        $status = true;
+                    }
+                }
+            }
+            break;
+        case "close 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) {
+                    //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 ($att) {
+                        $log->url = "review.php?id=".$log->cmid."&attempt=".$att->new_id;
+                        $log->info = $mod->new_id;
+                        $status = true;
+                    }
+                }
+            }
+            break;
+        case "continue 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) {
+                    //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 ($att) {
+                        $log->url = "review.php?id=".$log->cmid."&attempt=".$att->new_id;
+                        $log->info = $mod->new_id;
+                        $status = true;
+                    }
+                }
+            }
+            break;
+        case "continue attemp":
+            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 ($att) {
+                        $log->url = "review.php?id=".$log->cmid."&attempt=".$att->new_id;
+                        $log->info = $mod->new_id;
+                        $log->action = "continue attempt";  //To recover some bad actions
+                        $status = true;
+                    }
+                }
+            }
+            break;
         default:
             if (!defined('RESTORE_SILENTLY')) {
                 echo "action (".$log->module."-".$log->action.") unknown. Not restored<br />";                 //Debug