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.
/grade/ -> lib.php (source)

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]

Functions used by gradebook plugins and reports.

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

Defines 10 classes

graded_users_iterator:: (20 methods):
  __construct()
  init()
  next_user()
  close()
  require_active_enrolment()
  allow_user_custom_fields()
  _push()
  _pop()
  print_graded_users_selector()
  grade_get_graded_users_select()
  hide_natural_aggregation_upgrade_notice()
  grade_hide_min_max_grade_upgrade_notice()
  grade_upgrade_use_min_max_from_grade_grade()
  grade_upgrade_use_min_max_from_grade_item()
  hide_aggregatesubcats_upgrade_notice()
  hide_gradebook_calculations_freeze_notice()
  print_natural_aggregation_upgrade_notice()
  print_grade_plugin_selector()
  grade_print_tabs()
  grade_get_plugin_info()

grade_plugin_info:: (2 methods):
  __construct()
  print_grade_page_head()

grade_plugin_return:: (2 methods):
  __construct()
  grade_plugin_return()

name:: (23 methods):
  get_options()
  get_return_url()
  get_form_fields()
  add_mform_elements()
  add_url_params()
  grade_build_nav()
  flatten()
  locate_element()
  category_collapse()
  no_outcomes()
  category_grade_last()
  fill_levels()
  can_output_item()
  inject_fillers()
  inject_colspans()
  locate_element()
  exporttoxml()
  exporttojson()
  get_levels()
  get_items()
  get_item()
  grade_button()
  grade_extend_settings()

grade_structure:: (13 methods):
  get_element_icon()
  get_element_header()
  get_activity_link()
  get_grade_analysis_url()
  get_grade_analysis_icon()
  get_grade_eid()
  get_item_eid()
  get_params_for_iconstr()
  get_reset_icon()
  get_edit_icon()
  get_hiding_icon()
  get_locking_icon()
  get_calculation_icon()

grade_seq:: (2 methods):
  __construct()
  grade_seq()

name:: (23 methods):
  get_options()
  get_return_url()
  get_form_fields()
  add_mform_elements()
  add_url_params()
  grade_build_nav()
  flatten()
  locate_element()
  category_collapse()
  no_outcomes()
  category_grade_last()
  fill_levels()
  can_output_item()
  inject_fillers()
  inject_colspans()
  locate_element()
  exporttoxml()
  exporttojson()
  get_levels()
  get_items()
  get_item()
  grade_button()
  grade_extend_settings()

grade_tree:: (2 methods):
  __construct()
  grade_tree()

name:: (23 methods):
  get_options()
  get_return_url()
  get_form_fields()
  add_mform_elements()
  add_url_params()
  grade_build_nav()
  flatten()
  locate_element()
  category_collapse()
  no_outcomes()
  category_grade_last()
  fill_levels()
  can_output_item()
  inject_fillers()
  inject_colspans()
  locate_element()
  exporttoxml()
  exporttojson()
  get_levels()
  get_items()
  get_item()
  grade_button()
  grade_extend_settings()

grade_helper:: (12 methods):
  get_plugin_strings()
  get_aggregation_strings()
  get_info_manage_settings()
  get_plugins_reports()
  get_info_scales()
  get_info_outcomes()
  get_info_letters()
  get_plugins_import()
  get_plugins_export()
  get_user_field_value()
  get_user_profile_fields()
  fetch_all_natural_weights_for_course()


Class: graded_users_iterator  - X-Ref

This class iterates over all users that are graded in a course.
Returns detailed info about users and their grades.

__construct($course, $grade_items=null, $groupid=0,$sortfield1='lastname', $sortorder1='ASC',$sortfield2='firstname', $sortorder2='ASC')   X-Ref
Constructor

param: object $course A course object
param: array  $grade_items array of grade items, if not specified only user info returned
param: int    $groupid iterate only group users if present
param: string $sortfield1 The first field of the users table by which the array of users will be sorted
param: string $sortorder1 The order in which the first sorting field will be sorted (ASC or DESC)
param: string $sortfield2 The second field of the users table by which the array of users will be sorted
param: string $sortorder2 The order in which the second sorting field will be sorted (ASC or DESC)

