Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 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: | 956 lines (40 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
grade_report:: (17 methods):
__construct()
get_pref()
set_pref()
get_additional_context()
get_lang_string()
get_numusers()
supports_mygrades()
setup_groups()
setup_users()
get_users_search_sql()
get_sort_arrow()
blank_hidden_total_and_adjust_bounds()
blank_hidden_total()
calculate_average()
ungraded_counts()
item_types()
get_gradable_users()
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_additional_context(context_course $context, int $courseid, array $element,grade_plugin_return $gpr, string $mode, stdClass $templatecontext, bool $otherplugins = false) X-Ref |
Add additional links specific to plugin param: context_course $context Course context param: int $courseid Course ID param: array $element An array representing an element in the grade_tree param: grade_plugin_return $gpr A grade_plugin_return object param: string $mode Mode (user or grade item) param: stdClass $templatecontext Template context param: bool $otherplugins If we need to insert links to other plugins return: ?stdClass Updated template context |
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_users_search_sql(array $mappings, array $userfields) X-Ref |
Prepare SQL where clause and associated parameters for any user searching being performed. This mostly came from core_user\table\participants_search with some slight modifications four our use case. param: array $mappings Array of field mappings (fieldname => SQL code for the value) param: array $userfields An array that we cast from user profile fields to search within. return: array SQL query data in the format ['where' => '', 'params' => []]. |
get_sort_arrow(string $direction = 'down', ?moodle_url $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|null $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 |
calculate_average(grade_item $gradeitem, array $info) X-Ref |
Calculate average grade for a given grade item. Based on calculate_averages function from grade/report/user/lib.php param: grade_item $gradeitem Grade item param: array $info Ungraded grade items counts and report preferences. return: array Average grade and meancount. |
ungraded_counts() X-Ref |
Get ungraded grade items info and sum of all grade items in a course. Based on calculate_averages function from grade/report/user/lib.php return: array Ungraded grade items counts with report preferences. |
item_types() X-Ref |
Get grade item type names in a course to use in filter dropdown. return: array Item types. |
get_gradable_users(int $courseid, ?int $groupid = null) X-Ref |
Load a valid list of gradable users in a course. param: int $courseid The course ID. param: int|null $groupid The group ID (optional). return: array A list of enrolled gradable users. |