Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

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.

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

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.

param: stdClass $grade
return: bool Success