Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

Grade item storage for mod_forum.

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

Defines 1 class


Class: forum_gradeitem  - X-Ref

Grade item storage for mod_forum.

load_from_context(context $context)   X-Ref
Return an instance based on the context in which it is used.

param: context $context

load_from_forum_entity(forum_entity $forum)   X-Ref
Return an instance using the forum_entity instance.

param: forum_entity $forum
return: forum_gradeitem

get_table_name()   X-Ref
The table name used for grading.

return: string

is_grading_enabled()   X-Ref
Whether grading is enabled for this item.

return: bool

user_can_grade(stdClass $gradeduser, stdClass $grader)   X-Ref
Whether the grader can grade the gradee.

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

require_user_can_grade(stdClass $gradeduser, stdClass $grader)   X-Ref
Require that the user can grade, throwing an exception if not.

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

get_gradeitem_value()   X-Ref
Get the grade value for this instance.
The itemname is translated to the relevant grade field on the forum entity.

return: int

create_empty_grade(stdClass $gradeduser, stdClass $grader)   X-Ref
Create an empty forum_grade for the specified user and grader.

param: stdClass $gradeduser The user being graded
param: stdClass $grader The user who is grading
return: stdClass The newly created grade record

get_grade_for_user(stdClass $gradeduser, stdClass $grader = null)   X-Ref
Get the grade for the specified user.

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

user_has_grade(stdClass $gradeduser)   X-Ref
Get the grade status for the specified user.
Check if a grade obj exists & $grade->grade !== null.
If the user has a grade return true.

param: stdClass $gradeduser The user being graded
return: bool The grade exists

get_all_grades()   X-Ref
Get grades for all users for the specified gradeitem.

return: stdClass[] The grades

get_grade_instance_id()   X-Ref
Get the grade item instance id.

This is typically the cmid in the case of an activity, and relates to the iteminstance field in the grade_items
table.

return: int

store_grade(stdClass $grade)   X-Ref
Create or update the grade.

param: stdClass $grade
return: bool Success