Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

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
 lib/gradelib.php
 grade/grading/lib.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.

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

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.

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

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

return: stdClass
param: int $gradeid

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.

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

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.

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

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

return: gradingform_instance
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

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