Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
core_grades\penalty_container Class Reference

Public Member Functions

 __construct (private grade_item readonly grade_item $gradeitem, private grade_grade readonly grade_grade $gradegrade, private int readonly int $submissiondate, private int readonly int $duedate,)
 Constructor for the class.
 
 aggregate_penalty (float $penalty)
 Aggregate the number of points to deduct from the grade.
 
 get_due_date ()
 Get the due date.
 
 get_grade_after_penalties ()
 Get the penalised grade.
 
 get_grade_before_penalties ()
 Get the grade before penalties are applied.
 
 get_grade_grade ()
 Get the grade object.
 
 get_grade_item ()
 Get the grade item object.
 
 get_max_grade ()
 Get the maximum grade for the grade item.
 
 get_min_grade ()
 Get the minimum grade for the grade item.
 
 get_penalty ()
 Get the current penalty value.
 
 get_submission_date ()
 Get the submission date.
 
 get_userid ()
 Get the user id.
 

Constructor & Destructor Documentation

◆ __construct()

core_grades\penalty_container::__construct ( private grade_item readonly grade_item $gradeitem,
private grade_grade readonly grade_grade $gradegrade,
private int readonly int $submissiondate,
private int readonly int $duedate )

Constructor for the class.

Parameters
grade_item$gradeitemThe grade item object
grade_grade$gradegradeThe grade object
int$submissiondateThe date and time the submission was made
int$duedateThe date and time the activity is due
Parameters
$gradeitem$gradeitem The grade item object
$gradegrade$gradegrade The grade object
$submissiondate$submissiondate The date and time the submission was made
$duedate$duedate The date and time the activity is due

Member Function Documentation

◆ aggregate_penalty()

core_grades\penalty_container::aggregate_penalty ( float $penalty)

Aggregate the number of points to deduct from the grade.

Each penalty plugin is expected to call this method from their calculate_penalty() method.

For example, if a grade item has a maximum grade of 200 and a penalty plugin wants to deduct 10% from the maximum grade, the penalty plugin should call this method with a penalty value of 20.

Percentages must not be passed to this method. Any percentage values must be converted to points before calling this method. Penalty values cannot be negative or an exception will be thrown. After all penalty plugins have been called, the core penalty system will apply the aggregated penalty to the grade, clamping the grade between the minimum and maximum grade for the grade item.

Parameters
float$penaltyThe number of points to deduct from the grade
Exceptions
moodle_exceptionThrown if the penalty value is negative

◆ get_due_date()

core_grades\penalty_container::get_due_date ( )

Get the due date.

Return values
intThe date and time the activity is due

◆ get_grade_after_penalties()

core_grades\penalty_container::get_grade_after_penalties ( )

Get the penalised grade.

The penalised grade is clamped between the minimum and maximum grade for the grade item.

Return values
floatThe penalised grade

◆ get_grade_before_penalties()

core_grades\penalty_container::get_grade_before_penalties ( )

Get the grade before penalties are applied.

Return values
floatThe grade before penalties are applied

◆ get_grade_grade()

core_grades\penalty_container::get_grade_grade ( )

Get the grade object.

This object should not be modified.

Return values
grade_gradeThe grade object

◆ get_grade_item()

core_grades\penalty_container::get_grade_item ( )

Get the grade item object.

This object should not be modified.

Return values
grade_itemThe grade item object

◆ get_max_grade()

core_grades\penalty_container::get_max_grade ( )

Get the maximum grade for the grade item.

Return values
floatThe maximum grade for the grade item

◆ get_min_grade()

core_grades\penalty_container::get_min_grade ( )

Get the minimum grade for the grade item.

Return values
floatThe minimum grade for the grade item

◆ get_penalty()

core_grades\penalty_container::get_penalty ( )

Get the current penalty value.

Return values
floatThe number of points to deduct from the grade

◆ get_submission_date()

core_grades\penalty_container::get_submission_date ( )

Get the submission date.

Return values
intThe date and time the submission was made

◆ get_userid()

core_grades\penalty_container::get_userid ( )

Get the user id.

Return values
intThe user id

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