Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
grade_outcome Class Reference

Class representing a grade outcome. More...

Inheritance diagram for grade_outcome:
grade_object

Public Member Functions

 can_control_visibility ()
 Returns whether the grade object can control the visibility of the grades.
 
 can_delete ()
 Checks if outcome can be deleted.
 
 delete ($source=null)
 Deletes this outcome from the database.
 
 get_course_uses_count ()
 Returns the number of places where outcome is used.
 
 get_description ()
 Returns the formatted grade description with URLs converted.
 
 get_grade_info ($courseid=null, $average=true, $items=false)
 Computes then returns extra information about this outcome and other objects that are linked to it.
 
 get_hidden ()
 Check a grade item hidden status.
 
 get_item_uses_count ()
 Returns the number of grade items that use this grade outcome.
 
 get_name ()
 Returns the most descriptive field for this object.
 
 get_record_data ()
 Returns object with fields and values that are defined in database.
 
 get_shortname ()
 Returns unique outcome short name.
 
 insert ($source=null, $isbulkupdate=false)
 Records this object in the Database, sets its id to the returned value, and returns that value.
 
 is_hidden ()
 Returns the current hidden state of this grade_item.
 
 is_hiddenuntil ()
 Check grade object hidden status.
 
 load_optional_fields ()
 Makes sure all the optional fields are loaded.
 
 load_scale ()
 Instantiates a grade_scale object whose data is retrieved from the database.
 
 set_hidden ($hidden, $cascade=false)
 Set a grade object hidden status.
 
 update ($source=null, $isbulkupdate=false)
 In addition to update() it also updates grade_outcomes_courses if needed.
 
 update_from_db ()
 Using this object's id field, fetches the matching record in the DB, and looks at each variable in turn.
 
 use_in ($courseid)
 Mark outcome as used in a course.
 

Static Public Member Functions

static fetch ($params)
 Finds and returns a grade_outcome instance based on params.
 
static fetch_all ($params)
 Finds and returns all grade_outcome instances based on params.
 
static fetch_all_available ($courseid)
 Static method that returns all outcomes available in course.
 
static fetch_all_global ()
 Static function returning all global outcomes.
 
static fetch_all_helper ($table, $classname, $params)
 Factory method which uses the parameters to retrieve all matching instances from the database.
 
static fetch_all_local ($courseid)
 Static function returning all local course outcomes.
 
static set_properties (&$instance, $params)
 Given an associated array or object, cycles through each key/variable and assigns the value to the corresponding variable in this object.
 

Public Attributes

int $courseid
 The course this outcome belongs to.
 
string $description
 The description of this outcome - FORMAT_MOODLE.
 
int $descriptionformat = FORMAT_MOODLE
 Identifier of the text format to be used.
 
string $fullname
 The fullname of the outcome.
 
int $hidden = 0
 0 if visible, 1 always hidden or date not visible until $hidden
 
int $id
 The PK.
 
array $optional_fields = array()
 Array of optional fields with default values - usually long text information that is not always needed.
 
array $required_fields
 Array of required table fields, must start with 'id'.
 
object $scale
 A full grade_scale object referenced by $this->scaleid.
 
int $scaleid
 The id of the scale referenced by this outcome.
 
string $shortname
 The shortname of the outcome.
 
string $table = 'grade_outcomes'
 DB Table (used by grade_object).
 
int $timecreated
 The first time this grade_object was created.
 
int $timemodified
 The last time this grade_object was modified.
 
int $usermodified
 The userid of the person who last modified this outcome.
 

Protected Member Functions

 add_feedback_files (int $historyid=null)
 Handles adding feedback files in the gradebook.
 
 delete_feedback_files ()
 Handles deleting feedback files in the gradebook.
 
 notify_changed ($deleted)
 Called immediately after the object data has been inserted, updated, or deleted in the database.
 
 update_feedback_files (int $historyid=null)
 Handles updating feedback files in the gradebook.
 

Static Protected Member Functions

static fetch_helper ($table, $classname, $params)
 Factory method which uses the parameters to retrieve matching instances from the database.
 

Detailed Description

Class representing a grade outcome.

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

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_feedback_files()

grade_object::add_feedback_files ( int $historyid = null)
protectedinherited

Handles adding feedback files in the gradebook.

Parameters
int | null$historyid

Reimplemented in grade_grade.

