Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

Definition of grade outcome class

Copyright: 2006 Nicolas Connault
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 424 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 lib/grade/grade_object.php

Defines 1 class

grade_outcome:: (17 methods):
  delete()
  insert()
  update()
  use_in()
  fetch()
  fetch_all()
  load_scale()
  fetch_all_global()
  fetch_all_local()
  fetch_all_available()
  get_name()
  get_shortname()
  get_description()
  can_delete()
  get_course_uses_count()
  get_item_uses_count()
  get_grade_info()


Class: grade_outcome  - X-Ref

Class representing a grade outcome.

It is responsible for handling its DB representation, modifying and returning its metadata.

delete($source=null)   X-Ref
Deletes this outcome from the database.

param: string $source from where was the object deleted (mod/forum, manual, etc.)
return: bool success

insert($source=null)   X-Ref
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.

param: string $source from where was the object inserted (mod/forum, manual, etc.)
return: int PK ID if successful, false otherwise

update($source=null)   X-Ref
In addition to update() it also updates grade_outcomes_courses if needed

param: string $source from where was the object inserted
return: bool success

use_in($courseid)   X-Ref
Mark outcome as used in a course

param: int $courseid
return: False if invalid courseid requested

fetch($params)   X-Ref
Finds and returns a grade_outcome instance based on params.

param: array $params associative arrays varname=>value
return: object grade_outcome instance or false if none found.

fetch_all($params)   X-Ref
Finds and returns all grade_outcome instances based on params.

param: array $params associative arrays varname=>value
return: array array of grade_outcome insatnces or false if none found.

load_scale()   X-Ref
Instantiates a grade_scale object whose data is retrieved from the database

return: grade_scale

fetch_all_global()   X-Ref
Static function returning all global outcomes

return: array

fetch_all_local($courseid)   X-Ref
Static function returning all local course outcomes

param: int $courseid
return: array

fetch_all_available($courseid)   X-Ref
Static method that returns all outcomes available in course

param: int $courseid
return: array

get_name()   X-Ref
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.

return: string name

get_shortname()   X-Ref
Returns unique outcome short name.

return: string name

get_description()   X-Ref
Returns the formatted grade description with URLs converted

return: string

can_delete()   X-Ref
Checks if outcome can be deleted.

return: bool

get_course_uses_count()   X-Ref
Returns the number of places where outcome is used.

return: int

get_item_uses_count()   X-Ref
Returns the number of grade items that use this grade outcome

return: int

get_grade_info($courseid=null, $average=true, $items=false)   X-Ref
Computes then returns extra information about this outcome and other objects that are linked to it.
The average of all grades that use this outcome, for all courses (or 1 course if courseid is given) can
be requested, and is returned as a float if requested alone. If the list of items that use this outcome
is also requested, then a single array is returned, which contains the grade_items AND the average grade
if such is still requested (array('items' => array(...), 'avg' => 2.30)). This combining of two
methods into one is to save on DB queries, since both queries are similar and can be performed together.

param: int $courseid An optional courseid to narrow down the average to 1 course only
param: bool $average Whether or not to return the average grade for this outcome
param: bool $items Whether or not to return the list of items using this outcome
return: float