Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
completion_criteria_activity Class Reference

Course completion critieria - completion on activity completion. More...

Inheritance diagram for completion_criteria_activity:
completion_criteria data_object

Public Member Functions

 config_form_display (&$mform, $data=null)
 Add appropriate form elements to the critieria form.
 
 cron ()
 Find users who have completed this criteria and mark them accordingly.
 
 delete ()
 Deletes this object from the database.
 
 get_details ($completion)
 Return criteria progress details for display in reports.
 
 get_icon ($alt, array $attributes=null)
 Return pix_icon for display in reports.
 
 get_mod_instance ()
 Gets the module instance from the database and returns it.
 
 get_record_data ()
 Returns object with fields and values that are defined in database.
 
 get_status ($completion)
 Return criteria status text for display in reports.
 
 get_title ()
 Return criteria title for display in reports.
 
 get_title_detailed ()
 Return a more detailed criteria title for display in reports.
 
 get_type_title ()
 Return criteria type title for display in reports.
 
 insert ()
 Records this object in the Database, sets its id to the returned value, and returns that value.
 
 is_pending ($completion)
 Return true if the criteria's current status is different to what is sorted in the database, e.g.
 
 load_optional_fields ()
 Makes sure all the optional fields are loaded.
 
 notify_changed ($deleted)
 Called immediately after the object data has been inserted, updated, or deleted in the database.
 
 review ($completion, $mark=true)
 Review this criteria and decide if the user has completed.
 
 update ()
 Updates this object in the Database, based on its object variables.
 
 update_config (&$data)
 Update the criteria information stored in the database.
 
 update_from_db ()
 Using this object's id field, fetches the matching record in the DB, and looks at each variable in turn.
 

Static Public Member Functions

static factory ($params)
 Factory method for creating correct class object.
 
static fetch ($params)
 Finds and returns a data_object instance based on params.
 
static fetch_all ($params)
 Finds and returns all data_object instances based on params.
 
static fetch_all_helper ($table, $classname, $params)
 Factory method - uses the parameters to retrieve all matching instances from the DB.
 
static get_mod_name ($type)
 Get module instance module type.
 
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 $completedself
 completed status.
 
int $course
 
string $courseinstance
 course instance.
 
int $criteriatype = COMPLETION_CRITERIA_TYPE_ACTIVITY
 
int $date
 Date of course completion (for date criteria) This is a timestamp value.
 
int $enrolperiod
 Period after enrolment completion will be triggered (for period criteria) The value here is the number of days as an int.
 
float $gradepass
 
int $id
 
string $module
 
int $moduleinstance
 
array $optional_fields = array()
 Array of optional fields with default values - usually long text information that is not always needed.
 
array $required_fields = array('id', 'course', 'criteriatype', 'module', 'moduleinstance', 'courseinstance', 'enrolperiod', 'timeend', 'gradepass', 'role')
 Array of required table fields, must start with 'id'.
 
int $role
 
string $table = 'course_completion_criteria'
 
mixed $timeend
 time end.
 
Array $unique_fields = array()
 

Static Protected Member Functions

static fetch_helper ($table, $classname, $params)
 Factory method - uses the parameters to retrieve matching instance from the DB.
 

Detailed Description

Course completion critieria - completion on activity completion.

Author
Aaron Barnes aaron.nosp@m.b@ca.nosp@m.talys.nosp@m.t.ne.nosp@m.t.nz
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ config_form_display()

completion_criteria_activity::config_form_display ( & $mform,
$data = null )

Add appropriate form elements to the critieria form.

Parameters
moodleform$mformMoodle forms object
stdClass$datadetails of various modules

Reimplemented from completion_criteria.

◆ delete()

data_object::delete ( )
inherited

Deletes this object from the database.

Return values
boolsuccess

◆ factory()

static completion_criteria::factory ( $params)
staticinherited

Factory method for creating correct class object.

Parameters
array$paramsassociative arrays varname=>value
Return values
completion_criteria

◆ fetch()

static completion_criteria_activity::fetch ( $params)
static

Finds and returns a data_object instance based on params.

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

Reimplemented from data_object.

◆ fetch_all()

static completion_criteria::fetch_all ( $params)
staticinherited

Finds and returns all data_object instances based on params.

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

