Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 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: 426 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.

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

insert($source = null, $isbulkupdate = false)   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.

return: int PK ID if successful, false otherwise
param: string $source from where was the object inserted (mod/forum, manual, etc.)
param: bool $isbulkupdate If bulk grade update is happening.

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

return: bool success
param: string $source from where was the object inserted
param: bool $isbulkupdate If bulk grade update is happening.

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

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

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

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

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

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

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

return: array
param: int $courseid

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

return: array
param: int $courseid

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.

return: float
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