Search moodle.org's
Developer Documentation

  • Bug fixes for general core bugs in 3.11.x will end 9 May 2022 (12 months).
  • Bug fixes for security issues in 3.11.x will end 14 November 2022 (18 months).
  • 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 35 and 311] [Versions 36 and 311] [Versions 37 and 311] [Versions 38 and 311] [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: 3376 lines (124 kb)
    Included or required: 1 time
    Referenced: 7 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

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

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

    return: void
    param: grade_grade $grade Grade object

    _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.

    return: null
    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

    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.

    return: nothing or string if $return true
    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

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

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

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

    return: nothing or string if $return true
    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

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

    return: array
    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, ...

    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

    return: void
    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

    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).

    return: string HTML code or nothing if $return == false
    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.

    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

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

    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

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

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

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

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

    return: string
    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

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

    return: array
    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

    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.

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

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

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

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

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

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

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

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

    return: void
    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?

    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.

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

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

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

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

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

    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.

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

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

    return: string $xml
    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

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

    return: string
    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

    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

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

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

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

    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

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

    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

    return: string header
    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"

    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

    return: string
    param: grade_grade $grade

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

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

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

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

    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.

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

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

    return: string|action_menu_link
    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

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

    return: string|action_menu_link
    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

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

    return: string|action_menu_link
    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

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

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

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

    return: string|action_menu_link
    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

    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

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

    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

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

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

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

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

    return: string
    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

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

    return: array
    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

    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.

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

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

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

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

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

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

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

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

    return: void
    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?

    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.

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

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

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

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

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

    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.

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

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

    return: string $xml
    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

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

    return: string
    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

    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

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

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

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

    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

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

    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

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

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

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

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

    return: string
    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

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

    return: array
    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

    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.

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

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

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

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

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

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

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

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

    return: void
    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?

    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.

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

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

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

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

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

    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.

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

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

    return: string $xml
    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

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

    return: string
    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

    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

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

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

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

    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

    return: grade_plugin_info[]
    param: int $courseid

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

    return: array
    param: int $courseid

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

    return: grade_plugin_info
    param: int $courseid

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

    return: grade_plugin_info
    param: int $courseid

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

    return: array
    param: int $courseid

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

    return: array
    param: int $courseid

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

    return: array
    param: int $courseid

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

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

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

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

    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.

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