Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
gradingform_rubric_controller Class Reference

This controller encapsulates the rubric grading logic. More...

Inheritance diagram for gradingform_rubric_controller:
gradingform_controller

Public Member Functions

 create_instance ($raterid, $itemid=null)
 This function is invoked when user (teacher) starts grading.
 
 delete_definition ()
 Deletes the form definition and all the associated data.
 
 extend_navigation (global_navigation $navigation, navigation_node $node=null)
 Extends the module navigation.
 
 extend_settings_navigation (settings_navigation $settingsnav, navigation_node $node=null)
 Extends the module settings navigation with the rubric grading settings.
 
 fetch_instance (int $raterid, int $itemid, ?int $instanceid)
 If an instanceid is specified and grading instance exists and it is created by this rater for this item, then the instance is returned.
 
 form_unavailable_notification ()
 Returns a message why this form is unavailable.
 
 get_active_instances ($itemid)
 Returns list of ACTIVE instances for the specified $itemid (intentionally does not return instances with status NEEDUPDATE)
 
 get_all_active_instances ($since=0)
 Returns an array of all active instances for this definition.
 
 get_allow_grade_decimals ()
 Returns if decimal values are allowed as grades.
 
 get_area ()
 Returns gradable area name.
 
 get_areaid ()
 Returns gradable area id.
 
 get_component ()
 Returns gradable component name.
 
 get_context ()
 Returns controller context.
 
 get_current_instance ($raterid, $itemid, $idonly=false)
 Returns the current instance (either with status ACTIVE or NEEDUPDATE) for this definition for the specified $raterid and $itemid (if multiple raters are allowed, or only for $itemid otherwise).
 
 get_definition ($force=false)
 Returns the grading form definition structure.
 
 get_definition_copy (gradingform_controller $target)
 Returns the form definition suitable for cloning into another area.
 
 get_definition_for_editing ($addemptycriterion=false)
 Converts the current definition into an object suitable for the editor form's set_data()
 
 get_editor_url (moodle_url $returnurl=null)
 Returns URL of a page where the grading form can be defined and edited.
 
 get_formatted_description ()
 Formats the definition description for display on page.
 
 get_grade_range ()
 Returns the range of grades used in this area.
 
 get_min_max_score ()
 Calculates and returns the possible minimum and maximum score (in points) for this rubric.
 
 get_options ()
 Gets the options of this rubric definition, fills the missing options with default values.
 
 get_or_create_instance ($instanceid, $raterid, $itemid)
 If instanceid is specified and grading instance exists and it is created by this rater for this item, this instance is returned.
 
 get_renderer (moodle_page $page)
 Returns the rubric plugin renderer.
 
 has_active_instances ()
 Returns true if there are already people who has been graded on this definition.
 
 is_form_available ()
 Is the grading form defined and ready for usage?
 
 is_form_defined ()
 Is the form definition record available?
 
 is_own_form ($userid=null)
 Is the grading form owned by the given user?
 
 is_shared_template ()
 Is the grading form saved as a shared public template?
 
 mark_for_regrade ()
 Marks all instances filled with this rubric with the status INSTANCE_STATUS_NEEDUPDATE.
 
 render_grade ($page, $itemid, $gradinginfo, $defaultcontent, $cangrade)
 Returns html code to be included in student's feedback.
 
 render_preview (moodle_page $page)
 Returns the HTML code displaying the preview of the grading form.
 
 set_grade_range (array $graderange, $allowgradedecimals=false)
 Sets the range of grades used in this area.
 
 update_definition (stdClass $newdefinition, $usermodified=null)
 Saves the rubric definition into the database.
 
 update_or_check_rubric (stdClass $newdefinition, $usermodified=null, $doupdate=false)
 Either saves the rubric definition into the database or check if it has been changed.
 

Static Public Member Functions

static description_form_field_options ($context)
 Options for displaying the rubric description field in the form.
 
static get_default_options ()
 Returns the default options for the rubric display.
 
static get_external_definition_details ()
 
static get_external_instance_filling_details ()
 Returns an array that defines the structure of the rubric's filling.
 
static sql_search_from_tables ($gdid)
 Prepare the part of the search query to append to the FROM statement.
 
static sql_search_where ($token)
 Prepare the parts of the SQL WHERE statement to search for the given token.
 

Public Attributes

const DEFINITION_STATUS_DRAFT = 10
 the form is currently being edited and is not ready for usage yet
 
const DEFINITION_STATUS_NULL = 0
 undefined definition status
 
const DEFINITION_STATUS_READY = 20
 the form was marked as ready for actual usage
 
const DISPLAY_EDIT_FROZEN = 2
 Rubric display mode: Preview the rubric design with hidden fields.
 
const DISPLAY_EDIT_FULL = 1
 Rubric display mode: For editing (moderator or teacher creates a rubric)
 
const DISPLAY_EVAL = 4
 Rubric display mode: For evaluation, enabled (teacher grades a student)
 
const DISPLAY_EVAL_FROZEN = 5
 Rubric display mode: For evaluation, with hidden fields.
 
const DISPLAY_PREVIEW = 3
 Rubric display mode: Preview the rubric design (for person with manage permission)
 
const DISPLAY_PREVIEW_GRADED = 8
 Rubric display mode: Preview the rubric (for people being graded)
 
const DISPLAY_REVIEW = 6
 Rubric display mode: Teacher reviews filled rubric.
 
