|
Moodle
2.2.1
http://www.collinsharper.com
|


Class representing a grade item. It is responsible for handling its DB representation, modifying and returning its metadata.
Definition at line 33 of file grade_item.php.
| add_idnumber | ( | $ | idnumber | ) |
Set idnumber of grade item, updates also course_modules table
| string | $idnumber | (without magic quotes) |
Definition at line 419 of file grade_item.php.

| adjust_raw_grade | ( | $ | rawgrade, |
| $ | rawmin, | ||
| $ | rawmax | ||
| ) |
Given a float grade value or integer grade scale, applies a number of adjustment based on grade_item variables and returns the result.
| float | $rawgrade | The raw grade value. |
| float | $rawmin | original rawmin |
| float | $rawmax | original rawmax |
Definition at line 708 of file grade_item.php.


| bounded_grade | ( | $ | gradevalue | ) |
Makes sure value is a valid grade value.
| float | $gradevalue |
Definition at line 1231 of file grade_item.php.


| check_locktime | ( | ) |
Lock the grade if needed - make sure this is called only when final grades are valid
Definition at line 530 of file grade_item.php.

| compute | ( | $ | userid = null | ) |
Calculates final grade values using the formula in calculation property. The parameters are taken from final grades of grade items in current course only.
Definition at line 1660 of file grade_item.php.


| delete | ( | $ | source = null | ) |
Delete all grades and force_regrading of parent category.
| string | $source | from where was the object deleted (mod/forum, manual, etc.) |
Reimplemented from grade_object.
Definition at line 335 of file grade_item.php.

| delete_all_grades | ( | $ | source = null | ) |
Delete all grades
| string | $source | from where was the object deleted (mod/forum, manual, etc.) |
Definition at line 345 of file grade_item.php.


| static denormalize_formula | ( | $ | formula, |
| $ | courseid | ||
| ) | [static] |
Denormalizes the calculation formula to [idnumber] form
| string | $formula |
Definition at line 1019 of file grade_item.php.


| depends_on | ( | $ | reset_cache = false | ) |
Finds out on which other items does this depend directly when doing calculation or category aggregation
| bool | $reset_cache |
Definition at line 1268 of file grade_item.php.


| static fetch | ( | $ | params | ) | [static] |
Finds and returns a grade_item instance based on params.
| array | $params | associative arrays varname=>value |
Reimplemented from grade_object.
Definition at line 315 of file grade_item.php.


| static fetch_all | ( | $ | params | ) | [static] |
Finds and returns all grade_item instances based on params.
| array | $params | associative arrays varname=>value |
Reimplemented from grade_object.
Definition at line 326 of file grade_item.php.


| static fetch_course_item | ( | $ | courseid | ) | [static] |
Returns grade item associated with the course
| int | $courseid |
Definition at line 946 of file grade_item.php.


| force_regrading | ( | ) |
Sets this grade_item's needsupdate to true. Also marks the course item as needing update.
Definition at line 771 of file grade_item.php.

| get_calculation | ( | ) |
Returns calculation string if grade calculated.
Definition at line 991 of file grade_item.php.

| get_coefstring | ( | ) |
Queries parent categories recursively to find the aggregationcoef type that applies to this grade item.
Definition at line 1987 of file grade_item.php.

| get_decimals | ( | ) |
Returns the value of the decimals field. It can be set at 3 levels: grade_item, course setting and site. The lowest level overrides the higher ones.
Definition at line 1931 of file grade_item.php.


| get_displaytype | ( | ) |
Returns the value of the display type. It can be set at 3 levels: grade_item, course setting and site. The lowest level overrides the higher ones.
Definition at line 1916 of file grade_item.php.


| get_final | ( | $ | userid = NULL | ) |
Returns the final values for this grade item (as imported by module or other source).
| int | $userid | Optional: to retrieve a single final grade |
Definition at line 1068 of file grade_item.php.

| get_formatted_range | ( | $ | rangesdisplaytype = null, |
| $ | rangesdecimalpoints = null |
||
| ) |
Returns a string representing the range of grademin - grademax for this grade item.
| int | $rangesdisplaytype | |
| int | $rangesdecimalpoints |
Definition at line 1948 of file grade_item.php.

Get (or create if not exist yet) grade for this user
| int | $userid |
Definition at line 1094 of file grade_item.php.

| get_grade_item | ( | ) |
Returns this grade_item. This method is also available in grade_category, for cases where the object type is not know.
Definition at line 1131 of file grade_item.php.
| get_idnumber | ( | ) |
Returns the idnumber of this grade_item. This method is also available in grade_category, for cases where the object type is not know.
Definition at line 1122 of file grade_item.php.

Returns the grade_category for category item
Definition at line 858 of file grade_item.php.


| get_locktime | ( | ) |
Set the locktime for this grade item.
Definition at line 557 of file grade_item.php.

| get_name | ( | $ | fulltotal = false | ) |
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.
| boolean | $fulltotal,: | if the item is a category total, returns $categoryname."total" instead of "Category total" or "Course total" |
Definition at line 1168 of file grade_item.php.

Returns the grade_category object this grade_item belongs to (referenced by categoryid) or category attached to category item.
Definition at line 832 of file grade_item.php.


| get_sortorder | ( | ) |
Returns the sortorder of this grade_item. This method is also available in grade_category, for cases where the object type is not know.
Definition at line 1113 of file grade_item.php.

| has_hidden_grades | ( | $ | groupsql = "", |
| array $ | params = null, |
||
| $ | groupwheresql = "" |
||
| ) |
Returns the number of grades that are hidden.
| string | $groupsql | |
| array | $params | sql params in $groupsql |
| string | $groupsqlwhere |
Definition at line 599 of file grade_item.php.
| insert | ( | $ | source = null | ) |
In addition to perform parent::insert(), calls force_regrading() method too.
| string | $source | from where was the object inserted (mod/forum, manual, etc.) |
Reimplemented from grade_object.
Definition at line 364 of file grade_item.php.

| is_calculated | ( | ) |
Checks if grade calculated. Returns this object's calculation.
Definition at line 968 of file grade_item.php.


| is_category_item | ( | ) |
Is the grade item associated with category?
Definition at line 881 of file grade_item.php.

| is_course_item | ( | ) |
Is the grade item associated with course?
Definition at line 889 of file grade_item.php.

| is_editable | ( | ) |
| is_external_item | ( | ) |
Is the grade item external - associated with module, plugin or something else?
Definition at line 913 of file grade_item.php.

| is_locked | ( | $ | userid = NULL | ) |
Returns the locked state of this grade_item (if the grade_item is locked OR no specific $userid is given) or the locked state of a specific grade within this item if a specific $userid is given and the grade_item is unlocked.
| int | $userid |
Definition at line 456 of file grade_item.php.


| is_manual_item | ( | ) |
Is this a manually graded item?
Definition at line 897 of file grade_item.php.

| is_outcome_item | ( | ) |
Is this an outcome item?
Definition at line 905 of file grade_item.php.

Is the grade item overridable
Definition at line 921 of file grade_item.php.


Is the grade item feedback overridable
Definition at line 929 of file grade_item.php.


| is_raw_used | ( | ) |
Returns true if grade items uses raw grades
Definition at line 937 of file grade_item.php.


Calls upon the get_item_category method to retrieve the grade_category object from the DB and assigns it to $this->item_category. It also returns the object.
Definition at line 870 of file grade_item.php.


| load_outcome | ( | ) |
Instantiates a grade_outcome object whose data is retrieved from the DB, if this item's outcomeid variable is set.
Definition at line 819 of file grade_item.php.

Calls upon the get_parent_category method to retrieve the grade_category object from the DB and assigns it to $this->parent_category. It also returns the object.
Definition at line 846 of file grade_item.php.


| load_scale | ( | ) |
Instantiates a grade_scale object whose data is retrieved from the DB, if this item's scaleid variable is set.
Definition at line 785 of file grade_item.php.


| move_after_sortorder | ( | $ | sortorder | ) |
Definition at line 1149 of file grade_item.php.


