Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
This controller encapsulates the rubric grading logic. More...
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. | |
This controller encapsulates the rubric grading logic.
|
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
int | $raterid | |
int | $itemid |
gradingform_instance |
|
inherited |
Deletes the form definition and all the associated data.
void |
|
protected |
Deletes the rubric definition and all the associated information.
Reimplemented from gradingform_controller.
|
static |
Options for displaying the rubric description field in the form.
object | $context |
array | options for the form description field |
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.
global_navigation | $navigation | global_navigation |
navigation_node | $node | navigation_node |
Reimplemented from gradingform_controller.
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'.
settings_navigation | $settingsnav | settings_navigation |
navigation_node | $node | navigation_node |
Reimplemented from gradingform_controller.
|
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.
int | $raterid | |
int | $itemid | |
int | $instanceid |
gradingform_instance |
dml_exception |
|
inherited |
Returns a message why this form is unavailable.
Maybe overriden by plugins to give more details.
string |
|
inherited |
Returns list of ACTIVE instances for the specified $itemid (intentionally does not return instances with status NEEDUPDATE)
int | $itemid |
array | of gradingform_instance objects |
|
inherited |
Returns an array of all active instances for this definition.
(intentionally does not return instances with status NEEDUPDATE)
int | since only return instances with timemodified >= since |
array | of gradingform_instance objects |
|
finalinherited |
Returns if decimal values are allowed as grades.
bool |
|
inherited |
Returns gradable area name.
string | gradable area name |
|
inherited |
Returns gradable area id.
int | gradable area id |
|
inherited |
Returns gradable component name.
string | gradable component name |
|
inherited |
Returns controller context.
stdClass | controller context |
|
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).
int | $raterid | |
int | $itemid | |
boolean | $idonly |
mixed | if $idonly=true returns id of the found instance, otherwise returns the instance object |
|
static |
Returns the default options for the rubric display.
array |
|
inherited |
Returns the grading form definition structure.
boolean | $force | whether to force loading from DB even if it was already loaded |
stdClass|false | definition data or false if the form is not defined yet |
gradingform_rubric_controller::get_definition_copy | ( | gradingform_controller | $target | ) |
Returns the form definition suitable for cloning into another area.
gradingform_controller | $target | the controller of the new copy |
stdClass | definition structure to pass to the target's update_definition() |
Reimplemented from gradingform_controller.
gradingform_rubric_controller::get_definition_for_editing | ( | $addemptycriterion = false | ) |
Converts the current definition into an object suitable for the editor form's set_data()
boolean | $addemptycriterion | whether to add an empty criterion if the rubric is completely empty (just being created) |
stdClass |
|
inherited |
Returns URL of a page where the grading form can be defined and edited.
moodle_url | $returnurl | optional URL of a page where the user should be sent once they are finished with editing |
moodle_url |
|
static |
array | An array containing a single key/value pair with the 'rubric_criteria' external_multiple_structure. |
Reimplemented from gradingform_controller.
|
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().
An | array containing a single key/value pair with the 'criteria' external_multiple_structure |
Reimplemented from gradingform_controller.
gradingform_rubric_controller::get_formatted_description | ( | ) |
Formats the definition description for display on page.
string |
Reimplemented from gradingform_controller.
|
finalinherited |
Returns the range of grades used in this area.
array |
|
protectedinherited |
Returns the object of type gradingform_XXX_instance (where XXX is the plugin method name)
mixed | $instance | id or row from grading_isntances table |
gradingform_instance |
|
protectedinherited |
Returns the name of the grading method plugin, eg 'rubric'.
string | the name of the grading method plugin, eg 'rubric' |
gradingform_rubric_controller::get_min_max_score | ( | ) |
Calculates and returns the possible minimum and maximum score (in points) for this rubric.
array |
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.
array |
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
int | $instanceid | |
int | $raterid | |
int | $itemid |
gradingform_instance |
Reimplemented from gradingform_controller.
gradingform_rubric_controller::get_renderer | ( | moodle_page | $page | ) |
Returns the rubric plugin renderer.
moodle_page | $page | the target page |
gradingform_rubric_renderer |
|
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
boolean |
|
inherited |
Is the grading form defined and ready for usage?
boolean |
|
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.
boolean |
|
inherited |
Is the grading form owned by the given user?
The form owner is the user who created this instance of the form.
int | $userid | the user id to check, defaults to the current user |
boolean|null | null if the form not defined yet, boolean otherwise |
|
inherited |
Is the grading form saved as a shared public template?
boolean |
|
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.
gradingform_rubric_controller::render_grade | ( | $page, | |
$itemid, | |||
$gradinginfo, | |||
$defaultcontent, | |||
$cangrade ) |
Returns html code to be included in student's feedback.
moodle_page | $page | |
int | $itemid | |
array | $gradinginfo | result of function grade_get_grades |
string | $defaultcontent | default string to be returned if no active grading is found |
boolean | $cangrade | whether current user has capability to grade in this context |
string |
Reimplemented from gradingform_controller.
gradingform_rubric_controller::render_preview | ( | moodle_page | $page | ) |
Returns the HTML code displaying the preview of the grading form.
moodle_page | $page | the target page |
string |
Reimplemented from gradingform_controller.
|
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).
array | $graderange | array where first key is the minimum grade and the last key is the maximum grade. |
bool | $allowgradedecimals | if decimal values are allowed as grades. |
|
static |
Prepare the part of the search query to append to the FROM statement.
string | $gdid | the alias of grading_definitions.id column used by the caller |
string |
Reimplemented from gradingform_controller.
|
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.
string | $token | token to search for |
array |
Reimplemented from gradingform_controller.
gradingform_rubric_controller::update_definition | ( | stdClass | $newdefinition, |
$usermodified = null ) |
Saves the rubric definition into the database.
stdClass | $newdefinition | rubric definition data as coming from gradingform_rubric_editrubric\get_data() |
int | null | $usermodified | optional userid of the author of the definition, defaults to the current user |
Reimplemented from gradingform_controller.
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
stdClass | $newdefinition | rubric definition data as coming from gradingform_rubric_editrubric\get_data() |
int | null | $usermodified | optional userid of the author of the definition, defaults to the current user |
boolean | $doupdate | if true actually updates DB, otherwise performs a check |
const gradingform_rubric_controller::DISPLAY_VIEW = 7 |
Rubric display mode: Dispaly filled rubric (i.e.
students see their grades)