Reimplemented from data_object.

◆ fetch_all_helper()

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

Factory method - uses the parameters to retrieve all matching instances from the DB.

@final

Parameters
string$tableThe table name to fetch from
string$classnameThe class that you want the result instantiated as
array$paramsAny params required to select the desired row
Return values
mixedarray of object instances or false if not found

◆ fetch_helper()

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

Factory method - uses the parameters to retrieve matching instance from the DB.

@final

Parameters
string$tableThe table name to fetch from
string$classnameThe class that you want the result instantiated as
array$paramsAny params required to select the desired row
Return values
objectInstance of $classname or false.

◆ get_details()

completion_criteria_activity::get_details ( $completion)

Return criteria progress details for display in reports.

Parameters
completion_completion$completionThe user's completion record
Return values
arrayAn array with the following keys: type, criteria, requirement, status

Reimplemented from completion_criteria.

◆ get_icon()

completion_criteria_activity::get_icon ( $alt,
array $attributes = null )

Return pix_icon for display in reports.

Parameters
string$altThe alt text to use for the icon
array$attributeshtml attributes
Return values
pix_icon

Reimplemented from completion_criteria.

◆ get_mod_instance()

completion_criteria_activity::get_mod_instance ( )

Gets the module instance from the database and returns it.

If no module instance exists this function returns false.

Return values
stdClass|bool

◆ get_mod_name()

static completion_criteria_activity::get_mod_name ( $type)
static

Get module instance module type.

Parameters
int$typeModule type id
Return values
string

◆ get_record_data()

data_object::get_record_data ( )
inherited

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

Return values
stdClass

◆ get_status()

completion_criteria::get_status ( $completion)
inherited

Return criteria status text for display in reports.

Parameters
completion_completion$completionThe user's completion record
Return values
string

Reimplemented in completion_criteria_date, and completion_criteria_duration.

◆ get_title()

completion_criteria_activity::get_title ( )

Return criteria title for display in reports.

Return values
string

Reimplemented from completion_criteria.

◆ get_title_detailed()

completion_criteria_activity::get_title_detailed ( )

Return a more detailed criteria title for display in reports.

Return values
string

Reimplemented from completion_criteria.

◆ get_type_title()

completion_criteria_activity::get_type_title ( )

Return criteria type title for display in reports.

Return values
string

Reimplemented from completion_criteria.

◆ insert()

data_object::insert ( )
inherited

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 values
intPK ID if successful, false otherwise

◆ is_pending()

completion_criteria::is_pending ( $completion)
inherited

Return true if the criteria's current status is different to what is sorted in the database, e.g.

pending an update

Parameters
completion_completion$completionThe user's criteria completion record
Return values
bool

◆ load_optional_fields()

data_object::load_optional_fields ( )
inherited

Makes sure all the optional fields are loaded.

If id present (==instance exists in db) fetches data from db. Defaults are used for new instances.

◆ notify_changed()

data_object::notify_changed ( $deleted)
inherited

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$deletedSet this to true if it has been deleted.

◆ review()

completion_criteria_activity::review ( $completion,
$mark = true )

Review this criteria and decide if the user has completed.

Parameters
completion_completion$completionThe user's completion record
bool$markOptionally set false to not save changes to database
Return values
bool

Reimplemented from completion_criteria.

◆ set_properties()

static data_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.

@final

Parameters
data_object$instance
array$params

◆ update()

data_object::update ( )
inherited

Updates this object in the Database, based on its object variables.

ID must be set.

Return values
boolsuccess

◆ update_config()

completion_criteria_activity::update_config ( & $data)

Update the criteria information stored in the database.

Parameters
stdClass$dataForm data

Reimplemented from completion_criteria.

◆ update_from_db()

data_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 for success, false otherwise.

Member Data Documentation

◆ $optional_fields

array data_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 data_object($only_required_fields, false);

◆ $required_fields

array completion_criteria::$required_fields = array('id', 'course', 'criteriatype', 'module', 'moduleinstance', 'courseinstance', 'enrolperiod', 'timeend', 'gradepass', 'role')
inherited

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

Defaults to id, course, criteriatype, module, moduleinstane, courseinstance, enrolperiod, timeend, gradepass, role


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