init()   X-Ref
Initialise the iterator

return: boolean success

next_user()   X-Ref
Returns information about the next user

return: mixed array of user info, all grades and feedback or null when no more users found

close()   X-Ref
Close the iterator, do not forget to call this function


require_active_enrolment($onlyactive = true)   X-Ref
Should all enrolled users be exported or just those with an active enrolment?

param: bool $onlyactive True to limit the export to users with an active enrolment

allow_user_custom_fields($allow = true)   X-Ref
Allow custom fields to be included

param: bool $allow Whether to allow custom fields or not
return: void

_push($grade)   X-Ref
Add a grade_grade instance to the grade stack

param: grade_grade $grade Grade object
return: void

_pop()   X-Ref
Remove a grade_grade instance from the grade stack

return: grade_grade current grade object

print_graded_users_selector($course, $actionpage, $userid=0, $groupid=0, $includeall=true, $return=false)   X-Ref
Print a selection popup form of the graded users in a course.

param: int    $course id of the course
param: string $actionpage The page receiving the data from the popoup form
param: int    $userid   id of the currently selected user (or 'all' if they are all selected)
param: int    $groupid id of requested group, 0 means all
param: int    $includeall bool include all option
param: bool   $return If true, will return the HTML, otherwise, will print directly
return: null

grade_get_graded_users_select($report, $course, $userid, $groupid, $includeall)   X-Ref
No description

hide_natural_aggregation_upgrade_notice($courseid)   X-Ref
Hide warning about changed grades during upgrade to 2.8.

param: int $courseid The current course id.

grade_hide_min_max_grade_upgrade_notice($courseid)   X-Ref
Hide warning about changed grades during upgrade from 2.8.0-2.8.6 and 2.9.0.

param: int $courseid The current course id.

grade_upgrade_use_min_max_from_grade_grade($courseid)   X-Ref
Use the grade min and max from the grade_grade.

This is reserved for core use after an upgrade.

param: int $courseid The current course id.

grade_upgrade_use_min_max_from_grade_item($courseid)   X-Ref
Use the grade min and max from the grade_item.

This is reserved for core use after an upgrade.

param: int $courseid The current course id.

hide_aggregatesubcats_upgrade_notice($courseid)   X-Ref
Hide warning about changed grades during upgrade to 2.8.

param: int $courseid The current course id.

hide_gradebook_calculations_freeze_notice($courseid)   X-Ref
Hide warning about changed grades due to bug fixes

param: int $courseid The current course id.

print_natural_aggregation_upgrade_notice($courseid, $context, $thispage, $return=false)   X-Ref
Print warning about changed grades during upgrade to 2.8.

param: int $courseid The current course id.
param: context $context The course context.
param: string $thispage The relative path for the current page. E.g. /grade/report/user/index.php
param: boolean $return return as string
return: nothing or string if $return true

print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return=false)   X-Ref
Print grading plugin selection popup form.

param: array   $plugin_info An array of plugins containing information for the selector
param: boolean $return return as string
return: nothing or string if $return true

grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=false)   X-Ref
Print grading plugin selection tab-based navigation.

param: string  $active_type type of plugin on current page - import, export, report or edit
param: string  $active_plugin active plugin type - grader, user, cvs, ...
param: array   $plugin_info Array of plugins
param: boolean $return return as string
return: nothing or string if $return true

grade_get_plugin_info($courseid, $active_type, $active_plugin)   X-Ref
grade_get_plugin_info

param: int    $courseid The course id
param: string $active_type type of plugin on current page - import, export, report or edit
param: string $active_plugin active plugin type - grader, user, cvs, ...
return: array

Class: grade_plugin_info  - X-Ref

A simple class containing info about grade plugins.
Can be subclassed for special rules

__construct($id, $link, $string, $parent=null)   X-Ref
Constructor

param: int $id A unique id for this plugin
param: string $link A URL to access this plugin
param: string $string The name of this plugin
param: object $parent Another grade_plugin_info object, parent of the current one
return: void

print_grade_page_head($courseid, $active_type, $active_plugin=null,$heading = false, $return=false,$buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null,$user = null)   X-Ref
Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and
(optional) navigation tabs for any gradebook page. All gradebook pages MUST use these functions
in favour of the usual print_header(), print_header_simple(), print_heading() etc.
!IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at
the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN).

param: int     $courseid Course id
param: string  $active_type The type of the current page (report, settings,
param: string  $active_plugin The plugin of the current page (grader, fullview etc...)
param: string  $heading The heading of the page. Tries to guess if none is given
param: boolean $return Whether to return (true) or echo (false) the HTML generated by this function
param: string  $bodytags Additional attributes that will be added to the <body> tag
param: string  $buttons Additional buttons to display on the page
param: boolean $shownavigation should the gradebook navigation drop down (or tabs) be shown?
param: string  $headerhelpidentifier The help string identifier if required.
param: string  $headerhelpcomponent The component for the help string.
param: stdClass $user The user object for use with the user context header.
return: string HTML code or nothing if $return == false

Class: grade_plugin_return  - X-Ref

Utility class used for return tracking when using edit and other forms in grade plugins

__construct($params = [])   X-Ref
Constructor

param: array $params - associative array with return parameters, if not supplied parameter are taken from _GET or _POST

grade_plugin_return($params = null)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

get_options()   X-Ref
Returns return parameters as options array suitable for buttons.

return: array options

get_return_url($default, $extras=null)   X-Ref
Returns return url

param: string $default default url when params not set
param: array  $extras Extra URL parameters
return: string url

get_form_fields()   X-Ref
Returns string with hidden return tracking form elements.

return: string

add_mform_elements(&$mform)   X-Ref
Add hidden elements into mform

param: object &$mform moodle form object
return: void

add_url_params(moodle_url $url)   X-Ref
Add return tracking params into url

param: moodle_url $url A URL
return: string $url with return tracking params

grade_build_nav($path, $pagename=null, $id=null)   X-Ref
Function central to gradebook for building and printing the navigation (breadcrumb trail).

param: string $path The path of the calling script (using __FILE__?)
param: string $pagename The language string to use as the last part of the navigation (non-link)
param: mixed  $id Either a plain integer (assuming the key is 'id') or
return: string

flatten(&$element, $category_grade_last, $nooutcomes)   X-Ref
Static recursive helper - makes the grade_item for category the last children

param: array &$element The seed of the recursion
param: bool $category_grade_last category grade item is the last child
param: bool $nooutcomes Whether or not outcomes should be included
return: array

locate_element($eid)   X-Ref
Parses the array in search of a given eid and returns a element object with
information about the element it has found.

param: int $eid Gradetree Element ID
return: object element

category_collapse(&$element, $collapsed)   X-Ref
Static recursive helper - removes items from collapsed categories

param: array &$element The seed of the recursion
param: array $collapsed array of collapsed categories
return: void

no_outcomes(&$element)   X-Ref
Static recursive helper - removes all outcomes

param: array &$element The seed of the recursion
return: void

category_grade_last(&$element)   X-Ref
Static recursive helper - makes the grade_item for category the last children

param: array &$element The seed of the recursion
return: void

fill_levels(&$levels, &$element, $depth)   X-Ref
Static recursive helper - fills the levels array, useful when accessing tree elements of one level

param: array &$levels The levels of the grade tree through which to recurse
param: array &$element The seed of the recursion
param: int   $depth How deep are we?
return: void

can_output_item($element)   X-Ref
Determines whether the grade tree item can be displayed.
This is particularly targeted for grade categories that have no total (None) when rendering the grade tree.
It checks if the grade tree item is of type 'category', and makes sure that the category, or at least one of children,
can be output.

param: array $element The grade category element.
return: bool True if the grade tree item can be displayed. False, otherwise.

inject_fillers(&$element, $depth)   X-Ref
Static recursive helper - makes full tree (all leafes are at the same level)

param: array &$element The seed of the recursion
param: int   $depth How deep are we?
return: int

inject_colspans(&$element)   X-Ref
Static recursive helper - add colspan information into categories

param: array &$element The seed of the recursion
return: int

locate_element($eid)   X-Ref
Parses the array in search of a given eid and returns a element object with
information about the element it has found.

param: int $eid Gradetree Element ID
return: object element

exporttoxml($root=null, $tabs="\t")   X-Ref
Returns a well-formed XML representation of the grade-tree using recursion.

param: array  $root The current element in the recursion. If null, starts at the top of the tree.
param: string $tabs The control character to use for tabs
return: string $xml

exporttojson($root=null, $tabs="\t")   X-Ref
Returns a JSON representation of the grade-tree using recursion.

param: array $root The current element in the recursion. If null, starts at the top of the tree.
param: string $tabs Tab characters used to indent the string nicely for humans to enjoy
return: string

get_levels()   X-Ref
Returns the array of levels

return: array

get_items()   X-Ref
Returns the array of grade items

return: array

get_item($itemid)   X-Ref
Returns a specific Grade Item

param: int $itemid The ID of the grade_item object
return: grade_item

grade_button($type, $courseid, $object)   X-Ref
Local shortcut function for creating an edit/delete button for a grade_* object.

param: string $type 'edit' or 'delete'
param: int $courseid The Course ID
param: grade_* $object The grade_* object
return: string html

grade_extend_settings($plugininfo, $courseid)   X-Ref
This method adds settings to the settings block for the grade system and its
plugins


Class: grade_structure  - X-Ref

General structure representing grade items in course

get_element_icon(&$element, $spacerifnone=false)   X-Ref
Returns icon of element

param: array &$element An array representing an element in the grade_tree
param: bool  $spacerifnone return spacer if no icon found
return: string icon or spacer

get_element_header(&$element, $withlink = false, $icon = true, $spacerifnone = false,$withdescription = false, $fulltotal = false)   X-Ref
Returns name of element optionally with icon and link

param: array &$element An array representing an element in the grade_tree
param: bool  $withlink Whether or not this header has a link
param: bool  $icon Whether or not to display an icon with this header
param: bool  $spacerifnone return spacer if no icon found
param: bool  $withdescription Show description if defined by this item.
param: bool  $fulltotal If the item is a category total, returns $categoryname."total"
return: string header

get_activity_link($element)   X-Ref
No description

get_grade_analysis_url(grade_grade $grade)   X-Ref
Returns URL of a page that is supposed to contain detailed grade analysis

At the moment, only activity modules are supported. The method generates link
to the module's file grade.php with the parameters id (cmid), itemid, itemnumber,
gradeid and userid. If the grade.php does not exist, null is returned.

return: moodle_url|null URL or null if unable to construct it

get_grade_analysis_icon(grade_grade $grade)   X-Ref
Returns an action icon leading to the grade analysis page

param: grade_grade $grade
return: string

get_grade_eid($grade_grade)   X-Ref
Returns the grade eid - the grade may not exist yet.

param: grade_grade $grade_grade A grade_grade object
return: string eid

get_item_eid($grade_item)   X-Ref
Returns the grade_item eid

param: grade_item $grade_item A grade_item object
return: string eid

get_params_for_iconstr($element)   X-Ref
Given a grade_tree element, returns an array of parameters
used to build an icon for that element.

param: array $element An array representing an element in the grade_tree
return: array

get_reset_icon($element, $gpr, $returnactionmenulink = false)   X-Ref
Return a reset icon for the given element.

param: array  $element An array representing an element in the grade_tree
param: object $gpr A grade_plugin_return object
param: bool $returnactionmenulink return the instance of action_menu_link instead of string
return: string|action_menu_link

get_edit_icon($element, $gpr, $returnactionmenulink = false)   X-Ref
Return edit icon for give element

param: array  $element An array representing an element in the grade_tree
param: object $gpr A grade_plugin_return object
param: bool $returnactionmenulink return the instance of action_menu_link instead of string
return: string|action_menu_link

get_hiding_icon($element, $gpr, $returnactionmenulink = false)   X-Ref
Return hiding icon for give element

param: array  $element An array representing an element in the grade_tree
param: object $gpr A grade_plugin_return object
param: bool $returnactionmenulink return the instance of action_menu_link instead of string
return: string|action_menu_link

get_locking_icon($element, $gpr)   X-Ref
Return locking icon for given element

param: array  $element An array representing an element in the grade_tree
param: object $gpr A grade_plugin_return object
return: string

get_calculation_icon($element, $gpr, $returnactionmenulink = false)   X-Ref
Return calculation icon for given element

param: array  $element An array representing an element in the grade_tree
param: object $gpr A grade_plugin_return object
param: bool $returnactionmenulink return the instance of action_menu_link instead of string
return: string|action_menu_link

Class: grade_seq  - X-Ref

Flat structure similar to grade tree.

__construct($courseid, $category_grade_last=false, $nooutcomes=false)   X-Ref
Constructor, retrieves and stores array of all grade_category and grade_item
objects for the given courseid. Full objects are instantiated. Ordering sequence is fixed if needed.

param: int  $courseid The course id
param: bool $category_grade_last category grade item is the last child
param: bool $nooutcomes Whether or not outcomes should be included

grade_seq($courseid, $category_grade_last=false, $nooutcomes=false)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

get_options()   X-Ref
Returns return parameters as options array suitable for buttons.

return: array options

get_return_url($default, $extras=null)   X-Ref
Returns return url

param: string $default default url when params not set
param: array  $extras Extra URL parameters
return: string url

get_form_fields()   X-Ref
Returns string with hidden return tracking form elements.

return: string

add_mform_elements(&$mform)   X-Ref
Add hidden elements into mform

param: object &$mform moodle form object
return: void

add_url_params(moodle_url $url)   X-Ref
Add return tracking params into url

param: moodle_url $url A URL
return: string $url with return tracking params

grade_build_nav($path, $pagename=null, $id=null)   X-Ref
Function central to gradebook for building and printing the navigation (breadcrumb trail).

param: string $path The path of the calling script (using __FILE__?)
param: string $pagename The language string to use as the last part of the navigation (non-link)
param: mixed  $id Either a plain integer (assuming the key is 'id') or
return: string

flatten(&$element, $category_grade_last, $nooutcomes)   X-Ref
Static recursive helper - makes the grade_item for category the last children

param: array &$element The seed of the recursion
param: bool $category_grade_last category grade item is the last child
param: bool $nooutcomes Whether or not outcomes should be included
return: array

locate_element($eid)   X-Ref
Parses the array in search of a given eid and returns a element object with
information about the element it has found.

param: int $eid Gradetree Element ID
return: object element

category_collapse(&$element, $collapsed)   X-Ref
Static recursive helper - removes items from collapsed categories

param: array &$element The seed of the recursion
param: array $collapsed array of collapsed categories
return: void

no_outcomes(&$element)   X-Ref
Static recursive helper - removes all outcomes

param: array &$element The seed of the recursion
return: void

category_grade_last(&$element)   X-Ref
Static recursive helper - makes the grade_item for category the last children

param: array &$element The seed of the recursion
return: void

fill_levels(&$levels, &$element, $depth)   X-Ref
Static recursive helper - fills the levels array, useful when accessing tree elements of one level

param: array &$levels The levels of the grade tree through which to recurse
param: array &$element The seed of the recursion
param: int   $depth How deep are we?
return: void

can_output_item($element)   X-Ref
Determines whether the grade tree item can be displayed.
This is particularly targeted for grade categories that have no total (None) when rendering the grade tree.
It checks if the grade tree item is of type 'category', and makes sure that the category, or at least one of children,
can be output.

param: array $element The grade category element.
return: bool True if the grade tree item can be displayed. False, otherwise.

inject_fillers(&$element, $depth)   X-Ref
Static recursive helper - makes full tree (all leafes are at the same level)

param: array &$element The seed of the recursion
param: int   $depth How deep are we?
return: int

inject_colspans(&$element)   X-Ref
Static recursive helper - add colspan information into categories

param: array &$element The seed of the recursion
return: int

locate_element($eid)   X-Ref
Parses the array in search of a given eid and returns a element object with
information about the element it has found.

param: int $eid Gradetree Element ID
return: object element

exporttoxml($root=null, $tabs="\t")   X-Ref
Returns a well-formed XML representation of the grade-tree using recursion.

param: array  $root The current element in the recursion. If null, starts at the top of the tree.
param: string $tabs The control character to use for tabs
return: string $xml

exporttojson($root=null, $tabs="\t")   X-Ref
Returns a JSON representation of the grade-tree using recursion.

param: array $root The current element in the recursion. If null, starts at the top of the tree.
param: string $tabs Tab characters used to indent the string nicely for humans to enjoy
return: string

get_levels()   X-Ref
Returns the array of levels

return: array

get_items()   X-Ref
Returns the array of grade items

return: array

get_item($itemid)   X-Ref
Returns a specific Grade Item

param: int $itemid The ID of the grade_item object
return: grade_item

grade_button($type, $courseid, $object)   X-Ref
Local shortcut function for creating an edit/delete button for a grade_* object.

param: string $type 'edit' or 'delete'
param: int $courseid The Course ID
param: grade_* $object The grade_* object
return: string html

grade_extend_settings($plugininfo, $courseid)   X-Ref
This method adds settings to the settings block for the grade system and its
plugins


Class: grade_tree  - X-Ref

This class represents a complete tree of categories, grade_items and final grades,
organises as an array primarily, but which can also be converted to other formats.
It has simple method calls with complex implementations, allowing for easy insertion,
deletion and moving of items and categories within the tree.

__construct($courseid, $fillers=true, $category_grade_last=false,$collapsed=null, $nooutcomes=false)   X-Ref
Constructor, retrieves and stores a hierarchical array of all grade_category and grade_item
objects for the given courseid. Full objects are instantiated. Ordering sequence is fixed if needed.

param: int   $courseid The Course ID
param: bool  $fillers include fillers and colspans, make the levels var "rectangular"
param: bool  $category_grade_last category grade item is the last child
param: array $collapsed array of collapsed categories
param: bool  $nooutcomes Whether or not outcomes should be included

grade_tree($courseid, $fillers=true, $category_grade_last=false,$collapsed=null, $nooutcomes=false)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

get_options()   X-Ref
Returns return parameters as options array suitable for buttons.

return: array options

get_return_url($default, $extras=null)   X-Ref
Returns return url

param: string $default default url when params not set
param: array  $extras Extra URL parameters
return: string url

get_form_fields()   X-Ref
Returns string with hidden return tracking form elements.

return: string

add_mform_elements(&$mform)   X-Ref
Add hidden elements into mform

param: object &$mform moodle form object
return: void

add_url_params(moodle_url $url)   X-Ref
Add return tracking params into url

param: moodle_url $url A URL
return: string $url with return tracking params

grade_build_nav($path, $pagename=null, $id=null)   X-Ref
Function central to gradebook for building and printing the navigation (breadcrumb trail).

param: string $path The path of the calling script (using __FILE__?)
param: string $pagename The language string to use as the last part of the navigation (non-link)
param: mixed  $id Either a plain integer (assuming the key is 'id') or
return: string

flatten(&$element, $category_grade_last, $nooutcomes)   X-Ref
Static recursive helper - makes the grade_item for category the last children

param: array &$element The seed of the recursion
param: bool $category_grade_last category grade item is the last child
param: bool $nooutcomes Whether or not outcomes should be included
return: array

locate_element($eid)   X-Ref
Parses the array in search of a given eid and returns a element object with
information about the element it has found.

param: int $eid Gradetree Element ID
return: object element

category_collapse(&$element, $collapsed)   X-Ref
Static recursive helper - removes items from collapsed categories

param: array &$element The seed of the recursion
param: array $collapsed array of collapsed categories
return: void

no_outcomes(&$element)   X-Ref
Static recursive helper - removes all outcomes

param: array &$element The seed of the recursion
return: void

category_grade_last(&$element)   X-Ref
Static recursive helper - makes the grade_item for category the last children

param: array &$element The seed of the recursion
return: void

fill_levels(&$levels, &$element, $depth)   X-Ref
Static recursive helper - fills the levels array, useful when accessing tree elements of one level

param: array &$levels The levels of the grade tree through which to recurse
param: array &$element The seed of the recursion
param: int   $depth How deep are we?
return: void

can_output_item($element)   X-Ref
Determines whether the grade tree item can be displayed.
This is particularly targeted for grade categories that have no total (None) when rendering the grade tree.
It checks if the grade tree item is of type 'category', and makes sure that the category, or at least one of children,
can be output.

param: array $element The grade category element.
return: bool True if the grade tree item can be displayed. False, otherwise.

inject_fillers(&$element, $depth)   X-Ref
Static recursive helper - makes full tree (all leafes are at the same level)

param: array &$element The seed of the recursion
param: int   $depth How deep are we?
return: int

inject_colspans(&$element)   X-Ref
Static recursive helper - add colspan information into categories

param: array &$element The seed of the recursion
return: int

locate_element($eid)   X-Ref
Parses the array in search of a given eid and returns a element object with
information about the element it has found.

param: int $eid Gradetree Element ID
return: object element

exporttoxml($root=null, $tabs="\t")   X-Ref
Returns a well-formed XML representation of the grade-tree using recursion.

param: array  $root The current element in the recursion. If null, starts at the top of the tree.
param: string $tabs The control character to use for tabs
return: string $xml

exporttojson($root=null, $tabs="\t")   X-Ref
Returns a JSON representation of the grade-tree using recursion.

param: array $root The current element in the recursion. If null, starts at the top of the tree.
param: string $tabs Tab characters used to indent the string nicely for humans to enjoy
return: string

get_levels()   X-Ref
Returns the array of levels

return: array

get_items()   X-Ref
Returns the array of grade items

return: array

get_item($itemid)   X-Ref
Returns a specific Grade Item

param: int $itemid The ID of the grade_item object
return: grade_item

grade_button($type, $courseid, $object)   X-Ref
Local shortcut function for creating an edit/delete button for a grade_* object.

param: string $type 'edit' or 'delete'
param: int $courseid The Course ID
param: grade_* $object The grade_* object
return: string html

grade_extend_settings($plugininfo, $courseid)   X-Ref
This method adds settings to the settings block for the grade system and its
plugins


Class: grade_helper  - X-Ref

Grade helper class

This class provides several helpful functions that work irrespective of any
current state.

get_plugin_strings()   X-Ref
Gets strings commonly used by the describe plugins

report => get_string('view'),
scale => get_string('scales'),
outcome => get_string('outcomes', 'grades'),
letter => get_string('letters', 'grades'),
export => get_string('export', 'grades'),
import => get_string('import'),
settings => get_string('settings')

return: array

get_aggregation_strings()   X-Ref
Gets strings describing the available aggregation methods.

return: array

get_info_manage_settings($courseid)   X-Ref
Get grade_plugin_info object for managing settings if the user can

param: int $courseid
return: grade_plugin_info[]

get_plugins_reports($courseid)   X-Ref
Returns an array of plugin reports as grade_plugin_info objects

param: int $courseid
return: array

get_info_scales($courseid)   X-Ref
Get information on scales

param: int $courseid
return: grade_plugin_info

get_info_outcomes($courseid)   X-Ref
Get information on outcomes

param: int $courseid
return: grade_plugin_info

get_info_letters($courseid)   X-Ref
Get information on letters

param: int $courseid
return: array

get_plugins_import($courseid)   X-Ref
Get information import plugins

param: int $courseid
return: array

get_plugins_export($courseid)   X-Ref
Get information export plugins

param: int $courseid
return: array

get_user_field_value($user, $field)   X-Ref
Returns the value of a field from a user record

param: stdClass $user object
param: stdClass $field object
return: string value of the field

get_user_profile_fields($courseid, $includecustomfields = false)   X-Ref
Returns an array of user profile fields to be included in export

param: int $courseid
param: bool $includecustomfields
return: array An array of stdClass instances with customid, shortname, datatype, default and fullname fields

fetch_all_natural_weights_for_course($courseid)   X-Ref
This helper method gets a snapshot of all the weights for a course.
It is used as a quick method to see if any wieghts have been automatically adjusted.

param: int $courseid
return: array of itemid -> aggregationcoef2