Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
grade_helper Class Reference

Grade helper class. More...

Static Public Member Functions

static fetch_all_natural_weights_for_course ($courseid)
 This helper method gets a snapshot of all the weights for a course.
 
static get_activity_link (array $element)
 Returns a link to activity.
 
static get_aggregation_strings ()
 Gets strings describing the available aggregation methods.
 
static get_element_header (array $element, bool $withlink=false, bool $icon=true, bool $spacerifnone=false, bool $withdescription=false, bool $fulltotal=false, ?moodle_url $sortlink=null)
 Returns name of element optionally with icon and link.
 
static get_element_icon (array $element, bool $spacerifnone=false)
 Returns icon of element.
 
static get_element_type_string (array $element)
 Returns the string that describes the type of the element.
 
static get_info_letters ($courseid)
 Get information on letters.
 
static get_info_manage_settings ($courseid)
 Get grade_plugin_info object for managing settings if the user can.
 
static get_info_outcomes ($courseid)
 Get information on outcomes.
 
static get_info_scales ($courseid)
 Get information on scales.
 
static get_lang_string (string $strcode, ?string $section=null)
 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.
 
static get_plugin_strings ()
 Gets strings commonly used by the describe plugins.
 
static get_plugins_export ($courseid)
 Get information export plugins.
 
static get_plugins_import ($courseid)
 Get information import plugins.
 
static get_plugins_reports ($courseid)
 Returns an array of plugin reports as grade_plugin_info objects.
 
static get_user_field_value ($user, $field)
 Returns the value of a field from a user record.
 
static get_user_profile_fields ($courseid, $includecustomfields=false)
 Returns an array of user profile fields to be included in export.
 
static reset_caches ()
 Resets all static caches.
 

Static Protected Attributes

static array $aggregationstrings = null
 Cached grade aggregation strings.
 
