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 39 and 400]

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: 294 lines (10 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.

return: forum_gradeitem
param: forum_entity $forum

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.

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

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.

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

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

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

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.

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

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

should_grade_only_active_users()   X-Ref
Defines whether only active users in the course should be gradeable.

return: bool Whether only active users in the course should be gradeable.

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

return: bool Success
param: stdClass $grade