Moodle  2.2.1
http://www.collinsharper.com
grade_category Class Reference
Inheritance diagram for grade_category:
Collaboration diagram for grade_category:

Public Member Functions

 update ($source=null)
 delete ($source=null)
 insert ($source=null)
 insert_course_category ($courseid)
 qualifies_for_regrading ()
 force_regrading ()
 generate_grades ($userid=null)
 aggregate_values ($grade_values, $items)
 apply_limit_rules (&$grade_values, $items)
 is_extracredit_used ()
 is_aggregationcoef_used ()
 get_coefstring ($first=true)
 get_children ($include_category_items=false)
 load_grade_item ()
 get_grade_item ()
 load_parent_category ()
 get_parent_category ()
 get_name ()
 set_parent ($parentid, $source=null)
 get_final ($userid=null)
 get_sortorder ()
 get_idnumber ()
 set_sortorder ($sortorder)
 move_after_sortorder ($sortorder)
 is_course_category ()
 is_editable ()
 is_locked ()
 set_locked ($lockedstate, $cascade=false, $refresh=true)
 set_hidden ($hidden, $cascade=false)
 apply_default_settings ()
 apply_forced_settings ()

Static Public Member Functions

static build_path ($grade_category)
static fetch ($params)
static fetch_all ($params)
static fetch_course_tree ($courseid, $include_category_items=false)
static fetch_course_category ($courseid)
static set_properties (&$instance, $params)
static updated_forced_settings ()

Data Fields

 $table = 'grade_categories'
 $required_fields
 $courseid
 $parent
 $parent_category
 $depth = 0
 $path
 $fullname
 $aggregation = GRADE_AGGREGATE_MEAN
 $keephigh = 0
 $droplow = 0
 $aggregateonlygraded = 0
 $aggregateoutcomes = 0
 $aggregatesubcats = 0
 $children
 $all_children
 $grade_item
 $sortorder
 $forceable = array('aggregation', 'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes', 'aggregatesubcats')
 $coefstring = null

Detailed Description

Definition at line 38 of file grade_category.php.


Member Function Documentation

aggregate_values ( grade_values,
items 
)

Internal function - aggregation maths. Must be public: used by grade_grade::get_hiding_affected()

Parameters:
array$grade_valuesThe values being aggregated
array$itemsThe array of grade_items
Returns:
float

Definition at line 641 of file grade_category.php.

Applies default settings on this category

Returns:
bool true if anything changed

Definition at line 1599 of file grade_category.php.

Here is the caller graph for this function:

Applies forced settings on this category

Returns:
bool true if anything changed

Definition at line 1618 of file grade_category.php.

Here is the caller graph for this function:

apply_limit_rules ( &$  grade_values,
items 
)

Given an array of grade values (numerical indices), applies droplow or keephigh rules to limit the final array.

Parameters:
array&$grade_valuesitemid=>$grade_value float
array$itemsgrade item objects
Returns:
array Limited grades.

Definition at line 880 of file grade_category.php.

Here is the call graph for this function:

static build_path ( grade_category) [static]

Builds this category's path string based on its parents (if any) and its own id number. This is typically done just before inserting this object in the DB for the first time, or when a new parent is added or changed. It is a recursive function: once the calling object no longer has a parent, the path is complete.

Parameters:
object$grade_categoryA Grade_Category object
Returns:
int The depth of this category (2 means there is one parent)

Definition at line 171 of file grade_category.php.

Here is the caller graph for this function:

delete ( source = null)

If parent::delete() is successful, send force_regrading message to parent category.

Parameters:
string$sourcefrom where was the object deleted (mod/forum, manual, etc.)
Returns:
boolean success

Reimplemented from grade_object.

Definition at line 264 of file grade_category.php.

Here is the call graph for this function:

static fetch ( params) [static]

Finds and returns a grade_category instance based on params.

Parameters:
array$paramsassociative arrays varname=>value
Returns:
object grade_category instance or false if none found.

Reimplemented from grade_object.

Definition at line 190 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static fetch_all ( params) [static]

Finds and returns all grade_category instances based on params.

Parameters:
array$paramsassociative arrays varname=>value
Returns:
array array of grade_category insatnces or false if none found.

Reimplemented from grade_object.

Definition at line 201 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static fetch_course_category ( courseid) [static]

Return the top most course category.

Parameters:
int$courseidThe Course ID
Returns:
object grade_category instance for course grade

Definition at line 1441 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static fetch_course_tree ( courseid,
include_category_items = false 
) [static]

Returns tree with all grade_items and categories as elements

Parameters:
int$courseidThe course ID
boolean$include_category_itemsas category children
Returns:
array

Definition at line 1016 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Marks the category and course item as needing update - categories are always regraded.

Returns:
void

Definition at line 413 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

generate_grades ( userid = null)

Generates and saves final grades in associated category grade item. These immediate children must already have their own final grades. The category's aggregation method is used to generate final grades.

Please note that category grade is either calculated or aggregated - not both at the same time.

This method must be used ONLY from grade_item::regrade_final_grades(), because the calculation must be done in correct order!

Steps to follow: 1. Get final grades from immediate children 3. Aggregate these grades 4. Save them in final grades of associated category grade item

Parameters:
int$useridThe user ID
Returns:
bool

Definition at line 437 of file grade_category.php.

Here is the call graph for this function:

get_children ( include_category_items = false)

Fetches and returns all the children categories and/or grade_items belonging to this category. By default only returns the immediate children (depth=1), but deeper levels can be requested, as well as all levels (0). The elements are indexed by sort order.

Parameters:
bool$include_category_itemsWhether or not to include category grade_items in the children array
Returns:
array Array of child objects (grade_category and grade_item).

Definition at line 1093 of file grade_category.php.

get_coefstring ( first = true)

Recursive function to find which weight/extra credit field to use in the grade item form. Inherits from a parent category if that category has aggregatesubcats set to true.

Parameters:
string$firstWhether or not this is the first item in the recursion
Returns:
string

Definition at line 956 of file grade_category.php.

Here is the call graph for this function:

get_final ( userid = null)

Returns the final values for this grade category.

Parameters:
int$useridOptional: to retrieve a single final grade
Returns:
mixed An array of all final_grades (stdClass objects) for this grade_item, or a single final_grade.

Definition at line 1371 of file grade_category.php.

Here is the call graph for this function:

Retrieves from DB and instantiates the associated grade_item object. If no grade_item exists yet, create one.

Returns:
object Grade_item

Definition at line 1251 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the idnumber of the associated grade_item. This method is also available in grade_item, for cases where the object type is not known.

Returns:
string idnumber

Definition at line 1393 of file grade_category.php.

Here is the call graph for this function:

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.

Returns:
string name

Definition at line 1314 of file grade_category.php.

Here is the call graph for this function:

Uses $this->parent to instantiate and return a grade_category object.

Returns:
object Parent_category

Definition at line 1299 of file grade_category.php.

Here is the caller graph for this function:

Returns the sortorder of the associated grade_item. This method is also available in grade_item, for cases where the object type is not known.

Returns:
int Sort order

Definition at line 1382 of file grade_category.php.

Here is the call graph for this function:

insert ( source = null)

In addition to the normal insert() defined in grade_object, this method sets the depth and path for this object, and update the record accordingly. The reason why this must be done here instead of in the constructor, is that they both need to know the record's id number, which only gets created at insertion time. This method also creates an associated grade_item if this wasn't done during construction.

Parameters:
string$sourcefrom where was the object inserted (mod/forum, manual, etc.)
Returns:
int PK ID if successful, false otherwise

Reimplemented from grade_object.

Definition at line 326 of file grade_category.php.

Here is the call graph for this function:

insert_course_category ( courseid)

Internal function - used only from fetch_course_category() Normal insert() can not be used for course category

Parameters:
int$courseidThe course ID
Returns:
bool success

Definition at line 362 of file grade_category.php.

Here is the call graph for this function:

Returns true if category uses special aggregation coefficient

Returns:
boolean true if coefficient used

Definition at line 940 of file grade_category.php.

Return true if this is the top most category that represents the total course grade.

Returns:
boolean

Definition at line 1428 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Is grading object editable?

Returns:
boolean

Definition at line 1464 of file grade_category.php.

Returns true if category uses extra credit of any kind

Returns:
boolean true if extra credit used

Definition at line 929 of file grade_category.php.

Here is the caller graph for this function:

is_locked ( )

Returns the locked state/date of the associated grade_item. This method is also available in grade_item, for cases where the object type is not known.

Returns:
boolean

Definition at line 1473 of file grade_category.php.

Here is the call graph for this function:

Uses get_grade_item to load or create a grade_item, then saves it as $this->grade_item.

Returns:
object Grade_item

Definition at line 1239 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Uses $this->parent to instantiate $this->parent_category based on the referenced record in the DB.

Returns:
object Parent_category

Definition at line 1288 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

move_after_sortorder ( sortorder)

Move this category after the given sortorder - does not change the parent

Parameters:
int$sortorderto place after.
Returns:
void

Definition at line 1418 of file grade_category.php.

Here is the call graph for this function:

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.

Returns:
boolean

Definition at line 391 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

set_hidden ( hidden,
cascade = false 
)

Sets the grade_item's hidden variable and updates the grade_item. Method named after grade_item::set_hidden().

Parameters:
int$hidden0, 1 or a timestamp int(10) after which date the item will be hidden.
boolean$cascadeapply to child objects too
Returns:
void

Reimplemented from grade_object.

Definition at line 1558 of file grade_category.php.

Here is the call graph for this function:

set_locked ( lockedstate,
cascade = false,
refresh = true 
)

Sets the grade_item's locked variable and updates the grade_item. Method named after grade_item::set_locked().

Parameters:
int$lockedstate0, 1 or a timestamp int(10) after which date the item will be locked.
bool$cascadelock/unlock child objects too
bool$refreshrefresh grades when unlocking
Returns:
boolean success if category locked (not all children mayb be locked though)

Definition at line 1488 of file grade_category.php.

Here is the call graph for this function:

set_parent ( parentid,
source = null 
)

Sets this category's parent id. A generic method shared by objects that have a parent id of some kind.

Parameters:
int$parentidThe ID of the category parent to $this
grade_category$sourceAn optional grade_category to use as the source for the parent
Returns:
boolean success

Definition at line 1334 of file grade_category.php.

Here is the call graph for this function:

static set_properties ( &$  instance,
params 
) [static]

Given an associated array or object, cycles through each key/variable and assigns the value to the corresponding variable in this object. final

Reimplemented from grade_object.

Definition at line 1518 of file grade_category.php.

set_sortorder ( sortorder)

Sets sortorder variable for this category. This method is also available in grade_item, for cases where the object type is not know.

Parameters:
int$sortorderThe sortorder to assign to this category
Returns:
void

Definition at line 1406 of file grade_category.php.

Here is the call graph for this function:

update ( source = null)

In addition to update() as defined in grade_object, call force_regrading of parent categories, if applicable.

Parameters:
string$sourcefrom where was the object updated (mod/forum, manual, etc.)
Returns:
boolean success

Reimplemented from grade_object.

Definition at line 210 of file grade_category.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static updated_forced_settings ( ) [static]

Notification of change in forced category settings.

Returns:
void

Definition at line 1645 of file grade_category.php.

Here is the caller graph for this function:


Field Documentation

int $aggregateonlygraded = 0

Aggregate only graded items

Definition at line 112 of file grade_category.php.

int $aggregateoutcomes = 0

Aggregate outcomes together with normal items

Definition at line 118 of file grade_category.php.

int $aggregatesubcats = 0

Ignore subcategories when aggregating

Definition at line 124 of file grade_category.php.

int $aggregation = GRADE_AGGREGATE_MEAN

A constant pointing to one of the predefined aggregation strategies (none, mean, median, sum etc) .

Definition at line 94 of file grade_category.php.

array $all_children

A hierarchical array of all children below this category. This is stored separately from $children because it is more memory-intensive and may not be used as often.

Definition at line 137 of file grade_category.php.

array $children

Array of grade_items or grade_categories nested exactly 1 level below this category

Definition at line 130 of file grade_category.php.

$coefstring = null

String representing the aggregation coefficient. Variable is used as cache.

Definition at line 159 of file grade_category.php.

int $courseid

The course this category belongs to.

Definition at line 57 of file grade_category.php.

int $depth = 0

The number of parents this category has.

Definition at line 75 of file grade_category.php.

int $droplow = 0

Drop the X lowest items.

Definition at line 106 of file grade_category.php.

$forceable = array('aggregation', 'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes', 'aggregatesubcats')

List of options which can be "forced" from site settings.

Definition at line 154 of file grade_category.php.

string $fullname

The name of this category.

Definition at line 88 of file grade_category.php.

An associated grade_item object, with itemtype=category, used to calculate and cache a set of grade values for this category.

Definition at line 144 of file grade_category.php.

int $keephigh = 0

Keep only the X highest items.

Definition at line 100 of file grade_category.php.

int $parent

The category this category belongs to (optional).

Definition at line 63 of file grade_category.php.

object $parent_category

The grade_category object referenced by $this->parent (PK).

Definition at line 69 of file grade_category.php.

string $path

Shows the hierarchical path for this category as /1/2/3/ (like course_categories), the last number being this category's autoincrement ID number.

Definition at line 82 of file grade_category.php.

array $required_fields
Initial value:
 array('id', 'courseid', 'parent', 'depth', 'path', 'fullname', 'aggregation',
                                 'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes',
                                 'aggregatesubcats', 'timecreated', 'timemodified', 'hidden')

Array of required table fields, must start with 'id'.

Reimplemented from grade_object.

Definition at line 49 of file grade_category.php.

$sortorder

Temporary sortorder for speedup of children resorting

Definition at line 149 of file grade_category.php.

string $table = 'grade_categories'

The DB table.

Reimplemented from grade_object.

Definition at line 43 of file grade_category.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations