Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

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: 11 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

return: mixed The value of the preference
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

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.

return: bool Success or failure.
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

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.

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

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

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

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

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

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

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