foreach ($this->items as $item) {
// If the user shouldn't see this grade_item, hide the average as well
// MDL-11576 If any of the grades are hidden and the user doesn't have permission to view them, hide average as well
- if (($item->is_hidden() || $item->has_hidden_grades()) && !$canviewhidden) {
+ if (($item->is_hidden() || $item->has_hidden_grades($groupsql, $groupwheresql)) && !$canviewhidden) {
$avghtml .= '<td class="cell c' . $columncount++.'"> - </td>';
continue;
}
* Returns the number of grades that are hidden.
* @param return int Number of hidden grades
*/
- function has_hidden_grades() {
- return count_records('grade_grades', 'itemid', $this->id, 'hidden', 1);
+ function has_hidden_grades($groupsql = null, $groupwheresql = null) {
+ global $CFG;
+ return get_field_sql("SELECT COUNT(*) FROM {$CFG->prefix}grade_grades g LEFT JOIN "
+ ."{$CFG->prefix}user u ON g.userid = u.id$groupsql WHERE itemid = $this->id AND hidden = 1 $groupwheresql");
}
/**