static array false $exportplugins = null
 Cached grade export plugins {.
 
static array false $gradereportpreferences = null
 Cached grade report plugins preferences {.
 
static array false $gradereports = null
 Cached grade report plugins {.
 
static array false $importplugins = null
 Cached grade import plugins {.
 
static array $langstrings = []
 Cached grade tree plugin strings.
 
static grade_plugin_info false $letterinfo = null
 Cached leftter info {.
 
static grade_plugin_info false $managesetting = null
 Cached manage settings info {.
 
static grade_plugin_info false $outcomeinfo = null
 Cached outcome info {.
 
static array $pluginstrings = null
 Cached grade plugin strings.
 
static grade_plugin_info false $scaleinfo = null
 Cached scale info {.
 

Detailed Description

Grade helper class.

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

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ fetch_all_natural_weights_for_course()

static grade_helper::fetch_all_natural_weights_for_course ( $courseid)
static

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.

Parameters
int$courseid
Return values
arrayof itemid -> aggregationcoef2

◆ get_activity_link()

static grade_helper::get_activity_link ( array $element)
static

Returns a link to activity.

Parameters
array$elementAn array representing an element in the grade_tree
Return values
moodle_url|nulllink to activity or null if not found

◆ get_aggregation_strings()

static grade_helper::get_aggregation_strings ( )
static

Gets strings describing the available aggregation methods.

Return values
array

◆ get_element_header()

static grade_helper::get_element_header ( array $element,
bool $withlink = false,
bool $icon = true,
bool $spacerifnone = false,
bool $withdescription = false,
bool $fulltotal = false,
?moodle_url $sortlink = null )
static

Returns name of element optionally with icon and link.

Parameters
array$elementAn array representing an element in the grade_tree
bool$withlinkWhether or not this header has a link
bool$iconWhether or not to display an icon with this header
bool$spacerifnonereturn spacer if no icon found
bool$withdescriptionShow description if defined by this item.
bool$fulltotalIf the item is a category total, returns $categoryname."total" instead of "Category total" or "Course total"
moodle_url | null$sortlinkLink to sort column.
Return values
stringheader

◆ get_element_icon()

static grade_helper::get_element_icon ( array $element,
bool $spacerifnone = false )
static

Returns icon of element.

Parameters
array$elementAn array representing an element in the grade_tree
bool$spacerifnonereturn spacer if no icon found
Return values
stringicon or spacer

◆ get_element_type_string()

static grade_helper::get_element_type_string ( array $element)
static

Returns the string that describes the type of the element.

Parameters
array$elementAn array representing an element in the grade_tree
Return values
stringThe string that describes the type of the grade element

◆ get_info_letters()

static grade_helper::get_info_letters ( $courseid)
static

Get information on letters.

Parameters
int$courseid
Return values
array

◆ get_info_manage_settings()

static grade_helper::get_info_manage_settings ( $courseid)
static

Get grade_plugin_info object for managing settings if the user can.

Parameters
int$courseid
Return values
grade_plugin_info[]

◆ get_info_outcomes()

static grade_helper::get_info_outcomes ( $courseid)
static

Get information on outcomes.

Parameters
int$courseid
Return values
grade_plugin_info[]|false

◆ get_info_scales()

static grade_helper::get_info_scales ( $courseid)
static

Get information on scales.

Parameters
int$courseid
Return values
grade_plugin_info

◆ get_lang_string()

static grade_helper::get_lang_string ( string $strcode,
?string $section = null )
static

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.

Deprecated
since 4.3
Todo
MDL-78780 This will be deleted in Moodle 4.7.
Parameters
string$strcode
string | null$sectionOptional language section
Return values
string

◆ get_plugin_strings()

static grade_helper::get_plugin_strings ( )
static

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 values
array

◆ get_plugins_export()

static grade_helper::get_plugins_export ( $courseid)
static

Get information export plugins.

Parameters
int$courseid
Return values
array

◆ get_plugins_import()

static grade_helper::get_plugins_import ( $courseid)
static

Get information import plugins.

Parameters
int$courseid
Return values
array

◆ get_plugins_reports()

static grade_helper::get_plugins_reports ( $courseid)
static

Returns an array of plugin reports as grade_plugin_info objects.

Parameters
int$courseid
Return values
array

◆ get_user_field_value()

static grade_helper::get_user_field_value ( $user,
$field )
static

Returns the value of a field from a user record.

Parameters
stdClass$userobject
stdClass$fieldobject
Return values
stringvalue of the field

◆ get_user_profile_fields()

static grade_helper::get_user_profile_fields ( $courseid,
$includecustomfields = false )
static

Returns an array of user profile fields to be included in export.

Parameters
int$courseid
bool$includecustomfields
Return values
arrayAn array of stdClass instances with customid, shortname, datatype, default and fullname fields

◆ reset_caches()

static grade_helper::reset_caches ( )
static

Resets all static caches.

Return values
void

Member Data Documentation

◆ $exportplugins

array false grade_helper::$exportplugins = null
staticprotected

Cached grade export plugins {.

See also
get_plugins_export}

◆ $gradereportpreferences

array false grade_helper::$gradereportpreferences = null
staticprotected

Cached grade report plugins preferences {.

See also
get_info_scales}

◆ $gradereports

array false grade_helper::$gradereports = null
staticprotected

Cached grade report plugins {.

See also
get_plugins_reports}

◆ $importplugins

array false grade_helper::$importplugins = null
staticprotected

Cached grade import plugins {.

See also
get_plugins_import}

◆ $letterinfo

grade_plugin_info false grade_helper::$letterinfo = null
staticprotected

Cached leftter info {.

See also
get_info_letters}

◆ $managesetting

grade_plugin_info false grade_helper::$managesetting = null
staticprotected

Cached manage settings info {.

See also
get_info_settings}

◆ $outcomeinfo

grade_plugin_info false grade_helper::$outcomeinfo = null
staticprotected

Cached outcome info {.

See also
get_info_outcomes}

◆ $scaleinfo

grade_plugin_info false grade_helper::$scaleinfo = null
staticprotected

Cached scale info {.

See also
get_info_scales}

The documentation for this class was generated from the following file: