]> git.mjollnir.org Git - moodle.git/commitdiff
Added some more error messages when restoring
authormoodler <moodler>
Fri, 22 Aug 2003 13:20:06 +0000 (13:20 +0000)
committermoodler <moodler>
Fri, 22 Aug 2003 13:20:06 +0000 (13:20 +0000)
backup/restore_execute.html

index b38ac872214248add63a4654d20a1a399add9520..a47141de73897d341b1efbef232d7216ea930781 100644 (file)
@@ -60,7 +60,9 @@
     //Saving conversion id variables into backup_tables
     if ($restore->restoreto == 2) {
         echo "<li>".get_string("creatingnewcourse");
-        $status = restore_create_new_course($restore,$course_header);
+        if (!$status = restore_create_new_course($restore,$course_header)) {
+            notify("Error while creating the new empty course.");
+        }
         //Print course fullname and shortname and category
         if ($status) {
             echo "<ul>";
@@ -97,6 +99,7 @@
                 }
             }
         } else {
+            notify("Error opening existing course.");
             $status = false;
         }
     }
         //Into new course
         if ($restore->restoreto == 2) {
             echo "<li>".get_string("creatingsections");
-            $status = restore_create_sections($restore,$xml_file);
+            if (!$status = restore_create_sections($restore,$xml_file)) {
+                notify("Error creating sections in the existing course.");
+            }
         //Into existing course
         } else if ($restore->restoreto == 0 or $restore->restoreto == 1) {
             echo "<li>".get_string("checkingsections");
-            $status = restore_create_sections($restore,$xml_file);
+            if (!$status = restore_create_sections($restore,$xml_file)) {
+                notify("Error creating sections in the existing course.");
+            }
         //Error
         } else {
+            notify("Neither a new course or an existing one was specified.");
             $status = false;
         }
     }
     //Now create users as needed 
     if ($status and ($restore->users == 0 or $restore->users == 1)) {
         echo "<li>".get_string("creatingusers")."<br>";
-        $status = restore_create_users($restore,$xml_file);
+        if (!$status = restore_create_users($restore,$xml_file)) {
+            notify("Could not restore users.");
+        }
         //Now print info about the work done
         if ($status) {
             $recs = get_records_sql("select old_id, new_id from {$CFG->prefix}backup_ids
                 echo "<li>".get_string("other").": ".$other_count;
                 echo "</ul>";
             } else {
-                //Something is wrong. There is no users !!
+                notify("Something is wrong - no users were found!");
                 $status = false;
             }
         }
     //Now create categories and questions as needed (STEP1)
     if ($status and ($restore->mods[quiz]->restore)) {
          echo "<li>".get_string("creatingcategoriesandquestions")."<br>";
-         $status = restore_create_questions($restore,$xml_file);
+         if (!$status = restore_create_questions($restore,$xml_file)) {
+             notify("Could not restore categories and questions!");
+         }
     }
 
     //Now create user_files as needed
     if ($status and ($restore->user_files)) {
         echo "<li>".get_string("copyinguserfiles")."<br>";
-        $status = restore_user_files($restore);
+        if (!$status = restore_user_files($restore)) {
+            notify("Could not restore user files!");
+        }
         //If all is ok (and we have a counter)
         if ($status and ($status !== true)) {
             //Inform about user dirs created from backup
     //Now create course files as needed
     if ($status and ($restore->course_files)) {
         echo "<li>".get_string("copyingcoursefiles")."<br>";
-        $status = restore_course_files($restore);
+        if (!$status = restore_course_files($restore)) {
+            notify("Could not restore course files!");
+        }
         //If all is ok (and we have a counter)
         if ($status and ($status !== true)) {
             //Inform about user dirs created from backup
     //Now create scales as needed
     if ($status) {
         echo "<li>".get_string("creatingscales");
-        $status = restore_create_scales($restore,$xml_file);
+        if (!$status = restore_create_scales($restore,$xml_file)) {
+            notify("Could not restore custom scales!");
+        }
     }
 
     //Now create course modules as needed
     if ($status) {
         echo "<li>".get_string("creatingcoursemodules");
-        $status = restore_create_modules($restore,$xml_file);
+        if (!$status = restore_create_modules($restore,$xml_file)) {
+            notify("Could not restore custom scales!");
+        }
     }
 
     //Now create log entries as needed
     //Now, if all is OK, adjust the instance field in course_modules !!
     if ($status) {
         echo "<li>".get_string("checkinginstances");
-        $status = restore_check_instances($restore);
+        if (!$status = restore_check_instances($restore)) {
+            notify("Could not adjust instances in course_modules!");
+        }
     }
 
     //Now if all is OK, update:
     //Cleanup temps (files and db)
     if ($status) {
         echo "<li>".get_string("cleaningtempdata");
-        $status = clean_temp_data ($restore);
+        if (!$status = clean_temp_data ($restore)) {
+            notify("Could not clean up temporary data from files and database");
+        }
     }
 
     //End the main ul
     echo "</table>";
 
     if (!$status) {
-        error ("An error has ocurred");
+        error ("An error has occurred and the restore could not be completed!");
     }
 
     //Print final message