SCORM MDL-21568 fix regression
authorDan Marsden <Dan@digitalclay.co.nz>
Sat, 17 Jul 2010 06:45:57 +0000 (06:45 +0000)
committerDan Marsden <Dan@digitalclay.co.nz>
Sat, 17 Jul 2010 06:45:57 +0000 (06:45 +0000)
mod/scorm/db/upgrade.php

index 9c1f712..413dff2 100644 (file)
@@ -40,9 +40,11 @@ function xmldb_scorm_upgrade($oldversion) {
             if (empty($whatgradefixed)) {
                 /// fix bad usage of whatgrade/grading method.
                 $scorms = $DB->get_records('scorm');
-                foreach ($scorms as $scorm) {
-                    $scorm->whatgrade = $scorm->grademethod/10;
-                    $DB->update_record('scorm', $scorm);
+                if (!empty($scorm)) {
+                    foreach ($scorms as $scorm) {
+                        $scorm->whatgrade = $scorm->grademethod/10;
+                        $DB->update_record('scorm', $scorm);
+                    }
                 }
             }
         } else {
@@ -473,9 +475,11 @@ function xmldb_scorm_upgrade($oldversion) {
         if (empty($grademethodfixed)) {
             /// fix bad usage of whatgrade/grading method.
             $scorms = $DB->get_records('scorm');
-            foreach ($scorms as $scorm) {
-                $scorm->grademethod = $scorm->grademethod%10;
-                $DB->update_record('scorm', $scorm);
+            if (!empty($scorm)) {
+                foreach ($scorms as $scorm) {
+                    $scorm->grademethod = $scorm->grademethod%10;
+                    $DB->update_record('scorm', $scorm);
+                }
             }
         } else {
             //dump this config var as it isn't needed anymore.