Moodle  2.2.1
http://www.collinsharper.com
completion_info Class Reference

Public Member Functions

 __construct ($course)
 is_enabled ($cm=null)
 print_help_icon ()
 display_help_icon ()
 get_completion ($user_id, $criteriatype)
 get_completions ($user_id, $criteriatype=null)
 get_user_completion ($user_id, $criteria)
 has_criteria ()
 get_criteria ($criteriatype=null)
 get_aggregation_method ($criteriatype=null)
 get_incomplete_criteria ()
 clear_criteria ()
 is_course_complete ($user_id)
 update_state ($cm, $possibleresult=COMPLETION_UNKNOWN, $userid=0)
 internal_get_state ($cm, $userid, $current)
 set_module_viewed ($cm, $userid=0)
 count_user_data ($cm)
 count_course_user_data ($user_id=null)
 is_course_locked ()
 delete_course_completion_data ()
 delete_all_state ($cm)
 reset_all_state ($cm)
 get_data ($cm, $wholecourse=false, $userid=0, $modinfo=null)
 internal_set_data ($cm, $data)
 get_activities ($modinfo=null)
 is_tracked_user ($userid)
 get_num_tracked_users ($where= '', $where_params=array(), $groupid=0)
 get_tracked_users ($where= '', $where_params=array(), $groupid=0, $sort= '', $limitfrom= '', $limitnum= '', context $extracontext=null)
 generate_tracked_user_sql ($groupid=0)
 get_progress_all ($where= '', $where_params=array(), $groupid=0, $sort= '', $pagesize= '', $start= '', context $extracontext=null)
 inform_grade_changed ($cm, $item, $grade, $deleted)
 internal_get_grade_state ($item, $grade)
 internal_systemerror ($error)

Static Public Member Functions

static get_aggregation_methods ()
static is_enabled_for_site ()
static wipe_session_cache ()

Data Fields

 $course_id

Detailed Description

Definition at line 115 of file completionlib.php.


Constructor & Destructor Documentation

__construct ( course)

Constructs with course details.

Parameters:
object$courseMoodle course object. Must have at least ->id, ->enablecompletion

Definition at line 155 of file completionlib.php.


Member Function Documentation

Clear old course completion criteria

Definition at line 403 of file completionlib.php.

Here is the call graph for this function:

count_course_user_data ( user_id = null)

Determines how much course completion data exists for a course. This is used when deciding whether completion information should be 'locked' in the completion settings form and activity completion settings.

object

Parameters:
int$user_idOptionally only get course completion data for a single user
Returns:
int The number of users who have completion data stored for this course, 0 if none

Definition at line 664 of file completionlib.php.

Here is the caller graph for this function:

count_user_data ( cm)

Determines how much completion data exists for an activity. This is used when deciding whether completion information should be 'locked' in the module editing form.

object

Parameters:
object$cmActivity
Returns:
int The number of users who have completion data stored for this activity, 0 if none

Definition at line 642 of file completionlib.php.

delete_all_state ( cm)

Deletes completion state related to an activity for all users.

Intended for use only when the activity itself is deleted.

object object

Parameters:
object$cmActivity

Definition at line 720 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Deletes all course completion completion data.

Intended to be used when unlocking completion criteria settings.

object

Returns:
void

Definition at line 704 of file completionlib.php.

Here is the caller graph for this function:

Returns the 'Your progress' help icon, if completion tracking is enabled. object

Returns:
string HTML code for help icon, or blank if not needed

Definition at line 229 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

generate_tracked_user_sql ( groupid = 0)

Generate the SQL for finding tracked users in this course

Returns an object containing the sql fragment and an array of bound data params.

Parameters:
integer$groupid
Returns:
object

Definition at line 1108 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_activities ( modinfo = null)

Obtains a list of activities for which completion is enabled on the course. The list is ordered by the section order of those activities.

object COMPLETION_TRACKING_NONE

Parameters:
array$modinfoFor unit testing only, supply the value here. Otherwise the method calls get_fast_modinfo
Returns:
array Array from $cmid => $cm of all activities with completion enabled, empty array if none

Definition at line 971 of file completionlib.php.

Here is the call graph for this function:

get_aggregation_method ( criteriatype = null)

Get aggregation method public

Parameters:
$criteriatypeint optional If none supplied, get overall aggregation method
Returns:
int

Definition at line 368 of file completionlib.php.

static get_aggregation_methods ( ) [static]

Return array of aggregation methods public

Returns:
array

Definition at line 143 of file completionlib.php.

get_completion ( user_id,
criteriatype 
)

Get a course completion for a user public

Parameters:
$user_idint User id
$criteriatypeint Specific criteria type to return
Returns:
false|completion_criteria_completion

Definition at line 247 of file completionlib.php.

Here is the call graph for this function:

get_completions ( user_id,
criteriatype = null 
)

Get all course criteria's completion objects for a user public

Parameters:
$user_idint User id
$criteriatypeint optional Specific criteria type to return
Returns:
array

Definition at line 266 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_criteria ( criteriatype = null)

Get course completion criteria public

Parameters:
$criteriatypeint optional Specific criteria type to return
Returns:
void

Definition at line 323 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_data ( cm,
wholecourse = false,
userid = 0,
modinfo = null 
)

Obtains completion data for a particular activity and user (from the session cache if available, or by SQL query)

object object object object COMPLETION_CACHE_EXPIRY

Parameters:
object$cmActivity; only required field is ->id
bool$wholecourseIf true (default false) then, when necessary to fill the cache, retrieves information from the entire course not just for this one activity
int$useridUser ID or 0 (default) for current user
array$modinfoSupply the value here - this is used for unit testing and so that it can be called recursively from within get_fast_modinfo. (Needs only list of all CMs with IDs.) Otherwise the method calls get_fast_modinfo itself.
Returns:
object Completion data (record from course_modules_completion)

Definition at line 818 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Get incomplete course completion criteria public

Returns:
void

Definition at line 388 of file completionlib.php.

Here is the call graph for this function:

get_num_tracked_users ( where = '',
where_params = array(),
groupid = 0 
)

Return number of users whose progress is tracked in this course

Optionally supply a search's where clause, or a group id

Parameters:
string$whereWhere clause sql
array$where_paramsWhere clause params
int$groupidGroup id
Returns:
int

Definition at line 1032 of file completionlib.php.

Here is the call graph for this function:

get_progress_all ( where = '',
where_params = array(),
groupid = 0,
sort = '',
pagesize = '',
start = '',
context extracontext = null 
)

Obtains progress information across a course for all users on that course, or for all users in a specific group. Intended for use when displaying progress.

This includes only users who, in course context, have one of the roles for which progress is tracked (the gradebookroles admin option) and are enrolled in course.

Users are included (in the first array) even if they do not have completion progress for any course-module.

object object

Parameters:
bool$sortfirstnameIf true, sort by first name, otherwise sort by last name
string$whereWhere clause sql (optional)
array$where_paramsWhere clause params (optional)
int$groupidGroup ID or 0 (default)/false for all groups
int$pagesizeNumber of users to actually return (optional)
int$startUser to start at if paging (optional)
context$extracontextIf set, includes extra user information fields as appropriate to display for current user in this context
Returns:
Object with ->total and ->start (same as $start) and ->users; an array of user objects (like mdl_user id, firstname, lastname) containing an additional ->progress array of coursemoduleid => completionstate

Definition at line 1204 of file completionlib.php.

Here is the call graph for this function:

get_tracked_users ( where = '',
where_params = array(),
groupid = 0,
sort = '',
limitfrom = '',
limitnum = '',
context extracontext = null 
)

Return array of users whose progress is tracked in this course

Optionally supply a search's where caluse, group id, sorting, paging

Parameters:
string$whereWhere clause sql (optional)
array$where_paramsWhere clause params (optional)
integer$groupidGroup ID to restrict to (optional)
string$sortOrder by clause (optional)
integer$limitfromResult start (optional)
integer$limitnumResult max size (optional)
context$extracontextIf set, includes extra user information fields as appropriate to display for current user in this context
Returns:
array

Definition at line 1064 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_user_completion ( user_id,
criteria 
)

Get completion object for a user and a criteria public

Parameters:
$user_idint User id
$criteriacompletion_criteria Criteria object
Returns:
completion_criteria_completion

Definition at line 294 of file completionlib.php.

Check if course has completion criteria set

public

Returns:
bool

Definition at line 310 of file completionlib.php.

Here is the call graph for this function:

inform_grade_changed ( cm,
item,
grade,
deleted 
)

Called by grade code to inform the completion system when a grade has been changed. If the changed grade is used to determine completion for the course-module, then the completion status will be updated.

COMPLETION_TRACKING_MANUAL COMPLETION_INCOMPLETE

Parameters:
object$cmCourse-module for item that owns grade
grade_item$itemGrade item
object$grade
bool$deleted
Returns:
void

Definition at line 1259 of file completionlib.php.

Here is the call graph for this function:

internal_get_grade_state ( item,
grade 
)

Calculates the completion state that would result from a graded item (where grade-based completion is turned on) based on the actual grade and settings.

Internal function. Not private, so we can unit-test it.

COMPLETION_INCOMPLETE COMPLETION_COMPLETE_PASS COMPLETION_COMPLETE_FAIL COMPLETION_COMPLETE

Parameters:
object$itemgrade_item
object$gradegrade_grade
Returns:
int Completion state e.g. COMPLETION_INCOMPLETE

Definition at line 1297 of file completionlib.php.

Here is the caller graph for this function:

internal_get_state ( cm,
userid,
current 
)

Calculates the completion state for an activity and user.

Internal function. Not private, so we can unit-test it.

object object object COMPLETION_VIEW_REQUIRED COMPLETION_NOT_VIEWED COMPLETION_INCOMPLETE FEATURE_COMPLETION_HAS_RULES COMPLETION_COMPLETE COMPLETION_AND

Parameters:
object$cmActivity
int$useridID of user
object$currentPrevious completion information from database
Returns:
mixed

Definition at line 527 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

internal_set_data ( cm,
data 
)

Updates completion data for a particular coursemodule and user (user is determined from $data).

(Internal function. Not private, so we can unit-test it.)

object object object

Parameters:
object$cmActivity
object$dataData about completion for that user

Definition at line 935 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

internal_systemerror ( error)

This is to be used only for system errors (things that shouldn't happen) and not user-level errors.

object

Parameters:
string$errorError string (will not be displayed to user unless debugging is enabled)
Returns:
void Throws moodle_exception Exception with the error string as debug info

Definition at line 1335 of file completionlib.php.

Here is the caller graph for this function:

is_course_complete ( user_id)

Has the supplied user completed this course public

Parameters:
$user_idint User's id
Returns:
boolean

Definition at line 417 of file completionlib.php.

Check if this course's completion criteria should be locked

Returns:
boolean

Definition at line 692 of file completionlib.php.

Here is the call graph for this function:

is_enabled ( cm = null)

Checks whether completion is enabled in a particular course and possibly activity.

object COMPLETION_DISABLED COMPLETION_ENABLED

Parameters:
object$cmCourse-module object. If not specified, returns the course completion enable state.
Returns:
mixed COMPLETION_ENABLED or COMPLETION_DISABLED (==0) in the case of site and course; COMPLETION_TRACKING_MANUAL, _AUTOMATIC or _NONE (==0) for a course-module.

Definition at line 187 of file completionlib.php.

Here is the caller graph for this function:

static is_enabled_for_site ( ) [static]

Determines whether completion is enabled across entire site.

Static function.

object

Returns:
int COMPLETION_ENABLED (true) if completion is enabled for the site, COMPLETION_DISABLED (false) if it's complete

Definition at line 169 of file completionlib.php.

Here is the caller graph for this function:

is_tracked_user ( userid)

Checks to see if the userid supplied has a tracked role in this course

Parameters:
$useridUser id
Returns:
bool

Definition at line 1007 of file completionlib.php.

Here is the call graph for this function:

Displays the 'Your progress' help icon, if completion tracking is enabled. Just prints the result of display_help_icon().

Deprecated:
Use display_help_icon instead.
Returns:
void

Definition at line 220 of file completionlib.php.

Here is the call graph for this function:

reset_all_state ( cm)

Recalculates completion state related to an activity for all users.

Intended for use if completion conditions change. (This should be avoided as it may cause some things to become incomplete when they were previously complete, with the effect - for example - of hiding a later activity that was previously available.)

Resetting state of manual tickbox has same result as deleting state for it.

object COMPLETION_TRACKING_MANUAL COMPLETION_UNKNOWN

Parameters:
object$cmActivity

Definition at line 767 of file completionlib.php.

Here is the call graph for this function:

set_module_viewed ( cm,
userid = 0 
)

Marks a module as viewed.

Should be called whenever a module is 'viewed' (it is up to the module how to determine that). Has no effect if viewing is not set as a completion condition.

Note that this function must be called before you print the page header because it is possible that the navigation block may depend on it. If you call it after printing the header, it shows a developer debug warning. COMPLETION_VIEW_NOT_REQUIRED COMPLETION_VIEWED COMPLETION_COMPLETE

Parameters:
object$cmActivity
int$useridUser ID or 0 (default) for current user
Returns:
void

Definition at line 610 of file completionlib.php.

Here is the call graph for this function:

update_state ( cm,
possibleresult = COMPLETION_UNKNOWN,
userid = 0 
)

Updates (if necessary) the completion state of activity $cm for the given user.

For manual completion, this function is called when completion is toggled with $possibleresult set to the target state.

For automatic completion, this function should be called every time a module does something which might influence a user's completion state. For example, if a forum provides options for marking itself 'completed' once a user makes N posts, this function should be called every time a user makes a new post. [After the post has been saved to the database]. When calling, you do not need to pass in the new completion state. Instead this function carries out completion calculation by checking grades and viewed state itself, and calling the involved module via modulename_get_completion_state() to check module-specific conditions.

object object COMPLETION_COMPLETE COMPLETION_INCOMPLETE COMPLETION_COMPLETE_PASS COMPLETION_COMPLETE_FAIL COMPLETION_TRACKING_MANUAL

Parameters:
object$cmCourse-module
int$possibleresultExpected completion result. If the event that has just occurred (e.g. add post) can only result in making the activity complete when it wasn't before, use COMPLETION_COMPLETE. If the event that has just occurred (e.g. delete post) can only result in making the activity not complete when it was previously complete, use COMPLETION_INCOMPLETE. Otherwise use COMPLETION_UNKNOWN. Setting this value to something other than COMPLETION_UNKNOWN significantly improves performance because it will abandon processing early if the user's completion state already matches the expected result. For manual events, COMPLETION_COMPLETE or COMPLETION_INCOMPLETE must be used; these directly set the specified state.
int$useridUser ID to be updated. Default 0 = current user
Returns:
void

Definition at line 465 of file completionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static wipe_session_cache ( ) [static]

For testing only. Wipes information cached in user session.

object

Definition at line 1346 of file completionlib.php.

Here is the caller graph for this function:


Field Documentation

$course_id

Definition at line 128 of file completionlib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations