Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

File containing the grade_report class

Copyright: 2007 Moodle Pty Ltd (http://moodle.com)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 581 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: grade_report  - X-Ref

An abstract class containing variables and methods used by all or most reports.

__construct($courseid, $gpr, $context, $page=null)   X-Ref
Constructor. Sets local copies of user preferences and initialises grade_tree.

param: int $courseid
param: object $gpr grade plugin return tracking object
param: string $context
param: int $page The current page being viewed (when report is paged)

get_pref($pref, $objectid=null)   X-Ref
Given the name of a user preference (without grade_report_ prefix), locally saves then returns
the value of that preference. If the preference has already been fetched before,
the saved value is returned. If the preference is not set at the User level, the $CFG equivalent
is given (site default).
Can be called statically, but then doesn't benefit from caching

param: string $pref The name of the preference (do not include the grade_report_ prefix)
param: int $objectid An optional itemid or categoryid to check for a more fine-grained preference
return: mixed The value of the preference

set_pref($pref, $pref_value='default', $itemid=null)   X-Ref
Uses set_user_preferences() to update the value of a user preference. If 'default' is given as the value,
the preference will be removed in favour of a higher-level preference.

param: string $pref The name of the preference.
param: mixed $pref_value The value of the preference.
param: int $itemid An optional itemid to which the preference will be assigned
return: bool Success or failure.

get_lang_string($strcode, $section=null)   X-Ref
First checks the cached language strings, then returns match if found, or uses get_string()
to get it from the DB, caches it then returns it.

param: string $strcode
param: string $section Optional language section
return: string

get_numusers($groups = true, $users = false)   X-Ref
Fetches and returns a count of all the users that will be shown on this page.

param: boolean $groups include groups limit
param: boolean $users include users limit - default false, used for searching purposes
return: int Count of users

supports_mygrades()   X-Ref
Shows support for being used as a 'Grades' report.


setup_groups()   X-Ref
Sets up this object's group variables, mainly to restrict the selection of users to display.


setup_users()   X-Ref
Sets up this report's user criteria to restrict the selection of users to display.


get_sort_arrow($direction='move', $sortlink=null)   X-Ref
Returns an arrow icon inside an <a> tag, for the purpose of sorting a column.

param: string $direction
param: moodle_url $sortlink

blank_hidden_total_and_adjust_bounds($courseid, $course_item, $finalgrade)   X-Ref
Optionally blank out course/category totals if they contain any hidden items

param: string $courseid the course id
param: string $course_item an instance of grade_item
param: string $finalgrade the grade for the course_item
return: array[] containing values for 'grade', 'grademax', 'grademin', 'aggregationstatus' and 'aggregationweight'

blank_hidden_total($courseid, $course_item, $finalgrade)   X-Ref
Optionally blank out course/category totals if they contain any hidden items

param: string $courseid the course id
param: string $course_item an instance of grade_item
param: string $finalgrade the grade for the course_item
return: string The new final grade