Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
grade_grades is an object mapped to DB table {prefix}grade_grades More...
Public Member Functions | |
can_control_visibility () | |
Returns whether the grade object can control the visibility of the grades. | |
delete ($source=null) | |
Deletes the grade_grade instance from the database. | |
get_aggregation_hint () | |
Get some useful information about how this grade_grade is reflected in the aggregation for the grade_category. | |
get_aggregationstatus () | |
Returns the info on how this value was used in the aggregated grade. | |
get_aggregationweight () | |
Returns the weight this grade contributed to the aggregated grade. | |
get_context () | |
Determine the correct context for this grade_grade. | |
get_dategraded () | |
Returns timestamp when last graded, null if no grade present. | |
get_datesubmitted () | |
Returns timestamp of submission related to this grade, null if not submitted. | |
get_grade_max () | |
Returns the maximum number of points this grade is graded with respect to. | |
get_grade_min () | |
Returns the minimum number of points this grade is graded with. | |
get_hidden () | |
Check grade hidden status. | |
get_locktime () | |
Get the locktime for this grade. | |
get_record_data () | |
Returns object with fields and values that are defined in database. | |
insert ($source=null, $isbulkupdate=false) | |
Records this object in the Database, sets its id to the returned value, and returns that value. | |
is_editable () | |
Is grading object editable? | |
is_excluded () | |
Checks if grade excluded from aggregation functions. | |
is_hidden () | |
Check grade hidden status. | |
is_hiddenuntil () | |
Check grade hidden status. | |
is_locked () | |
Check grade lock status. | |
is_overridden () | |
Checks if grade overridden. | |
is_passed ($grade_item=null) | |
Returns true if the grade's value is superior or equal to the grade item's gradepass value, false otherwise. | |
load_grade_item () | |
Loads the grade_item object referenced by $this->itemid and saves it as $this->grade_item for easy access. | |
load_optional_fields () | |
Makes sure all the optional fields are loaded. | |
set_aggregationstatus ($aggregationstatus) | |
Set aggregationstatus flag. | |
set_aggregationweight ($aggregationweight) | |
Set aggregationweight. | |
set_excluded ($state) | |
Set the excluded status of grade. | |
set_hidden ($hidden, $cascade=false) | |
Set the hidden status of grade, 0 mean visible, 1 always hidden, number means date to hide until. | |
set_locked ($lockedstate, $cascade=false, $refresh=true) | |
Lock/unlock this grade. | |
set_locktime ($locktime) | |
Set the locktime for this grade. | |
set_overridden ($state, $refresh=true) | |
Set the overridden status of grade. | |
update ($source=null, $isbulkupdate=false) | |
In addition to update() as defined in grade_object rounds the float numbers using php function, the reason is we need to compare the db value with computed number to skip updates if possible. | |
update_from_db () | |
Using this object's id field, fetches the matching record in the DB, and looks at each variable in turn. | |
Static Public Member Functions | |
static | check_locktime_all ($items) |
Lock the grade if needed. | |
static | fetch ($params) |
Finds and returns a grade_grade instance based on params. | |
static | fetch_all ($params) |
Finds and returns all grade_grade instances based on params. | |
static | fetch_all_helper ($table, $classname, $params) |
Factory method which uses the parameters to retrieve all matching instances from the database. | |
static | fetch_users_grades ($grade_item, $userids, $include_missing=true) |
Returns array of grades for given grade_item+users. | |
static | get_hiding_affected (&$grade_grades, &$grade_items) |
Return array of grade item ids that are either hidden or indirectly depend on hidden grades, excluded grades are not returned. | |
static | set_properties (&$instance, $params) |
Given an associated array or object, cycles through each key/variable and assigns the value to the corresponding variable in this object. | |
static | standardise_score ($rawgrade, $source_min, $source_max, $target_min, $target_max) |
Given a float value situated between a source minimum and a source maximum, converts it to the corresponding value situated between a target minimum and a target maximum. | |
Public Attributes | |
string | $aggregationstatus = 'unknown' |
Aggregation status flag. | |
float | $aggregationweight = null |
Aggregation weight is the specific weight used in the aggregation calculation for this grade. | |
bool | $excluded = 0 |
Grade excluded from aggregation functions $excluded. | |
bool | $exported = 0 |
Exported flag $exported. | |
string | $feedback |
Feedback content. | |
array | $feedbackfiles = [] |
Feedback files to copy. | |
int | $feedbackformat = FORMAT_PLAIN |
Feedback format. | |
float | $finalgrade |
The final value of this grade. | |
grade_item | $grade_item |
The grade_item object referenced by $this->itemid. | |
float | $hidden = 0 |
0 if visible, 1 always hidden or date not visible until $hidden | |
int | $id |
The PK. | |
string | $information |
Information text. | |
int | $informationformat = FORMAT_PLAIN |
Information text format. | |
int | $itemid |
The id of the grade_item this grade belongs to. | |
string | $label |
label text. | |
float | $locked = 0 |
0 not locked, date when the item was locked locked | |
float | $locktime = 0 |
0 no automatic locking, date when to lock the grade automatically $locktime | |
array | $optional_fields = array('feedback'=>null, 'feedbackformat'=>0, 'information'=>null, 'informationformat'=>0) |
Array of optional fields with default values (these should match db defaults) $optional_fields. | |
bool | $overridden = 0 |
Overridden flag $overridden. | |
float | $rawgrade |
The grade value of this raw grade, if such was provided by the module. | |
float | $rawgrademax = 100 |
The maximum allowable grade when this grade was created. | |
float | $rawgrademin = 0 |
The minimum allowable grade when this grade was created. | |
int | $rawscaleid |
id of the scale, if this grade is based on a scale. | |
array | $required_fields |
Array of required table fields, must start with 'id'. | |
string | $table = 'grade_grades' |
The DB table. | |
bool | $timecreated = null |
TODO: HACK: create a new field datesubmitted - the date of submission if any (MDL-31377) $timecreated. | |
bool | $timemodified = null |
TODO: HACK: create a new field dategraded - the date of grading (MDL-31378) $timemodified. | |
int | $userid |
The id of the user this grade belongs to. | |
int | $usermodified |
The userid of the person who last modified this grade. | |
Protected Member Functions | |
add_feedback_files (int $historyid=null) | |
Handles adding feedback files in the gradebook. | |
delete_feedback_files () | |
Handles deleting feedback files in the gradebook. | |
get_grade_min_and_max () | |
Returns the minimum and maximum number of points this grade is graded with respect to. | |
notify_changed ($deleted, $isbulkupdate=false) | |
Used to notify the completion system (if necessary) that a user's grade has changed, and clear up a possible score cache. | |
notify_changed ($deleted) | |
Called immediately after the object data has been inserted, updated, or deleted in the database. | |
update_feedback_files (int $historyid=null) | |
Handles updating feedback files in the gradebook. | |
Static Protected Member Functions | |
static | fetch_helper ($table, $classname, $params) |
Factory method which uses the parameters to retrieve matching instances from the database. | |
static | flatten_dependencies_array (&$dependson, &$dependencydepth) |
Given an array like this: $a = array(1=>array(2, 3), 2=>array(4), 3=>array(1), 4=>array()) this function fully resolves the dependencies so each value will be an array of the all items this item depends on and their dependencies (and their dependencies...). | |
grade_grades is an object mapped to DB table {prefix}grade_grades
|
protected |
Handles adding feedback files in the gradebook.
int | null | $historyid |
Reimplemented from grade_object.
|
inherited |
Returns whether the grade object can control the visibility of the grades.
bool |
Reimplemented in grade_item.
|
static |
Lock the grade if needed.
Make sure this is called only when final grades are valid
array | $items | array of all grade item ids |
void |
grade_grade::delete | ( | $source = null | ) |
Deletes the grade_grade instance from the database.
string | $source | The location the deletion occurred (mod/forum, manual, etc.). |
bool | Returns true if the deletion was successful, false otherwise. |
Reimplemented from grade_object.
|
protected |
Handles deleting feedback files in the gradebook.
Reimplemented from grade_object.
|
static |
Finds and returns a grade_grade instance based on params.
array | $params | associative arrays varname=>value |
grade_grade | Returns a grade_grade instance or false if none found |
Reimplemented from grade_object.
|
static |
Finds and returns all grade_grade instances based on params.
array | $params | associative arrays varname=>value |
array | array of grade_grade instances or false if none found. |
Reimplemented from grade_object.
|
staticinherited |
Factory method which uses the parameters to retrieve all matching instances from the database.
string | $table | The table to retrieve from |
string | $classname | The name of the class to instantiate |
array | $params | An array of conditions like $fieldname => $fieldvalue |
array|bool | Array of object instances or false if not found |
|
staticprotectedinherited |
Factory method which uses the parameters to retrieve matching instances from the database.
string | $table | The table to retrieve from |
string | $classname | The name of the class to instantiate |
array | $params | An array of conditions like $fieldname => $fieldvalue |
mixed | An object instance or false if not found |
|
static |
Returns array of grades for given grade_item+users.
grade_item | $grade_item | |
array | $userids | |
bool | $include_missing | include grades that do not exist yet |
array | userid=>grade_grade array |
|
staticprotected |
Given an array like this: $a = array(1=>array(2, 3), 2=>array(4), 3=>array(1), 4=>array()) this function fully resolves the dependencies so each value will be an array of the all items this item depends on and their dependencies (and their dependencies...).
It should not explode if there are circular dependencies. The dependency depth array will list the number of branches in the tree above each leaf.
array | $dependson | Array to flatten |
array | $dependencydepth | Array of itemids => depth. Initially these should be all set to 1. |
array | Flattened array |
grade_grade::get_aggregation_hint | ( | ) |
Get some useful information about how this grade_grade is reflected in the aggregation for the grade_category.
For example this could be an extra credit item, and it could be dropped because it's in the X lowest or highest.
array(status,weight) | - A keyword and a numerical weight that represents how this grade was included in the aggregation. |
grade_grade::get_aggregationstatus | ( | ) |
Returns the info on how this value was used in the aggregated grade.
string | One of 'dropped', 'excluded', 'novalue', 'used' or 'extra' |
grade_grade::get_aggregationweight | ( | ) |
Returns the weight this grade contributed to the aggregated grade.
float|null |
grade_grade::get_context | ( | ) |
Determine the correct context for this grade_grade.
context |
grade_grade::get_dategraded | ( | ) |
Returns timestamp when last graded, null if no grade present.
int |
grade_grade::get_datesubmitted | ( | ) |
Returns timestamp of submission related to this grade, null if not submitted.
int | Timestamp |
grade_grade::get_grade_max | ( | ) |
Returns the maximum number of points this grade is graded with respect to.
float | The maximum number of points |
grade_grade::get_grade_min | ( | ) |
Returns the minimum number of points this grade is graded with.
float | The minimum number of points |
|
protected |
Returns the minimum and maximum number of points this grade is graded with respect to.
array | A list containing, in order, the minimum and maximum number of points. |
grade_grade::get_hidden | ( | ) |
Check grade hidden status.
Uses data from both grade item and grade.
int | 0 means visible, 1 hidden always, timestamp hidden until |
Reimplemented from grade_object.
|
static |
Return array of grade item ids that are either hidden or indirectly depend on hidden grades, excluded grades are not returned.
THIS IS A REALLY BIG HACK! to be replaced by conditional aggregation of hidden grades in 2.0
array | $grade_grades | all course grades of one user, & used for better internal caching |
array | $grade_items | array of grade items, & used for better internal caching |
array | This is an array of following arrays: unknown => list of item ids that may be affected by hiding (with the ITEM ID as both the key and the value) - for BC with old gradereport plugins unknowngrades => list of item ids that may be affected by hiding (with the calculated grade as the value) altered => list of item ids that are definitely affected by hiding (with the calculated grade as the value) alteredgrademax => for each item in altered or unknown, the new value of the grademax alteredgrademin => for each item in altered or unknown, the new value of the grademin alteredgradestatus => for each item with a modified status - the value of the new status alteredgradeweight => for each item with a modified weight - the value of the new weight |
grade_grade::get_locktime | ( | ) |
Get the locktime for this grade.
int\$locktime | timestamp for lock to activate |
|
inherited |
Returns object with fields and values that are defined in database.
stdClass |
|
inherited |
Records this object in the Database, sets its id to the returned value, and returns that value.
If successful this function also fetches the new object data from database and stores it in object properties.
string | $source | From where was the object inserted (mod/forum, manual, etc.) |
string | $isbulkupdate | If bulk grade update is happening. |
int | The new grade object ID if successful, false otherwise |
Reimplemented in grade_category, grade_item, grade_outcome, and grade_scale.
grade_grade::is_editable | ( | ) |
Is grading object editable?
bool |
grade_grade::is_excluded | ( | ) |
Checks if grade excluded from aggregation functions.
bool | True if grade is excluded from aggregation |
grade_grade::is_hidden | ( | ) |
Check grade hidden status.
Uses data from both grade item and grade.
bool | true if hidden, false if not |
Reimplemented from grade_object.
grade_grade::is_hiddenuntil | ( | ) |
Check grade hidden status.
Uses data from both grade item and grade.
bool | true if hiddenuntil, false if not |
Reimplemented from grade_object.
grade_grade::is_locked | ( | ) |
Check grade lock status.
Uses both grade item lock and grade lock. Internally any date in locked field (including future ones) means locked, the date is stored for logging purposes only.
bool | True if locked, false if not |
grade_grade::is_overridden | ( | ) |
Checks if grade overridden.
bool | True if grade is overriden |
grade_grade::is_passed | ( | $grade_item = null | ) |
Returns true if the grade's value is superior or equal to the grade item's gradepass value, false otherwise.
grade_item | $grade_item | An optional grade_item of which gradepass value we can use, saves having to load the grade_grade's grade_item |
bool |
grade_grade::load_grade_item | ( | ) |
Loads the grade_item object referenced by $this->itemid and saves it as $this->grade_item for easy access.
grade_item | The grade_item instance referenced by $this->itemid |
|
inherited |
Makes sure all the optional fields are loaded.
If id present, meaning the instance exists in the database, then data will be fetched from the database. Defaults are used for new instances.
|
protected |
Used to notify the completion system (if necessary) that a user's grade has changed, and clear up a possible score cache.
bool | $deleted | True if grade was actually deleted |
bool | $isbulkupdate | If bulk grade update is happening. |
|
protectedinherited |
Called immediately after the object data has been inserted, updated, or deleted in the database.
Default does nothing, can be overridden to hook in special behaviour.
bool | $deleted |
Reimplemented in grade_category, and grade_item.
grade_grade::set_aggregationstatus | ( | $aggregationstatus | ) |
Set aggregationstatus flag.
string | $aggregationstatus |
void |
grade_grade::set_aggregationweight | ( | $aggregationweight | ) |
Set aggregationweight.
float | $aggregationweight |
void |
grade_grade::set_excluded | ( | $state | ) |
Set the excluded status of grade.
bool | $state | requested excluded state |
bool | True is database state changed |
grade_grade::set_hidden | ( | $hidden, | |
$cascade = false ) |
Set the hidden status of grade, 0 mean visible, 1 always hidden, number means date to hide until.
int | $hidden | new hidden status |
bool | $cascade | ignored |
Reimplemented from grade_object.
grade_grade::set_locked | ( | $lockedstate, | |
$cascade = false, | |||
$refresh = true ) |
Lock/unlock this grade.
int | $lockedstate | 0, 1 or a timestamp int(10) after which date the item will be locked. |
bool | $cascade | Ignored param |
bool | $refresh | Refresh grades when unlocking |
bool | True if successful, false if can not set new lock state for grade |
grade_grade::set_locktime | ( | $locktime | ) |
Set the locktime for this grade.
int | $locktime | timestamp for lock to activate |
void |
grade_grade::set_overridden | ( | $state, | |
$refresh = true ) |
Set the overridden status of grade.
bool | $state | requested overridden state |
bool | $refresh | refresh grades from external activities if needed |
bool | true is db state changed |
|
staticinherited |
Given an associated array or object, cycles through each key/variable and assigns the value to the corresponding variable in this object.
grade_object | $instance | The object to set the properties on |
array | $params | An array of properties to set like $propertyname => $propertyvalue |
array|stdClass | Either an associative array or an object containing property name, property value pairs |
Reimplemented in grade_category.
|
static |
Given a float value situated between a source minimum and a source maximum, converts it to the corresponding value situated between a target minimum and a target maximum.
Thanks to Darlene for the formula :-)
float | $rawgrade | |
float | $source_min | |
float | $source_max | |
float | $target_min | |
float | $target_max |
float | Converted value |
grade_grade::update | ( | $source = null, | |
$isbulkupdate = false ) |
In addition to update() as defined in grade_object rounds the float numbers using php function, the reason is we need to compare the db value with computed number to skip updates if possible.
string | $source | from where was the object inserted (mod/forum, manual, etc.) |
bool | $isbulkupdate | If bulk grade update is happening. |
bool | success |
Reimplemented from grade_object.
|
protected |
Handles updating feedback files in the gradebook.
int | null | $historyid |
Reimplemented from grade_object.
|
inherited |
Using this object's id field, fetches the matching record in the DB, and looks at each variable in turn.
If the DB has different data, the db's data is used to update the object. This is different from the update() function, which acts on the DB record based on the object.
bool | True if successful |
string grade_grade::$aggregationstatus = 'unknown' |
Aggregation status flag.
Can be one of 'unknown', 'dropped', 'novalue' or 'used'. $aggregationstatus
float grade_grade::$aggregationweight = null |
Aggregation weight is the specific weight used in the aggregation calculation for this grade.
$aggregationweight
string grade_grade::$feedback |
Feedback content.
$feedback
array grade_grade::$feedbackfiles = [] |
Feedback files to copy.
Example -
[ 'contextid' => 1, 'component' => 'mod_xyz', 'filearea' => 'mod_xyz_feedback', 'itemid' => 2 ];
int grade_grade::$feedbackformat = FORMAT_PLAIN |
Feedback format.
$feedbackformat
float grade_grade::$finalgrade |
The final value of this grade.
$finalgrade
grade_item grade_grade::$grade_item |
The grade_item object referenced by $this->itemid.
$grade_item
|
inherited |
The PK.
$id
string grade_grade::$information |
Information text.
$information
int grade_grade::$informationformat = FORMAT_PLAIN |
Information text format.
$informationformat
int grade_grade::$itemid |
The id of the grade_item this grade belongs to.
$itemid
string grade_grade::$label |
label text.
$label
float grade_grade::$rawgrade |
The grade value of this raw grade, if such was provided by the module.
$rawgrade
float grade_grade::$rawgrademax = 100 |
The maximum allowable grade when this grade was created.
$rawgrademax
float grade_grade::$rawgrademin = 0 |
The minimum allowable grade when this grade was created.
$rawgrademin
int grade_grade::$rawscaleid |
id of the scale, if this grade is based on a scale.
$rawscaleid
array grade_grade::$required_fields |
Array of required table fields, must start with 'id'.
$required_fields
string grade_grade::$table = 'grade_grades' |
The DB table.
$table
int grade_grade::$userid |
The id of the user this grade belongs to.
$userid
int grade_grade::$usermodified |
The userid of the person who last modified this grade.
$usermodified