MDL-22139 backup - minor fix to query (grade_item->id is in backup_ids_temp->itemid)
authorEloy Lafuente <stronk7@moodle.org>
Tue, 13 Jul 2010 09:29:25 +0000 (09:29 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Tue, 13 Jul 2010 09:29:25 +0000 (09:29 +0000)
backup/util/dbops/backup_plan_dbops.class.php

index cc9e674..5c2e251 100644 (file)
@@ -180,17 +180,21 @@ abstract class backup_plan_dbops extends backup_dbops {
     public static function require_gradebook_backup($courseid, $backupid) {
         global $DB;
 
-        $backupgradebook = true;
-
         $sql = "SELECT count(id)
-FROM {grade_items}
-WHERE courseid=:courseid AND itemtype = 'mod'
-AND id NOT IN (SELECT bi.id FROM {backup_ids_temp} bi WHERE bi.itemname = 'grade_item_final' AND bi.backupid = :backupid)";
+                  FROM {grade_items}
+                 WHERE courseid=:courseid
+                   AND itemtype = 'mod'
+                   AND id NOT IN (
+                       SELECT bi.itemid
+                         FROM {backup_ids_temp} bi
+                        WHERE bi.itemname = 'grade_itemfinal'
+                          AND bi.backupid = :backupid)";
         $params = array('courseid'=>$courseid, 'backupid'=>$backupid);
 
+
         $count = $DB->count_records_sql($sql, $params);
 
         //if there are 0 activity grade items not already included in the backup
-        return $count==0;
+        return $count == 0;
     }
 }