Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
grading_manager Class Reference

General class providing access to common grading features. More...

Public Member Functions

 create_shared_area ($method)
 Creates a new shared area to hold a grading form template.
 
 extend_navigation (global_navigation $navigation, navigation_node $modulenode=null)
 Extends the module navigation with the advanced grading information.
 
 extend_settings_navigation (settings_navigation $settingsnav, navigation_node $modulenode=null)
 Extends the settings navigation with the grading settings.
 
 get_active_controller ()
 Returns the controller for the active method if it is available.
 
 get_active_method ()
 Returns the currently active grading method in the gradable area.
 
 get_area ()
 Returns grading manager area name.
 
 get_area_title ()
 Returns the localized title of the currently set area.
 
 get_available_areas ()
 Returns the list of gradable areas in the given context and component.
 
 get_available_methods ($includenone=true)
 Returns the list of available grading methods in the given context.
 
 get_component ()
 Returns grading manager component.
 
 get_component_title ()
 Returns a text describing the context and the component.
 
 get_context ()
 Returns grading manager context.
 
 get_controller ($method)
 Returns the given method's controller in the gradable area.
 
 get_management_url (moodle_url $returnurl=null)
 Returns the URL of the grading area management page.
 
 load ($areaid)
 Loads the gradable area info from the database.
 
 set_active_method ($method)
 Sets the currently active grading method in the gradable area.
 
 set_area ($area)
 Sets the area the manager operates on.
 
 set_component ($component)
 Sets the component the manager operates on.
 
 set_context (stdClass $context)
 Sets the context the manager operates on.
 

Static Public Member Functions

static available_areas ($component)
 Returns the list of gradable areas provided by the given component.
 
static available_methods ($includenone=true)
 Returns the list of installed grading plugins together, optionally extended with a simple direct grading.
 
static delete_all_for_context ($contextid)
 Removes all data associated with the given context.
 
static tokenize ($needle)
 Helper method to tokenize the given string.
 

Protected Attributes

string $area
 the name of the gradable area
 
string $component
 the frankenstyle name of the component
 
stdClass $context
 the context
 

Detailed Description

General class providing access to common grading features.

Grading manager provides access to the particular grading method controller in that area.

Fully initialized instance of the grading manager operates over a single gradable area. It is possible to work with a partially initialized manager that knows just context and component without known area, for example. It is also possible to change context, component and area of an existing manager. Such pattern is used when copying form definitions, for example.

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

Member Function Documentation

◆ available_areas()

static grading_manager::available_areas ( $component)
static

Returns the list of gradable areas provided by the given component.

This performs a callback to the library of the relevant plugin to obtain the list of supported areas.

Parameters
string$componentnormalized component name
Return values
arrayof (string)areacode => (string)localized title of the area

◆ available_methods()

static grading_manager::available_methods ( $includenone = true)
static

Returns the list of installed grading plugins together, optionally extended with a simple direct grading.

Parameters
bool$includenoneshould the 'Simple direct grading' be included
Return values
arrayof the (string)name => (string)localized title of the method

◆ create_shared_area()

grading_manager::create_shared_area ( $method)

Creates a new shared area to hold a grading form template.

Shared area are implemented as virtual gradable areas at the system level context with the component set to core_grading and unique random area name.

Parameters
string$methodthe name of the plugin we create the area for
Return values
intthe new area id

◆ delete_all_for_context()

static grading_manager::delete_all_for_context ( $contextid)
static

Removes all data associated with the given context.

This is called by context::delete_content()

Parameters
int$contextidcontext id

◆ extend_navigation()

grading_manager::extend_navigation ( global_navigation $navigation,
navigation_node $modulenode = null )

Extends the module navigation with the advanced grading information.

This function is called when the context for the page is an activity module with the FEATURE_ADVANCED_GRADING.

Parameters
global_navigation$navigation
navigation_node$modulenode

◆ extend_settings_navigation()

grading_manager::extend_settings_navigation ( settings_navigation $settingsnav,
navigation_node $modulenode = null )

Extends the settings navigation with the grading settings.

This function is called when the context for the page is an activity module with the FEATURE_ADVANCED_GRADING and the user has the permission moodle/grade:managegradingforms.

Parameters
settings_navigation$settingsnavsettings_navigation
navigation_node$modulenodenavigation_node

◆ get_active_controller()

grading_manager::get_active_controller ( )

Returns the controller for the active method if it is available.

Return values
null|gradingform_controller

◆ get_active_method()

grading_manager::get_active_method ( )

Returns the currently active grading method in the gradable area.

Return values
string|nullthe name of the grading plugin of null if it has not been set

◆ get_area()

grading_manager::get_area ( )

Returns grading manager area name.

Return values
stringgrading manager area name

◆ get_area_title()

grading_manager::get_area_title ( )

Returns the localized title of the currently set area.

Return values
string

◆ get_available_areas()

grading_manager::get_available_areas ( )

Returns the list of gradable areas in the given context and component.

This performs a callback to the library of the relevant plugin to obtain the list of supported areas.

Return values
arrayof (string)areacode => (string)localized title of the area

◆ get_available_methods()

grading_manager::get_available_methods ( $includenone = true)

Returns the list of available grading methods in the given context.

Currently this is just a static list obtained from self::available_methods(). In the future, the list of available methods may be controlled per-context.

Requires the context property to be set in advance.

Parameters
bool$includenoneshould the 'Simple direct grading' be included
Return values
arrayof the (string)name => (string)localized title of the method

◆ get_component()

grading_manager::get_component ( )

Returns grading manager component.

Return values
stringgrading manager component

◆ get_component_title()

grading_manager::get_component_title ( )

Returns a text describing the context and the component.

At the moment this works for gradable areas in course modules. In the future, this method should be improved so it works for other contexts (blocks, gradebook items etc) or subplugins.

Return values
string

◆ get_context()

grading_manager::get_context ( )

Returns grading manager context.

Return values
stdClassgrading manager context

◆ get_controller()

grading_manager::get_controller ( $method)

Returns the given method's controller in the gradable area.

Parameters
string$methodthe method name, eg 'rubric' (must be available)
Return values
gradingform_controller

◆ get_management_url()

grading_manager::get_management_url ( moodle_url $returnurl = null)

Returns the URL of the grading area management page.

Parameters
moodle_url$returnurloptional URL of the page where the user should be sent back to
Return values
moodle_url

◆ load()

grading_manager::load ( $areaid)

Loads the gradable area info from the database.

Parameters
int$areaid

◆ set_active_method()

grading_manager::set_active_method ( $method)

Sets the currently active grading method in the gradable area.

Parameters
string$methodthe method name, eg 'rubric' (must be available)
Return values
booltrue if the method changed or was just set, false otherwise

◆ set_area()

grading_manager::set_area ( $area)

Sets the area the manager operates on.

Parameters
string$areathe name of the gradable area

◆ set_component()

grading_manager::set_component ( $component)

Sets the component the manager operates on.

Parameters
string$componentthe frankenstyle name of the component

◆ set_context()

grading_manager::set_context ( stdClass $context)

Sets the context the manager operates on.

Parameters
stdClass$context

◆ tokenize()

static grading_manager::tokenize ( $needle)
static

Helper method to tokenize the given string.

Splits the given string into smaller strings. This is a helper method for full text searching in grading forms. If the given string is surrounded with double quotes, the resulting array consists of a single item containing the quoted content.

Otherwise, string like 'grammar, english language' would be tokenized into the three tokens 'grammar', 'english', 'language'.

One-letter tokens like are dropped in non-phrase mode. Repeated tokens are returned just once.

Parameters
string$needle
Return values
array

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