Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403]

Compontent definition of a gradeitem.

Copyright: Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 583 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 grade/grading/lib.php
 lib/gradelib.php

Defines 1 class


Class: component_gradeitem  - X-Ref

Compontent definition of a gradeitem.

__construct(string $component, context $context, string $itemname)   X-Ref
component_gradeitem constructor.

param: string $component
param: context $context
param: string $itemname

instance(string $component, context $context, string $itemname)   X-Ref
Fetch an instance of a specific component_gradeitem.

param: string $component
param: context $context
param: string $itemname
return: self

get_grade_itemid()   X-Ref
Get the itemid for the current gradeitem.

return: int

get_scale()   X-Ref
Get the scale if a scale is being used.

return: stdClass

is_using_scale()   X-Ref
Check whether a scale is being used for this grade item.

return: bool

is_using_direct_grading()   X-Ref
Whether this grade item is configured to use direct grading.

return: bool

is_using_advanced_grading()   X-Ref
Whether this grade item is configured to use advanced grading.

return: bool

get_advanced_grading_method()   X-Ref
Get the name of the advanced grading method.

return: string

get_grading_component_name()   X-Ref
Get the name of the component responsible for grading this gradeitem.

return: string

get_grading_component_subtype()   X-Ref
Get the name of the component subtype responsible for grading this gradeitem.

return: string

allow_decimals()   X-Ref
Whether decimals are allowed.

return: bool

get_grading_manager()   X-Ref
Get the grading manager for this advanced grading definition.

return: grading_manager

get_advanced_grading_controller()   X-Ref
Get the advanced grading controller if advanced grading is enabled.

return: gradingform_controller

get_grade_menu()   X-Ref
Get the list of available grade items.

return: array

check_grade_validity(?float $grade)   X-Ref
Check whether the supplied grade is valid and throw an exception if not.

param: float $grade The value being checked
return: bool

get_grade(int $gradeid)   X-Ref
Get the grade record for the specified grade id.

param: int $gradeid
return: stdClass

get_formatted_grade_for_user(stdClass $gradeduser, stdClass $grader)   X-Ref
Returns the grade that should be displayed to the user.

The grade does not necessarily return a float value, this method takes grade settings into considering so
the correct value be shown, eg. a float vs a letter.

param: stdClass $gradeduser
param: stdClass $grader
return: stdClass|null

get_grade_item()   X-Ref
Get the core grade item from the current component grade item.
This is mainly used to access the max grade for a gradeitem

return: \grade_item The grade item

store_grade_from_formdata(stdClass $gradeduser, stdClass $grader, stdClass $formdata)   X-Ref
Create or update the grade.

param: stdClass $gradeduser The user being graded
param: stdClass $grader The user who is grading
param: stdClass $formdata The data submitted
return: bool Success

get_advanced_grading_instance(stdClass $grader, stdClass $grade, int $instanceid = null)   X-Ref
Get the advanced grading instance for the specified grade entry.

param: stdClass $grader The user who is grading
param: stdClass $grade The row from the grade table.
param: int $instanceid The instanceid of the advanced grading form
return: gradingform_instance

send_student_notification(stdClass $gradeduser, stdClass $grader)   X-Ref
Sends a notification about the item being graded for the student.

param: stdClass $gradeduser The user being graded
param: stdClass $grader The user who is grading