Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
/grade/ -> querylib.php (source)

Functions used to retrieve grades objects

Copyright: 2008 Petr Skoda and Nicolas Connault
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 352 lines (13 kb)
Included or required:0 times
Referenced: 4 times
Includes or requires: 0 files

Defines 5 functions


Functions that are not part of a class:

grade_get_course_grades($courseid, $userid_or_ids=null)   X-Ref
Returns the aggregated or calculated course grade(s) for a single course for one or more users

param: int $courseid The ID of course
param: int|array $userid_or_ids Optional ID of the graded user or array of user IDs; if userid not used, returns only information about grade_item
return: stdClass Returns an object containing information about course grade item. scaleid, name, grade

grade_get_course_grade($userid, $courseid_or_ids=null)   X-Ref
Returns the aggregated or calculated course grade for a single user for one or more courses

param: int $userid The ID of the single user
param: int|array $courseid_or_ids Optional ID of course or array of IDs, empty means all of the user's courses
return: mixed grade info or grades array including item info, false if error

grade_get_grade_items_for_activity($cm, $only_main_item=false)   X-Ref
Returns all grade items (including outcomes) or main item for a given activity identified by $cm object.

param: cm_info $cm A course module object (preferably with modname property)
param: bool $only_main_item Limit the search to the primary grade item for the activity, 'itemnumber'==0
return: mixed An array of grade item instances, one grade item if $only_main_item == true, false if error or not found

grade_is_user_graded_in_activity($cm, $userid)   X-Ref
Returns whether or not a user received grades in main grade item for given activity

param: cm_info $cm The activity context module
param: int $userid The user ID
return: bool True if graded, false if user not graded yet

grade_get_gradable_activities($courseid, $modulename='')   X-Ref
Returns an array of activities (defined as $cm objects) which are gradeable from gradebook, outcomes are ignored.

param: int $courseid If provided then restrict to one course.
param: string $modulename If defined (could be 'forum', 'assignment' etc) then only that type are returned.
return: array $cm objects