Skip to content

Commit

Permalink
Merge branch 'w04_MDL-31183_m22_gloscounts' of git://github.com/skoda…
Browse files Browse the repository at this point in the history
…k/moodle into MOODLE_22_STABLE
  • Loading branch information
stronk7 committed Jan 24, 2012
2 parents 5d2dce0 + 3397a09 commit ba09a26
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mod/glossary/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2231,24 +2231,24 @@ function glossary_count_unrated_entries($glossaryid, $userid) {
// Now we need to count the ratings that this user has made // Now we need to count the ratings that this user has made
$sql = "SELECT COUNT('x') AS num $sql = "SELECT COUNT('x') AS num
FROM {glossary_entries} e FROM {glossary_entries} e
JOIN {ratings} r ON r.itemid = e.id JOIN {rating} r ON r.itemid = e.id
WHERE e.glossaryid = :glossaryid AND WHERE e.glossaryid = :glossaryid AND
r.userid = :userid AND r.userid = :userid AND
r.component = 'mod_glossary' AND r.component = 'mod_glossary' AND
r.ratingarea = 'entry' AND r.ratingarea = 'entry' AND
r.contextid = :contextid"; r.contextid = :contextid";
$params = array('glossaryid' => $glossaryid, 'userid' => $userid, 'contextid' => $context->id); $params = array('glossaryid' => $glossaryid, 'userid' => $userid, 'contextid' => $contextid);
$rated = $DB->count_records_sql($sql, $params); $rated = $DB->count_records_sql($sql, $params);
if ($rated) { if ($rated) {
// The number or enties minus the number or rated entries equals the number of unrated // The number or enties minus the number or rated entries equals the number of unrated
// entries // entries
if ($entries->num > $rated->num) { if ($entries > $rated) {
return $entries->num - $rated->num; return $entries - $rated;
} else { } else {
return 0; // Just in case there was a counting error return 0; // Just in case there was a counting error
} }
} else { } else {
return $entries->num; return (int)$entries;
} }
} else { } else {
return 0; return 0;
Expand Down

0 comments on commit ba09a26

Please sign in to comment.