const DISPLAY_VIEW = 7
 Rubric display mode: Dispaly filled rubric (i.e.
 

Protected Member Functions

 delete_plugin_definition ()
 Deletes the rubric definition and all the associated information.
 
 get_instance ($instance)
 Returns the object of type gradingform_XXX_instance (where XXX is the plugin method name)
 
 get_method_name ()
 Returns the name of the grading method plugin, eg 'rubric'.
 
 load_definition ()
 Loads the rubric form definition if it exists.
 

Protected Attributes

string $area
 the name of the gradable area
 
int $areaid
 the id of the gradable area record
 
string $component
 the frankenstyle name of the component
 
stdClass $context
 the context
 
stdClass false $definition = false
 the definition structure
 
boolean null $hasactiveinstances = null
 cached result of function has_active_instances()
 

Detailed Description

This controller encapsulates the rubric grading logic.

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

Member Function Documentation

◆ create_instance()

gradingform_controller::create_instance ( $raterid,
$itemid = null )
inherited

This function is invoked when user (teacher) starts grading.

It creates and returns copy of the current ACTIVE instance if it exists. If this is the first grading attempt, a new instance is created. The status of the returned instance is INCOMPLETE

Parameters
int$raterid
int$itemid
Return values
gradingform_instance

◆ delete_definition()

gradingform_controller::delete_definition ( )
inherited

Deletes the form definition and all the associated data.

See also
delete_plugin_definition()
Return values
void

◆ delete_plugin_definition()

gradingform_rubric_controller::delete_plugin_definition ( )
protected

Deletes the rubric definition and all the associated information.

Reimplemented from gradingform_controller.

◆ description_form_field_options()

static gradingform_rubric_controller::description_form_field_options ( $context)
static

Options for displaying the rubric description field in the form.

Parameters
object$context
Return values
arrayoptions for the form description field

◆ extend_navigation()

gradingform_rubric_controller::extend_navigation ( global_navigation $navigation,
navigation_node $node = null )

Extends the module navigation.

This function is called when the context for the page is an activity module with the FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.

Parameters
global_navigation$navigationglobal_navigation
navigation_node$nodenavigation_node

Reimplemented from gradingform_controller.

◆ extend_settings_navigation()

gradingform_rubric_controller::extend_settings_navigation ( settings_navigation $settingsnav,
navigation_node $node = null )

Extends the module settings navigation with the rubric grading settings.

This function is called when the context for the page is an activity module with the FEATURE_ADVANCED_GRADING, the user has the permission moodle/grade:managegradingforms and there is an area with the active grading method set to 'rubric'.

Parameters
settings_navigation$settingsnavsettings_navigation
navigation_node$nodenavigation_node

Reimplemented from gradingform_controller.

◆ fetch_instance()

gradingform_controller::fetch_instance ( int $raterid,
int $itemid,
?int $instanceid )
inherited

If an instanceid is specified and grading instance exists and it is created by this rater for this item, then the instance is returned.

If instanceid is not known, then null can be passed to fetch the current instance matchign the specified raterid and itemid.

If the instanceid is falsey, or no instance was found, then create a new instance for the specified rater and item.

Parameters
int$raterid
int$itemid
int$instanceid
Return values
gradingform_instance
Exceptions
dml_exception

◆ form_unavailable_notification()

gradingform_controller::form_unavailable_notification ( )
inherited

Returns a message why this form is unavailable.

Maybe overriden by plugins to give more details.

See also
is_form_available()
Return values
string

◆ get_active_instances()

gradingform_controller::get_active_instances ( $itemid)
inherited

Returns list of ACTIVE instances for the specified $itemid (intentionally does not return instances with status NEEDUPDATE)

Parameters
int$itemid
Return values
arrayof gradingform_instance objects

◆ get_all_active_instances()

gradingform_controller::get_all_active_instances ( $since = 0)
inherited

Returns an array of all active instances for this definition.

(intentionally does not return instances with status NEEDUPDATE)

Parameters
intsince only return instances with timemodified >= since
Return values
arrayof gradingform_instance objects

◆ get_allow_grade_decimals()

gradingform_controller::get_allow_grade_decimals ( )
finalinherited

Returns if decimal values are allowed as grades.

Return values
bool

◆ get_area()

gradingform_controller::get_area ( )
inherited

Returns gradable area name.

Return values
stringgradable area name

◆ get_areaid()

gradingform_controller::get_areaid ( )
inherited

Returns gradable area id.

Return values
intgradable area id

◆ get_component()

gradingform_controller::get_component ( )
inherited

Returns gradable component name.

Return values
stringgradable component name

◆ get_context()

gradingform_controller::get_context ( )
inherited

Returns controller context.

Return values
stdClasscontroller context

◆ get_current_instance()

gradingform_controller::get_current_instance ( $raterid,
$itemid,
$idonly = false )
inherited

Returns the current instance (either with status ACTIVE or NEEDUPDATE) for this definition for the specified $raterid and $itemid (if multiple raters are allowed, or only for $itemid otherwise).

Parameters
int$raterid
int$itemid
boolean$idonly
Return values
mixedif $idonly=true returns id of the found instance, otherwise returns the instance object

◆ get_default_options()

static gradingform_rubric_controller::get_default_options ( )
static

Returns the default options for the rubric display.

Return values
array

◆ get_definition()

gradingform_controller::get_definition ( $force = false)
inherited

Returns the grading form definition structure.

Parameters
boolean$forcewhether to force loading from DB even if it was already loaded
Return values
stdClass|falsedefinition data or false if the form is not defined yet

◆ get_definition_copy()

gradingform_rubric_controller::get_definition_copy ( gradingform_controller $target)

Returns the form definition suitable for cloning into another area.

See also
parent\get_definition_copy()
Parameters
gradingform_controller$targetthe controller of the new copy
Return values
stdClassdefinition structure to pass to the target's update_definition()

Reimplemented from gradingform_controller.

◆ get_definition_for_editing()

gradingform_rubric_controller::get_definition_for_editing ( $addemptycriterion = false)

Converts the current definition into an object suitable for the editor form's set_data()

Parameters
boolean$addemptycriterionwhether to add an empty criterion if the rubric is completely empty (just being created)
Return values
stdClass

◆ get_editor_url()

gradingform_controller::get_editor_url ( moodle_url $returnurl = null)
inherited

Returns URL of a page where the grading form can be defined and edited.

Parameters
moodle_url$returnurloptional URL of a page where the user should be sent once they are finished with editing
Return values
moodle_url

◆ get_external_definition_details()

static gradingform_rubric_controller::get_external_definition_details ( )
static
Return values
arrayAn array containing a single key/value pair with the 'rubric_criteria' external_multiple_structure.
See also
gradingform_controller\get_external_definition_details()
Since
Moodle 2.5

Reimplemented from gradingform_controller.

◆ get_external_instance_filling_details()

static gradingform_rubric_controller::get_external_instance_filling_details ( )
static

Returns an array that defines the structure of the rubric's filling.

This function is used by the web service function core_grading_external\get_gradingform_instances().

Return values
Anarray containing a single key/value pair with the 'criteria' external_multiple_structure
See also
gradingform_controller\get_external_instance_filling_details()
Since
Moodle 2.6

Reimplemented from gradingform_controller.

◆ get_formatted_description()

gradingform_rubric_controller::get_formatted_description ( )

Formats the definition description for display on page.

Return values
string

Reimplemented from gradingform_controller.

◆ get_grade_range()

gradingform_controller::get_grade_range ( )
finalinherited

Returns the range of grades used in this area.

Return values
array

◆ get_instance()

gradingform_controller::get_instance ( $instance)
protectedinherited

Returns the object of type gradingform_XXX_instance (where XXX is the plugin method name)

Parameters
mixed$instanceid or row from grading_isntances table
Return values
gradingform_instance

◆ get_method_name()

gradingform_controller::get_method_name ( )
protectedinherited

Returns the name of the grading method plugin, eg 'rubric'.

Return values
stringthe name of the grading method plugin, eg 'rubric'
See also
PARAM_PLUGIN

◆ get_min_max_score()

gradingform_rubric_controller::get_min_max_score ( )

Calculates and returns the possible minimum and maximum score (in points) for this rubric.

Return values
array

◆ get_options()

gradingform_rubric_controller::get_options ( )

Gets the options of this rubric definition, fills the missing options with default values.

The only exception is 'lockzeropoints' - if other options are present in the json string but this one is absent, this means that the rubric was created before Moodle 3.2 and the 0 value should be used.

Return values
array

◆ get_or_create_instance()

gradingform_rubric_controller::get_or_create_instance ( $instanceid,
$raterid,
$itemid )

If instanceid is specified and grading instance exists and it is created by this rater for this item, this instance is returned.

If there exists a draft for this raterid+itemid, take this draft (this is the change from parent) Otherwise new instance is created for the specified rater and itemid

Parameters
int$instanceid
int$raterid
int$itemid
Return values
gradingform_instance

Reimplemented from gradingform_controller.

◆ get_renderer()

gradingform_rubric_controller::get_renderer ( moodle_page $page)

Returns the rubric plugin renderer.

Parameters
moodle_page$pagethe target page
Return values
gradingform_rubric_renderer

◆ has_active_instances()

gradingform_controller::has_active_instances ( )
inherited

Returns true if there are already people who has been graded on this definition.

In this case plugins may restrict changes of the grading definition

Return values
boolean

◆ is_form_available()

gradingform_controller::is_form_available ( )
inherited

Is the grading form defined and ready for usage?

Return values
boolean

◆ is_form_defined()

gradingform_controller::is_form_defined ( )
inherited

Is the form definition record available?

Note that this actually checks whether the process of defining the form ever started and not whether the form definition should be considered as final.

Return values
boolean

◆ is_own_form()

gradingform_controller::is_own_form ( $userid = null)
inherited

Is the grading form owned by the given user?

The form owner is the user who created this instance of the form.

Parameters
int$useridthe user id to check, defaults to the current user
Return values
boolean|nullnull if the form not defined yet, boolean otherwise

◆ is_shared_template()

gradingform_controller::is_shared_template ( )
inherited

Is the grading form saved as a shared public template?

Return values
boolean

◆ load_definition()

gradingform_rubric_controller::load_definition ( )
protected

Loads the rubric form definition if it exists.

There is a new array called 'rubric_criteria' appended to the list of parent's definition properties.

Reimplemented from gradingform_controller.

◆ render_grade()

gradingform_rubric_controller::render_grade ( $page,
$itemid,
$gradinginfo,
$defaultcontent,
$cangrade )

Returns html code to be included in student's feedback.

Parameters
moodle_page$page
int$itemid
array$gradinginforesult of function grade_get_grades
string$defaultcontentdefault string to be returned if no active grading is found
boolean$cangradewhether current user has capability to grade in this context
Return values
string

Reimplemented from gradingform_controller.

◆ render_preview()

gradingform_rubric_controller::render_preview ( moodle_page $page)

Returns the HTML code displaying the preview of the grading form.

Parameters
moodle_page$pagethe target page
Return values
string

Reimplemented from gradingform_controller.

◆ set_grade_range()

gradingform_controller::set_grade_range ( array $graderange,
$allowgradedecimals = false )
finalinherited

Sets the range of grades used in this area.

This is usually either range like 0-100 or the scale where keys start from 1.

Typically modules will call it: $controller->set_grade_range(make_grades_menu($gradingtype), $gradingtype > 0); Negative $gradingtype means that scale is used and the grade must be rounded to the nearest int. Positive $gradingtype means that range 0..$gradingtype is used for the grades and in this case grade does not have to be rounded.

Sometimes modules always expect grade to be rounded (like mod_assign does).

Parameters
array$graderangearray where first key is the minimum grade and the last key is the maximum grade.
bool$allowgradedecimalsif decimal values are allowed as grades.

◆ sql_search_from_tables()

static gradingform_rubric_controller::sql_search_from_tables ( $gdid)
static

Prepare the part of the search query to append to the FROM statement.

Parameters
string$gdidthe alias of grading_definitions.id column used by the caller
Return values
string

Reimplemented from gradingform_controller.

◆ sql_search_where()

static gradingform_rubric_controller::sql_search_where ( $token)
static

Prepare the parts of the SQL WHERE statement to search for the given token.

The returned array cosists of the list of SQL comparions and the list of respective parameters for the comparisons. The returned chunks will be joined with other conditions using the OR operator.

Parameters
string$tokentoken to search for
Return values
array

Reimplemented from gradingform_controller.

◆ update_definition()

gradingform_rubric_controller::update_definition ( stdClass $newdefinition,
$usermodified = null )

Saves the rubric definition into the database.

See also
parent\update_definition()
Parameters
stdClass$newdefinitionrubric definition data as coming from gradingform_rubric_editrubric\get_data()
int | null$usermodifiedoptional userid of the author of the definition, defaults to the current user

Reimplemented from gradingform_controller.

◆ update_or_check_rubric()

gradingform_rubric_controller::update_or_check_rubric ( stdClass $newdefinition,
$usermodified = null,
$doupdate = false )

Either saves the rubric definition into the database or check if it has been changed.

Returns the level of changes: 0 - no changes 1 - only texts or criteria sortorders are changed, students probably do not require re-grading 2 - added levels but maximum score on rubric is the same, students still may not require re-grading 3 - removed criteria or added levels or changed number of points, students require re-grading but may be re-graded automatically 4 - removed levels - students require re-grading and not all students may be re-graded automatically 5 - added criteria - all students require manual re-grading

Parameters
stdClass$newdefinitionrubric definition data as coming from gradingform_rubric_editrubric\get_data()
int | null$usermodifiedoptional userid of the author of the definition, defaults to the current user
boolean$doupdateif true actually updates DB, otherwise performs a check

Member Data Documentation

◆ DISPLAY_VIEW

const gradingform_rubric_controller::DISPLAY_VIEW = 7

Rubric display mode: Dispaly filled rubric (i.e.

students see their grades)


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