Moodle APIs 4.1
Moodle 4.1.9+ (Build: 20240402)
|
Public Member Functions | |
can_control_visibility () | |
Returns whether the grade object can control the visibility of the grades. | |
can_delete () | |
Checks if scale can be deleted. | |
compact_items ($items=NULL) | |
Compacts (implodes) the array of items in $scale_items into a comma-separated string, $scale. | |
delete ($source=null) | |
Deletes this scale from the database. | |
get_description () | |
Returns the formatted grade description with URLs converted. | |
get_hidden () | |
Check a grade item hidden status. | |
get_name () | |
Returns the most descriptive field for this object. | |
get_nearest_item ($grade) | |
When called on a loaded scale object (with a valid id) and given a float grade between the grademin and grademax, this method returns the scale item that falls closest to the float given (which is usually an average of several grades on a scale). | |
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_hidden () | |
Returns the current hidden state of this grade_item. | |
is_hiddenuntil () | |
Check grade object hidden status. | |
is_last_global_scale () | |
Checks if this is the last scale on the site. | |
is_used () | |
Returns if scale used anywhere - activities, grade items, outcomes, etc. | |
load_items ($items=NULL) | |
Loads the scale's items into the $scale_items array. | |
load_optional_fields () | |
Makes sure all the optional fields are loaded. | |
set_hidden ($hidden, $cascade=false) | |
Set a grade object hidden status. | |
update ($source=null, $isbulkupdate=false) | |
In addition to update() it also updates grade_outcomes_courses if needed. | |
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 | fetch ($params) |
Finds and returns a grade_scale instance based on params. | |
static | fetch_all ($params) |
Finds and returns all grade_scale instances based on params. | |
static | fetch_all_global () |
Static function returning all global scales. | |
static | fetch_all_helper ($table, $classname, $params) |
Factory method which uses the parameters to retrieve all matching instances from the database. | |
static | fetch_all_local ($courseid) |
Static function returning all local course scales. | |
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. | |
Public Attributes | |
int | $courseid |
The course this scale belongs to. | |
string | $description |
A description for this scale. | |
int | $hidden = 0 |
0 if visible, 1 always hidden or date not visible until $hidden | |
int | $id |
The PK. | |
string | $name |
The name of the scale. | |
array | $optional_fields = array() |
Array of optional fields with default values - usually long text information that is not always needed. | |
array | $required_fields = array('id', 'courseid', 'userid', 'name', 'scale', 'description', 'descriptionformat', 'timemodified') |
Array of required table fields, must start with 'id'. | |
string | $scale |
A string representation of the scale items (a comma-separated list). | |
array | $scale_items = array() |
The items in this scale. | |
string | $table = 'scale' |
DB Table (used by grade_object). | |
int | $timecreated |
The first time this grade_object was created. | |
int | $timemodified |
The last time this grade_object was modified. | |
int | $userid |
The ID of the user who created the scale $userid. | |
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. | |
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. | |
|
protectedinherited |
Handles adding feedback files in the gradebook.
int | null | $historyid |
Reimplemented in grade_grade.
|
inherited |
Returns whether the grade object can control the visibility of the grades.
bool |
Reimplemented in grade_item.
grade_scale::can_delete | ( | ) |
Checks if scale can be deleted.
bool |
grade_scale::compact_items | ( | $items = NULL | ) |
Compacts (implodes) the array of items in $scale_items into a comma-separated string, $scale.
There are three ways to achieve this:
mixed | $items | Could be null, a string or an array. The method behaves differently for each case. |
array | The resulting string of scale items or null if the method failed to produce one. |
grade_scale::delete | ( | $source = null | ) |
Deletes this scale from the database.
string | $source | from where was the object deleted (mod/forum, manual, etc.) |
bool | success |
Reimplemented from grade_object.
|
protectedinherited |
Handles deleting feedback files in the gradebook.
Reimplemented in grade_grade.
|
static |
Finds and returns a grade_scale instance based on params.
array | $params | associative arrays varname=>value |
object | grade_scale instance or false if none found. |
Reimplemented from grade_object.
|
static |
Finds and returns all grade_scale instances based on params.
array | $params | associative arrays varname=>value |
array | array of grade_scale instances or false if none found. |
Reimplemented from grade_object.
|
static |
Static function returning all global scales.
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 |
|
static |
Static function returning all local course scales.
int | $courseid | The course ID |
array | Returns an array of grade_scale instances |
|
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 |
grade_scale::get_description | ( | ) |
Returns the formatted grade description with URLs converted.
string |
|
inherited |
Check a grade item hidden status.
int | 0 means visible, 1 hidden always, a timestamp means "hidden until" |
Reimplemented in grade_grade.
grade_scale::get_name | ( | ) |
Returns the most descriptive field for this object.
This is a standard method used when we do not know the exact type of an object.
string | name |
grade_scale::get_nearest_item | ( | $grade | ) |
When called on a loaded scale object (with a valid id) and given a float grade between the grademin and grademax, this method returns the scale item that falls closest to the float given (which is usually an average of several grades on a scale).
If the float falls below 1 but above 0, it will be rounded up to 1.
float | $grade |
string |
|
inherited |
Returns object with fields and values that are defined in database.
stdClass |
grade_scale::insert | ( | $source = null , |
|
$isbulkupdate = false |
|||
) |
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.) |
bool | $isbulkupdate | If bulk grade update is happening. |
int | PK ID if successful, false otherwise |
Reimplemented from grade_object.
|
inherited |
Returns the current hidden state of this grade_item.
This depends on the grade object hidden setting and the current time if hidden is set to a "hidden until" timestamp
bool | Current hidden state |
Reimplemented in grade_grade.
|
inherited |
Check grade object hidden status.
bool | True if a "hidden until" timestamp is set, false if grade object is set to always visible or always hidden. |
Reimplemented in grade_grade.
grade_scale::is_last_global_scale | ( | ) |
Checks if this is the last scale on the site.
bool |
grade_scale::is_used | ( | ) |
Returns if scale used anywhere - activities, grade items, outcomes, etc.
bool |
grade_scale::load_items | ( | $items = NULL | ) |
Loads the scale's items into the $scale_items array.
There are three ways to achieve this:
mixed | $items | Could be null, a string or an array. The method behaves differently for each case. |
array | The resulting array of scale items or null if the method failed to produce one. |
|
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.
|
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.
|
inherited |
Set a grade object hidden status.
int | $hidden | 0 means visiable, 1 means hidden always, a timestamp means "hidden until" |
bool | $cascade | Ignored |
Reimplemented in grade_category, grade_grade, and grade_item.
|
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.
grade_scale::update | ( | $source = null , |
|
$isbulkupdate = false |
|||
) |
In addition to update() it also updates grade_outcomes_courses if needed.
string | $source | from where was the object inserted |
bool | $isbulkupdate | If bulk grade update is happening. |
bool | success |
Reimplemented from grade_object.
|
protectedinherited |
Handles updating feedback files in the gradebook.
int | null | $historyid |
Reimplemented in grade_grade.
|
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 |
int grade_scale::$courseid |
The course this scale belongs to.
$courseid
string grade_scale::$description |
A description for this scale.
$description
|
inherited |
The PK.
$id
string grade_scale::$name |
The name of the scale.
$name
|
inherited |
Array of optional fields with default values - usually long text information that is not always needed.
If you want to create an instance without optional fields use: new grade_object($only_required_fields, false); $optional_fields
array grade_scale::$required_fields = array('id', 'courseid', 'userid', 'name', 'scale', 'description', 'descriptionformat', 'timemodified') |
Array of required table fields, must start with 'id'.
$required_fields
string grade_scale::$scale |
A string representation of the scale items (a comma-separated list).
$scale
array grade_scale::$scale_items = array() |
The items in this scale.
$scale_items
string grade_scale::$table = 'scale' |
DB Table (used by grade_object).
$table
|
inherited |
The first time this grade_object was created.
$timecreated
|
inherited |
The last time this grade_object was modified.
$timemodified