| static normalize_formula | ( | $ | formula, |
| $ | courseid | ||
| ) | [static] |
Normalizes the calculation formula to [#giXX#] form
| string | $formula |
Definition at line 1045 of file grade_item.php.


Compares the values held by this object with those of the matching record in DB, and returns whether or not these differences are sufficient to justify an update of all parent objects. This assumes that this object has an id number and a matching record in DB. If not, it will return false.
Definition at line 281 of file grade_item.php.


| refresh_grades | ( | $ | userid = 0 | ) |
Refetch grades from modules, plugins.
| int | $userid | optional, one user only |
Definition at line 1371 of file grade_item.php.


| regrade_final_grades | ( | $ | userid = null | ) |
Performs the necessary calculations on the grades_final referenced by this grade_item. Also resets the needsupdate flag once successfully performed.
This function must be used ONLY from lib/gradeslib.php/grade_regrade_final_grades(), because the regrading must be done in correct order!!
Definition at line 627 of file grade_item.php.

Mark regrading as finished successfully.
Definition at line 611 of file grade_item.php.
| set_calculation | ( | $ | formula | ) |
Sets this item's calculation (creates it) if not yet set, or updates it if already set (in the DB). If no calculation is given, the calculation is removed.
| string | $formula | string representation of formula used for calculation |
Definition at line 1007 of file grade_item.php.


| set_hidden | ( | $ | hidden, |
| $ | cascade = false |
||
| ) |
Set the hidden status of grade_item and all grades, 0 mean visible, 1 always hidden, number means date to hide until.
| int | $hidden | new hidden status |
| boolean | $cascade | apply to child objects too |
Reimplemented from grade_object.
Definition at line 567 of file grade_item.php.


| set_locked | ( | $ | lockedstate, |
| $ | cascade = false, |
||
| $ | refresh = true |
||
| ) |
Locks or unlocks this grade_item and (optionally) all its associated final grades.
| int | $locked | 0, 1 or a timestamp int(10) after which date the item will be locked. |
| boolean | $cascade | lock/unlock child objects too |
| boolean | $refresh | refresh grades when unlocking |
setting lock
removing lock
Definition at line 478 of file grade_item.php.


| set_locktime | ( | $ | locktime | ) |
Set the locktime for this grade item.
| int | $locktime | timestamp for lock to activate |
Definition at line 547 of file grade_item.php.

| set_parent | ( | $ | parentid | ) |
Sets this item's categoryid. A generic method shared by objects that have a parent id of some kind.
| int | $parentid |
Definition at line 1196 of file grade_item.php.

| set_sortorder | ( | $ | sortorder | ) |
Sets the sortorder of this grade_item. This method is also available in grade_category, for cases where the object type is not know.
| int | $sortorder |
Definition at line 1141 of file grade_item.php.


| update | ( | $ | source = null | ) |
In addition to update() as defined in grade_object, handle the grade_outcome and grade_scale objects. Force regrading if necessary, rounds the float numbers using php function, the reason is we need to compare the db value with computed number to skip regrading if possible.
| string | $source | from where was the object inserted (mod/forum, manual, etc.) |
Reimplemented from grade_object.
Definition at line 248 of file grade_item.php.


| update_final_grade | ( | $ | userid, |
| $ | finalgrade = false, |
||
| $ | source = NULL, |
||
| $ | feedback = false, |
||
| $ | feedbackformat = FORMAT_MOODLE, |
||
| $ | usermodified = null |
||
| ) |
Updates final grade value for given user, this is a only way to update final grades from gradebook and import because it logs the change in history table and deals with overridden flag. This flag is set to prevent later overriding from raw grades submitted from modules.
| int | $userid | the graded user |
| mixed | $finalgrade | float value of final grade - false means do not change |
| string | $howmodified | modification source |
| string | $note | optional note |
| mixed | $feedback | teachers feedback as string - false means do not change |
| int | $feedbackformat |
Definition at line 1410 of file grade_item.php.

| update_raw_grade | ( | $ | userid, |
| $ | rawgrade = false, |
||
| $ | source = NULL, |
||
| $ | feedback = false, |
||
| $ | feedbackformat = FORMAT_MOODLE, |
||
| $ | usermodified = null, |
||
| $ | dategraded = null, |
||
| $ | datesubmitted = null, |
||
| $ | grade = null |
||
| ) |
Updates raw grade value for given user, this is a only way to update raw grades from external source (modules, etc.), because it logs the change in history table and deals with final grade recalculation.
| int | $userid | the graded user |
| mixed | $rawgrade | float value of raw grade - false means do not change |
| string | $howmodified | modification source |
| string | $note | optional note |
| mixed | $feedback | teachers feedback as string - false means do not change |
| int | $feedbackformat | |
| int | $usermodified | - user which did the grading |
| int | $dategraded | |
| int | $datesubmitted | |
| object | $grade | object - useful for bulk upgrades |
Definition at line 1524 of file grade_item.php.

| use_formula | ( | $ | userid, |
| $ | params, | ||
| $ | useditems, | ||
| $ | oldgrade | ||
| ) |
internal function - does the final grade calculation
Definition at line 1756 of file grade_item.php.


| validate_formula | ( | $ | formulastr | ) |
Validate the formula.
| string | $formula |
Definition at line 1839 of file grade_item.php.

| float $aggregationcoef = 0 |
Aggregation coeficient used for weighted averages
Definition at line 198 of file grade_item.php.
| string $calculation |
Calculation string used for this item.
Definition at line 121 of file grade_item.php.
| $calculation_normalized |
Definition at line 128 of file grade_item.php.
| int $categoryid |
The category this grade_item belongs to (optional).
Definition at line 60 of file grade_item.php.
| int $courseid |
The course this grade_item belongs to.
Definition at line 54 of file grade_item.php.
| int $decimals = null |
The number of digits after the decimal point symbol. Applies only to REAL and PERCENTAGE grade display types.
Definition at line 216 of file grade_item.php.
| $dependson_cache = null |
Cached dependson array
Definition at line 239 of file grade_item.php.
Display type of the grades (Real, Percentage, Letter, or default).
Definition at line 210 of file grade_item.php.
| $formula |
Math evaluation object
Definition at line 132 of file grade_item.php.
| float $grademax = 100 |
Maximum allowable grade.
Definition at line 144 of file grade_item.php.
| float $grademin = 0 |
Minimum allowable grade.
Definition at line 150 of file grade_item.php.
| float $gradepass = 0 |
grade required to pass. (grademin <= gradepass <= grademax)
Definition at line 180 of file grade_item.php.
| int $gradetype = GRADE_TYPE_VALUE |
The type of grade (0 = none, 1 = value, 2 = scale, 3 = text)
Definition at line 138 of file grade_item.php.
| string $idnumber |
Arbitrary idnumber provided by the module responsible.
Definition at line 115 of file grade_item.php.
| object $item_category |
The grade_category object referenced $this->iteminstance (itemtype must be == 'category' or == 'course' in that case).
Definition at line 66 of file grade_item.php.
| string $iteminfo |
Info and notes about this item.
Definition at line 109 of file grade_item.php.
| int $iteminstance |
ID of the item module
Definition at line 97 of file grade_item.php.
| string $itemmodule |
The module pushing this grade (e.g. 'forum', 'quiz', 'assignment' etc).
Definition at line 91 of file grade_item.php.
| string $itemname |
The name of this grade_item (pushed by the module).
Definition at line 79 of file grade_item.php.
| int $itemnumber |
Number of the item in a series of multiple grades pushed by an activity.
Definition at line 103 of file grade_item.php.
| string $itemtype |
e.g. 'category', 'course' and 'mod', 'blocks', 'import', etc...
Definition at line 85 of file grade_item.php.
| int $locked = 0 |
Grade item lock flag. Empty if not locked, locked if any value present, usually date when item was locked. Locking prevents updating.
Definition at line 222 of file grade_item.php.
| int $locktime = 0 |
Date after which the grade will be locked. Empty means no automatic locking.
Definition at line 228 of file grade_item.php.
| float $multfactor = 1.0 |
Multiply all grades by this number.
Definition at line 186 of file grade_item.php.
| boolean $needsupdate = 1 |
If set, the whole column will be recalculated, then this flag will be switched off.
Definition at line 234 of file grade_item.php.
| object $outcome |
The grade_outcome this grade is associated with, if applicable.
Definition at line 174 of file grade_item.php.
| int $outcomeid |
The id of the optional grade_outcome associated with this grade_item.
Definition at line 168 of file grade_item.php.
| object $parent_category |
The grade_category object referenced by $this->categoryid.
Definition at line 72 of file grade_item.php.
| float $plusfactor = 0 |
Add this to all grades.
Definition at line 192 of file grade_item.php.
| array $required_fields |
array('id', 'courseid', 'categoryid', 'itemname', 'itemtype', 'itemmodule', 'iteminstance', 'itemnumber', 'iteminfo', 'idnumber', 'calculation', 'gradetype', 'grademax', 'grademin', 'scaleid', 'outcomeid', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'sortorder', 'display', 'decimals', 'hidden', 'locked', 'locktime', 'needsupdate', 'timecreated', 'timemodified')
Array of required table fields, must start with 'id'.
Reimplemented from grade_object.
Definition at line 44 of file grade_item.php.
| object $scale |
A grade_scale object (referenced by $this->scaleid).
Definition at line 162 of file grade_item.php.
| int $scaleid |
id of the scale, if this grade is based on a scale.
Definition at line 156 of file grade_item.php.
| int $sortorder = 0 |
Sorting order of the columns.
Definition at line 204 of file grade_item.php.
| string $table = 'grade_items' |
DB Table (used by grade_object).
Reimplemented from grade_object.
Definition at line 38 of file grade_item.php.