Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mod_forum\grades\forum_gradeitem Class Reference

Grade item storage for mod_forum. More...

Inheritance diagram for mod_forum\grades\forum_gradeitem:
core_grades\component_gradeitem

Public Member Functions

 check_grade_validity (?float $grade)
 Check whether the supplied grade is valid and throw an exception if not. More...
 
 create_empty_grade (stdClass $gradeduser, stdClass $grader)
 Create an empty forum_grade for the specified user and grader. More...
 
 get_advanced_grading_instance (stdClass $grader, stdClass $grade, int $instanceid=null)
 Get the advanced grading instance for the specified grade entry. More...
 
 get_advanced_grading_method ()
 Get the name of the advanced grading method. More...
 
 get_all_grades ()
 Get grades for all users for the specified gradeitem. More...
 
 get_grade (int $gradeid)
 Get the grade record for the specified grade id. More...
 
 get_grade_for_user (stdClass $gradeduser, stdClass $grader=null)
 Get the grade for the specified user. More...
 
 get_grade_instance_id ()
 Get the grade item instance id. More...
 
 get_grade_item ()
 Get the core grade item from the current component grade item. More...
 
 get_grade_itemid ()
 Get the itemid for the current gradeitem. More...
 
 get_grade_menu ()
 Get the list of available grade items. More...
 
 get_grading_component_name ()
 Get the name of the component responsible for grading this gradeitem. More...
 
 get_grading_component_subtype ()
 Get the name of the component subtype responsible for grading this gradeitem. More...
 
 is_grading_enabled ()
 Whether grading is enabled for this item. More...
 
 is_using_advanced_grading ()
 Whether this grade item is configured to use advanced grading. More...
 
 is_using_direct_grading ()
 Whether this grade item is configured to use direct grading. More...
 
 is_using_scale ()
 Check whether a scale is being used for this grade item. More...
 
 require_user_can_grade (stdClass $gradeduser, stdClass $grader)
 Require that the user can grade, throwing an exception if not. More...
 
 send_student_notification (stdClass $gradeduser, stdClass $grader)
 Sends a notification about the item being graded for the student. More...
 
 store_grade_from_formdata (stdClass $gradeduser, stdClass $grader, stdClass $formdata)
 Create or update the grade. More...
 
 user_can_grade (stdClass $gradeduser, stdClass $grader)
 Whether the grader can grade the gradee. More...
 
 user_has_grade (stdClass $gradeduser)
 Get the grade status for the specified user. More...
 

Static Public Member Functions

static instance (string $component, context $context, string $itemname)
 Fetch an instance of a specific component_gradeitem. More...
 
static load_from_context (context $context)
 Return an instance based on the context in which it is used. More...
 
static load_from_forum_entity (forum_entity $forum)
 Return an instance using the forum_entity instance. More...
 

Protected Member Functions

 allow_decimals ()
 Whether decimals are allowed. More...
 
 get_advanced_grading_controller ()
 Get the advanced grading controller if advanced grading is enabled. More...
 
 get_gradeitem_value ()
 Get the grade value for this instance. More...
 
 get_grading_manager ()
 Get the grading manager for this advanced grading definition. More...
 
 get_scale ()
 Get the scale if a scale is being used. More...
 
 get_table_name ()
 The table name used for grading. More...
 
 store_grade (stdClass $grade)
 Create or update the grade. More...
 

Protected Attributes

string $component
 The component.
 
context $context
 The context for this activity.
 
forum_entity $forum
 The forum entity being graded.
 
string $itemname
 The item name.
 
int $itemnumber
 The grade itemnumber.
 
array $scale
 The scale data for the current grade item.
 

Detailed Description

Grade item storage for mod_forum.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ allow_decimals()

core_grades\component_gradeitem::allow_decimals ( )
protectedinherited

Whether decimals are allowed.

Return values
bool

◆ check_grade_validity()

core_grades\component_gradeitem::check_grade_validity ( ?float  $grade)
inherited

Check whether the supplied grade is valid and throw an exception if not.

Parameters
float$gradeThe value being checked
Exceptions
moodle_exception
Return values
bool

◆ create_empty_grade()

mod_forum\grades\forum_gradeitem::create_empty_grade ( stdClass  $gradeduser,
stdClass  $grader 
)

Create an empty forum_grade for the specified user and grader.

Parameters
stdClass$gradeduserThe user being graded
stdClass$graderThe user who is grading
Return values
stdClassThe newly created grade record
Exceptions
dml_exception

Reimplemented from core_grades\component_gradeitem.

◆ get_advanced_grading_controller()

core_grades\component_gradeitem::get_advanced_grading_controller ( )
protectedinherited

Get the advanced grading controller if advanced grading is enabled.

Return values
gradingform_controller

◆ get_advanced_grading_instance()

core_grades\component_gradeitem::get_advanced_grading_instance ( stdClass  $grader,
stdClass  $grade,
int  $instanceid = null 
)
inherited

Get the advanced grading instance for the specified grade entry.

Parameters
stdClass$graderThe user who is grading
stdClass$gradeThe row from the grade table.
int$instanceidThe instanceid of the advanced grading form
Return values
gradingform_instance

◆ get_advanced_grading_method()

core_grades\component_gradeitem::get_advanced_grading_method ( )
inherited

Get the name of the advanced grading method.

Return values
string

◆ get_all_grades()

mod_forum\grades\forum_gradeitem::get_all_grades ( )

Get grades for all users for the specified gradeitem.

Return values
stdClass[]The grades
Exceptions
dml_exception

Reimplemented from core_grades\component_gradeitem.

◆ get_grade()

core_grades\component_gradeitem::get_grade ( int  $gradeid)
inherited

Get the grade record for the specified grade id.

Parameters
int$gradeid
Return values
stdClass
Exceptions
dml_exception

◆ get_grade_for_user()

mod_forum\grades\forum_gradeitem::get_grade_for_user ( stdClass  $gradeduser,
stdClass  $grader = null 
)

Get the grade for the specified user.

Parameters
stdClass$gradeduserThe user being graded
stdClass$graderThe user who is grading
Return values
stdClassThe grade value
Exceptions
dml_exception

Reimplemented from core_grades\component_gradeitem.

◆ get_grade_instance_id()

mod_forum\grades\forum_gradeitem::get_grade_instance_id ( )

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 values
int

Reimplemented from core_grades\component_gradeitem.

◆ get_grade_item()

core_grades\component_gradeitem::get_grade_item ( )
inherited

Get the core grade item from the current component grade item.

This is mainly used to access the max grade for a gradeitem

Return values
grade_itemThe grade item

◆ get_grade_itemid()

core_grades\component_gradeitem::get_grade_itemid ( )
inherited

Get the itemid for the current gradeitem.

Return values
int

◆ get_grade_menu()

core_grades\component_gradeitem::get_grade_menu ( )
inherited

Get the list of available grade items.

Return values
array

◆ get_gradeitem_value()

mod_forum\grades\forum_gradeitem::get_gradeitem_value ( )
protected

Get the grade value for this instance.

The itemname is translated to the relevant grade field on the forum entity.

Return values
int

Reimplemented from core_grades\component_gradeitem.

◆ get_grading_component_name()

core_grades\component_gradeitem::get_grading_component_name ( )
inherited

Get the name of the component responsible for grading this gradeitem.

Return values
string

◆ get_grading_component_subtype()

core_grades\component_gradeitem::get_grading_component_subtype ( )
inherited

Get the name of the component subtype responsible for grading this gradeitem.

Return values
string

◆ get_grading_manager()

core_grades\component_gradeitem::get_grading_manager ( )
protectedinherited

Get the grading manager for this advanced grading definition.

Return values
grading_manager

◆ get_scale()

core_grades\component_gradeitem::get_scale ( )
protectedinherited

Get the scale if a scale is being used.

Return values
stdClass

◆ get_table_name()

mod_forum\grades\forum_gradeitem::get_table_name ( )
protected

The table name used for grading.

Return values
string

Reimplemented from core_grades\component_gradeitem.

◆ instance()

static core_grades\component_gradeitem::instance ( string  $component,
context  $context,
string  $itemname 
)
staticinherited

Fetch an instance of a specific component_gradeitem.

Parameters
string$component
context$context
string$itemname
Return values
self

◆ is_grading_enabled()

mod_forum\grades\forum_gradeitem::is_grading_enabled ( )

Whether grading is enabled for this item.

Return values
bool

Reimplemented from core_grades\component_gradeitem.

◆ is_using_advanced_grading()

core_grades\component_gradeitem::is_using_advanced_grading ( )
inherited

Whether this grade item is configured to use advanced grading.

Return values
bool

◆ is_using_direct_grading()

core_grades\component_gradeitem::is_using_direct_grading ( )
inherited

Whether this grade item is configured to use direct grading.

Return values
bool

◆ is_using_scale()

core_grades\component_gradeitem::is_using_scale ( )
inherited

Check whether a scale is being used for this grade item.

Return values
bool

◆ load_from_context()

static mod_forum\grades\forum_gradeitem::load_from_context ( context  $context)
static

Return an instance based on the context in which it is used.

Parameters
context$context

Reimplemented from core_grades\component_gradeitem.

◆ load_from_forum_entity()

static mod_forum\grades\forum_gradeitem::load_from_forum_entity ( forum_entity  $forum)
static

Return an instance using the forum_entity instance.

Parameters
forum_entity$forum
Return values
forum_gradeitem

◆ require_user_can_grade()

mod_forum\grades\forum_gradeitem::require_user_can_grade ( stdClass  $gradeduser,
stdClass  $grader 
)

Require that the user can grade, throwing an exception if not.

Parameters
stdClass$gradeduserThe user being graded
stdClass$graderThe user who is grading
Exceptions
required_capability_exception

Reimplemented from core_grades\component_gradeitem.

◆ send_student_notification()

core_grades\component_gradeitem::send_student_notification ( stdClass  $gradeduser,
stdClass  $grader 
)
inherited

Sends a notification about the item being graded for the student.

Parameters
stdClass$gradeduserThe user being graded
stdClass$graderThe user who is grading

◆ store_grade()

mod_forum\grades\forum_gradeitem::store_grade ( stdClass  $grade)
protected

Create or update the grade.

Parameters
stdClass$grade
Return values
boolSuccess
Exceptions
dml_exception
moodle_exception
coding_exception

Reimplemented from core_grades\component_gradeitem.

◆ store_grade_from_formdata()

core_grades\component_gradeitem::store_grade_from_formdata ( stdClass  $gradeduser,
stdClass  $grader,
stdClass  $formdata 
)
inherited

Create or update the grade.

Parameters
stdClass$gradeduserThe user being graded
stdClass$graderThe user who is grading
stdClass$formdataThe data submitted
Return values
boolSuccess

◆ user_can_grade()

mod_forum\grades\forum_gradeitem::user_can_grade ( stdClass  $gradeduser,
stdClass  $grader 
)

Whether the grader can grade the gradee.

Parameters
stdClass$gradeduserThe user being graded
stdClass$graderThe user who is grading
Return values
bool

Reimplemented from core_grades\component_gradeitem.

◆ user_has_grade()

mod_forum\grades\forum_gradeitem::user_has_grade ( stdClass  $gradeduser)

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.

Parameters
stdClass$gradeduserThe user being graded
Return values
boolThe grade exists
Exceptions
dml_exception

Reimplemented from core_grades\component_gradeitem.


The documentation for this class was generated from the following file: