Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Public Member Functions | |
can_control_visibility () | |
Returns whether the grade object can control the visibility of the grades. More... | |
delete ($source=null) | |
Deletes the grade_grade instance from the database. More... | |
get_aggregation_hint () | |
Get some useful information about how this grade_grade is reflected in the aggregation for the grade_category. More... | |
get_aggregationstatus () | |
Returns the info on how this value was used in the aggregated grade. More... | |
get_aggregationweight () | |
Returns the weight this grade contributed to the aggregated grade. More... | |
get_context () | |
Determine the correct context for this grade_grade. More... | |
get_dategraded () | |
Returns timestamp when last graded, null if no grade present. More... | |
get_datesubmitted () | |
Returns timestamp of submission related to this grade, null if not submitted. More... | |
get_grade_max () | |
Returns the maximum number of points this grade is graded with respect to. More... | |
get_grade_min () | |
Returns the minimum number of points this grade is graded with. More... | |
get_hidden () | |
Check grade hidden status. More... | |
get_locktime () | |
Get the locktime for this grade. More... | |
get_record_data () | |
Returns object with fields and values that are defined in database. More... | |
insert ($source=null) | |
Insert the grade_grade instance into the database. More... | |
is_editable () | |
Is grading object editable? More... | |
is_excluded () | |
Checks if grade excluded from aggregation functions. More... | |
is_hidden () | |
Check grade hidden status. More... | |
is_hiddenuntil () | |
Check grade hidden status. More... | |
is_locked () | |
Check grade lock status. More... | |
is_overridden () | |
Checks if grade overridden. More... | |
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. More... | |
load_grade_item () | |
Loads the grade_item object referenced by $this->itemid and saves it as $this->grade_item for easy access. More... | |
load_optional_fields () | |
Makes sure all the optional fields are loaded. More... | |
set_aggregationstatus ($aggregationstatus) | |
Set aggregationstatus flag. More... | |
set_aggregationweight ($aggregationweight) | |
Set aggregationweight. More... | |
set_excluded ($state) | |
Set the excluded status of grade. More... | |
set_hidden ($hidden, $cascade=false) | |
Set the hidden status of grade, 0 mean visible, 1 always hidden, number means date to hide until. More... | |
set_locked ($lockedstate, $cascade=false, $refresh=true) | |
Lock/unlock this grade. More... | |
set_locktime ($locktime) | |
Set the locktime for this grade. More... | |
set_overridden ($state, $refresh=true) | |
Set the overridden status of grade. More... | |
update ($source=null) | |
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. More... | |
update_from_db () | |
Using this object's id field, fetches the matching record in the DB, and looks at each variable in turn. More... | |
Static Public Member Functions | |
static | check_locktime_all ($items) |
Lock the grade if needed. More... | |
static | fetch ($params) |
Finds and returns a grade_grade instance based on params. More... | |
static | fetch_all ($params) |
Finds and returns all grade_grade instances based on params. More... | |
static | fetch_all_helper ($table, $classname, $params) |
Factory method which uses the parameters to retrieve all matching instances from the database. More... | |
static | fetch_users_grades ($grade_item, $userids, $include_missing=true) |
Returns array of grades for given grade_item+users. More... | |
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. More... | |
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. More... | |
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. More... | |
Public Attributes | |
string | $aggregationstatus = 'unknown' |
Aggregation status flag. More... | |
float | $aggregationweight = null |
Aggregation weight is the specific weight used in the aggregation calculation for this grade. More... | |
bool | $excluded = 0 |
Grade excluded from aggregation functions $excluded. | |
bool | $exported = 0 |
Exported flag $exported. | |
array | $feedbackfiles = [] |
Feedback files to copy. More... | |
float | $finalgrade |
The final value of this grade. More... | |
grade_item | $grade_item |
The grade_item object referenced by $this->itemid. More... | |
float | $hidden = 0 |
0 if visible, 1 always hidden or date not visible until $hidden | |
int | $id |
The PK. More... | |
int | $itemid |
The id of the grade_item this grade belongs to. More... | |
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. More... | |
float | $rawgrademax = 100 |
The maximum allowable grade when this grade was created. More... | |
float | $rawgrademin = 0 |
The minimum allowable grade when this grade was created. More... | |
int | $rawscaleid |
id of the scale, if this grade is based on a scale. More... | |
array | $required_fields |
Array of required table fields, must start with 'id'. More... | |
string | $table = 'grade_grades' |
The DB table. More... | |
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. More... | |
int | $usermodified |
The userid of the person who last modified this grade. More... | |
Protected Member Functions | |
add_feedback_files (int $historyid=null) | |
Handles adding feedback files in the gradebook. More... | |
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. More... | |
notify_changed ($deleted) | |
Used to notify the completion system (if necessary) that a user's grade has changed, and clear up a possible score cache. More... | |
update_feedback_files (int $historyid=null) | |
Handles updating feedback files in the gradebook. More... | |
Static Protected Member Functions | |
static | fetch_helper ($table, $classname, $params) |
Factory method which uses the parameters to retrieve matching instances from the database. More... | |
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...). More... | |
|
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.
|
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 |
grade_grade::insert | ( | $source = null | ) |
Insert the grade_grade instance into the database.
string | $source | From where was the object inserted (mod/forum, manual, etc.) |
int | The new grade_grade ID if successful, false otherwise |
Reimplemented from grade_object.
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 |
Reimplemented from grade_object.
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.
stdClass | $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 | ) |
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 | 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
array grade_grade::$feedbackfiles = [] |
Feedback files to copy.
Example -
[ 'contextid' => 1, 'component' => 'mod_xyz', 'filearea' => 'mod_xyz_feedback', 'itemid' => 2 ];
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
int grade_grade::$itemid |
The id of the grade_item this grade belongs to.
$itemid
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