Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-29733 grade: SQL and comment cleanup

  • Loading branch information...
commit 415b15ccd69183402ff4afab8dfc6444137fdf0d 1 parent 8a592bd
@andyjdavis andyjdavis authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/grade/grade_item.php
View
15 lib/grade/grade_item.php
@@ -1730,6 +1730,7 @@ public function compute($userid=null) {
return true; // no need to recalculate locked items
}
+ // Precreate grades - we need them to exist
if ($userid) {
$missing = array();
if (!$DB->record_exists('grade_grades', array('itemid'=>$this->id, 'userid'=>$userid))) {
@@ -1738,14 +1739,14 @@ public function compute($userid=null) {
$missing[] = $m;
}
} else {
- // precreate grades - we need them to exist
- $params = array($this->courseid, $this->id);
- $sql = "SELECT go.userid
- FROM {grade_grades} go
+ // Find any users who have grades for some but not all grade items in this course
+ $params = array('gicourseid' => $this->courseid, 'ggitemid' => $this->id);
+ $sql = "SELECT gg.userid
+ FROM {grade_grades} gg
JOIN {grade_items} gi
- ON (gi.id = go.itemid AND gi.courseid = ?)
- GROUP BY go.userid
- HAVING SUM(go.itemid = ?) = 0";
+ ON (gi.id = gg.itemid AND gi.courseid = :gicourseid)
+ GROUP BY gg.userid
+ HAVING SUM(CASE WHEN gg.itemid = :ggitemid THEN 1 ELSE 0 END) = 0";
$missing = $DB->get_records_sql($sql, $params);
}
Please sign in to comment.
Something went wrong with that request. Please try again.