Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

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

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.

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

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

param: string $source from where was the object inserted
param: bool $isbulkupdate If bulk grade update is happening.
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