◆ can_control_visibility()

grade_object::can_control_visibility ( )
inherited

Returns whether the grade object can control the visibility of the grades.

Return values
bool

Reimplemented in grade_item.

◆ can_delete()

grade_outcome::can_delete ( )

Checks if outcome can be deleted.

Return values
bool

◆ delete()

grade_outcome::delete ( $source = null)

Deletes this outcome from the database.

Parameters
string$sourcefrom where was the object deleted (mod/forum, manual, etc.)
Return values
boolsuccess

Reimplemented from grade_object.

◆ delete_feedback_files()

grade_object::delete_feedback_files ( )
protectedinherited

Handles deleting feedback files in the gradebook.

Reimplemented in grade_grade.

◆ fetch()

static grade_outcome::fetch ( $params)
static

Finds and returns a grade_outcome instance based on params.

Parameters
array$paramsassociative arrays varname=>value
Return values
objectgrade_outcome instance or false if none found.

Reimplemented from grade_object.

◆ fetch_all()

static grade_outcome::fetch_all ( $params)
static

Finds and returns all grade_outcome instances based on params.

Parameters
array$paramsassociative arrays varname=>value
Return values
arrayarray of grade_outcome insatnces or false if none found.

Reimplemented from grade_object.

◆ fetch_all_available()

static grade_outcome::fetch_all_available ( $courseid)
static

Static method that returns all outcomes available in course.

Parameters
int$courseid
Return values
array

◆ fetch_all_global()

static grade_outcome::fetch_all_global ( )
static

Static function returning all global outcomes.

Return values
array

◆ fetch_all_helper()

static grade_object::fetch_all_helper ( $table,
$classname,
$params )
staticinherited

Factory method which uses the parameters to retrieve all matching instances from the database.

Parameters
string$tableThe table to retrieve from
string$classnameThe name of the class to instantiate
array$paramsAn array of conditions like $fieldname => $fieldvalue
Return values
array|boolArray of object instances or false if not found

◆ fetch_all_local()

static grade_outcome::fetch_all_local ( $courseid)
static

Static function returning all local course outcomes.

Parameters
int$courseid
Return values
array

◆ fetch_helper()

static grade_object::fetch_helper ( $table,
$classname,
$params )
staticprotectedinherited

Factory method which uses the parameters to retrieve matching instances from the database.

Parameters
string$tableThe table to retrieve from
string$classnameThe name of the class to instantiate
array$paramsAn array of conditions like $fieldname => $fieldvalue
Return values
mixedAn object instance or false if not found

◆ get_course_uses_count()

grade_outcome::get_course_uses_count ( )

Returns the number of places where outcome is used.

Return values
int

◆ get_description()

grade_outcome::get_description ( )

Returns the formatted grade description with URLs converted.

Return values
string

◆ get_grade_info()

grade_outcome::get_grade_info ( $courseid = null,
$average = true,
$items = false )

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.

Parameters
int$courseidAn optional courseid to narrow down the average to 1 course only
bool$averageWhether or not to return the average grade for this outcome
bool$itemsWhether or not to return the list of items using this outcome
Return values
float

◆ get_hidden()

grade_object::get_hidden ( )
inherited

Check a grade item hidden status.

Return values
int0 means visible, 1 hidden always, a timestamp means "hidden until"

Reimplemented in grade_grade.

◆ get_item_uses_count()

grade_outcome::get_item_uses_count ( )

Returns the number of grade items that use this grade outcome.

Return values
int

◆ get_name()

grade_outcome::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.

Return values
stringname

◆ get_record_data()

grade_object::get_record_data ( )
inherited

Returns object with fields and values that are defined in database.

Return values
stdClass

◆ get_shortname()

grade_outcome::get_shortname ( )

Returns unique outcome short name.

Return values
stringname

◆ insert()

grade_outcome::insert ( $source = null,
$isbulkupdate = false )

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.

Parameters
string$sourcefrom where was the object inserted (mod/forum, manual, etc.)
bool$isbulkupdateIf bulk grade update is happening.
Return values
intPK ID if successful, false otherwise

Reimplemented from grade_object.

◆ is_hidden()

grade_object::is_hidden ( )
inherited

Returns the current hidden state of this grade_item.

This depends on the grade object hidden setting and the current time if hidden is set to a "hidden until" timestamp

Return values
boolCurrent hidden state

Reimplemented in grade_grade.

◆ is_hiddenuntil()

grade_object::is_hiddenuntil ( )
inherited

Check grade object hidden status.

Return values
boolTrue if a "hidden until" timestamp is set, false if grade object is set to always visible or always hidden.

Reimplemented in grade_grade.

◆ load_optional_fields()

grade_object::load_optional_fields ( )
inherited

Makes sure all the optional fields are loaded.

If id present, meaning the instance exists in the database, then data will be fetched from the database. Defaults are used for new instances.

◆ load_scale()

grade_outcome::load_scale ( )

Instantiates a grade_scale object whose data is retrieved from the database.

Return values
grade_scale

◆ notify_changed()

grade_object::notify_changed ( $deleted)
protectedinherited

Called immediately after the object data has been inserted, updated, or deleted in the database.

Default does nothing, can be overridden to hook in special behaviour.

Parameters
bool$deleted

Reimplemented in grade_category, and grade_item.

◆ set_hidden()

grade_object::set_hidden ( $hidden,
$cascade = false )
inherited

Set a grade object hidden status.

Parameters
int$hidden0 means visiable, 1 means hidden always, a timestamp means "hidden until"
bool$cascadeIgnored

Reimplemented in grade_category, grade_grade, and grade_item.

◆ set_properties()

static grade_object::set_properties ( & $instance,
$params )
staticinherited

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

Parameters
grade_object$instanceThe object to set the properties on
array$paramsAn array of properties to set like $propertyname => $propertyvalue
Return values
array|stdClassEither an associative array or an object containing property name, property value pairs

Reimplemented in grade_category.

◆ update()

grade_outcome::update ( $source = null,
$isbulkupdate = false )

In addition to update() it also updates grade_outcomes_courses if needed.

Parameters
string$sourcefrom where was the object inserted
bool$isbulkupdateIf bulk grade update is happening.
Return values
boolsuccess

Reimplemented from grade_object.

◆ update_feedback_files()

grade_object::update_feedback_files ( int $historyid = null)
protectedinherited

Handles updating feedback files in the gradebook.

Parameters
int | null$historyid

Reimplemented in grade_grade.

◆ update_from_db()

grade_object::update_from_db ( )
inherited

Using this object's id field, fetches the matching record in the DB, and looks at each variable in turn.

If the DB has different data, the db's data is used to update the object. This is different from the update() function, which acts on the DB record based on the object.

Return values
boolTrue if successful

◆ use_in()

grade_outcome::use_in ( $courseid)

Mark outcome as used in a course.

Parameters
int$courseid
Return values
Falseif invalid courseid requested

Member Data Documentation

◆ $courseid

int grade_outcome::$courseid

The course this outcome belongs to.

$courseid

◆ $description

string grade_outcome::$description

The description of this outcome - FORMAT_MOODLE.

$description

◆ $fullname

string grade_outcome::$fullname

The fullname of the outcome.

$fullname

◆ $id

int grade_object::$id
inherited

The PK.

$id

◆ $optional_fields

array grade_object::$optional_fields = array()
inherited

Array of optional fields with default values - usually long text information that is not always needed.

If you want to create an instance without optional fields use: new grade_object($only_required_fields, false); $optional_fields

◆ $required_fields

array grade_outcome::$required_fields
Initial value:
= array('id', 'courseid', 'shortname', 'fullname', 'scaleid','description',
'descriptionformat', 'timecreated', 'timemodified', 'usermodified')

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

$required_fields

◆ $scale

object grade_outcome::$scale

A full grade_scale object referenced by $this->scaleid.

$scale

◆ $scaleid

int grade_outcome::$scaleid

The id of the scale referenced by this outcome.

$scaleid

◆ $shortname

string grade_outcome::$shortname

The shortname of the outcome.

$shortname

◆ $table

string grade_outcome::$table = 'grade_outcomes'

DB Table (used by grade_object).

$table

◆ $timecreated

int grade_object::$timecreated
inherited

The first time this grade_object was created.

$timecreated

◆ $timemodified

int grade_object::$timemodified
inherited

The last time this grade_object was modified.

$timemodified

◆ $usermodified

int grade_outcome::$usermodified

The userid of the person who last modified this outcome.

$usermodified


The documentation for this class was generated from the following file: