]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-21160 database activity - remap scale on restore ; merged from 19_STABLE
authorEloy Lafuente <stronk7@moodle.org>
Fri, 18 Dec 2009 17:40:16 +0000 (17:40 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Fri, 18 Dec 2009 17:40:16 +0000 (17:40 +0000)
mod/data/restorelib.php

index 9b76d31e23a33f9529c71eea2edc3f5dbdfa7daf..096c5fbc9e26bf18be8d9fb50092bfd14e8d9933 100644 (file)
@@ -99,6 +99,14 @@ function data_restore_mods($mod,$restore) {
             unset($database->notification);    /// Unset it if null to get proper Moodle 2.0 default (0) applied
         }
 
+        // We have to recode the scale field if it's <0 (positive is a grade, not a scale)
+        if ($database->scale < 0) {
+            $scale = backup_getid($restore->backup_unique_code, 'scale', abs($database->scale));
+            if ($scale) {
+                $database->scale = -($scale->new_id);
+            }
+        }
+
         $newid = $DB->insert_record ('data', $database);
 
         //Do some output
@@ -727,5 +735,3 @@ function data_decode_content_links_caller($restore) {
 
     return $status;
 }
-
-