|
Moodle
2.2.1
http://www.collinsharper.com
|
Definition at line 115 of file completionlib.php.
| __construct | ( | $ | course | ) |
Constructs with course details.
| object | $course | Moodle course object. Must have at least ->id, ->enablecompletion |
Definition at line 155 of file completionlib.php.
| clear_criteria | ( | ) |
Clear old course completion criteria
Definition at line 403 of file completionlib.php.

| 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
| int | $user_id | Optionally only get course completion data for a single user |
Definition at line 664 of file completionlib.php.

| 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
| object | $cm | Activity |
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
| object | $cm | Activity |
Definition at line 720 of file completionlib.php.


Deletes all course completion completion data.
Intended to be used when unlocking completion criteria settings.
object
Definition at line 704 of file completionlib.php.

Returns the 'Your progress' help icon, if completion tracking is enabled. object
Definition at line 229 of file completionlib.php.


| 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.
| integer | $groupid |
Definition at line 1108 of file completionlib.php.


| 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
| array | $modinfo | For unit testing only, supply the value here. Otherwise the method calls get_fast_modinfo |
Definition at line 971 of file completionlib.php.

| get_aggregation_method | ( | $ | criteriatype = null | ) |
Get aggregation method public
| $criteriatype | int optional If none supplied, get overall aggregation method |
Definition at line 368 of file completionlib.php.
| static get_aggregation_methods | ( | ) | [static] |
Return array of aggregation methods public
Definition at line 143 of file completionlib.php.
| get_completion | ( | $ | user_id, |
| $ | criteriatype | ||
| ) |
Get a course completion for a user public
| $user_id | int User id |
| $criteriatype | int Specific criteria type to return |
Definition at line 247 of file completionlib.php.

| get_completions | ( | $ | user_id, |
| $ | criteriatype = null |
||
| ) |
Get all course criteria's completion objects for a user public
| $user_id | int User id |
| $criteriatype | int optional Specific criteria type to return |
Definition at line 266 of file completionlib.php.


| get_criteria | ( | $ | criteriatype = null | ) |
Get course completion criteria public
| $criteriatype | int optional Specific criteria type to return |
Definition at line 323 of file completionlib.php.


| 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
| object | $cm | Activity; only required field is ->id |
| bool | $wholecourse | If true (default false) then, when necessary to fill the cache, retrieves information from the entire course not just for this one activity |
| int | $userid | User ID or 0 (default) for current user |
| array | $modinfo | Supply 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. |
Definition at line 818 of file completionlib.php.


Get incomplete course completion criteria public
Definition at line 388 of file completionlib.php.

| 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
| string | $where | Where clause sql |
| array | $where_params | Where clause params |
| int | $groupid | Group id |
Definition at line 1032 of file completionlib.php.

| 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
| bool | $sortfirstname | If true, sort by first name, otherwise sort by last name |
| string | $where | Where clause sql (optional) |
| array | $where_params | Where clause params (optional) |
| int | $groupid | Group ID or 0 (default)/false for all groups |
| int | $pagesize | Number of users to actually return (optional) |
| int | $start | User to start at if paging (optional) |
| context | $extracontext | If set, includes extra user information fields as appropriate to display for current user in this context |
Definition at line 1204 of file completionlib.php.

| 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
| string | $where | Where clause sql (optional) |
| array | $where_params | Where clause params (optional) |
| integer | $groupid | Group ID to restrict to (optional) |
| string | $sort | Order by clause (optional) |
| integer | $limitfrom | Result start (optional) |
| integer | $limitnum | Result max size (optional) |
| context | $extracontext | If set, includes extra user information fields as appropriate to display for current user in this context |
Definition at line 1064 of file completionlib.php.


| get_user_completion | ( | $ | user_id, |
| $ | criteria | ||
| ) |
Get completion object for a user and a criteria public
| $user_id | int User id |
| $criteria | completion_criteria Criteria object |
Definition at line 294 of file completionlib.php.
| has_criteria | ( | ) |
Check if course has completion criteria set
public
Definition at line 310 of file completionlib.php.

| 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
| object | $cm | Course-module for item that owns grade |
| grade_item | $item | Grade item |
| object | $grade | |
| bool | $deleted |
Definition at line 1259 of file completionlib.php.

| 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
| object | $item | grade_item |
| object | $grade | grade_grade |
Definition at line 1297 of file completionlib.php.

| 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
| object | $cm | Activity |
| int | $userid | ID of user |
| object | $current | Previous completion information from database |
Definition at line 527 of file completionlib.php.


| 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
| object | $cm | Activity |
| object | $data | Data about completion for that user |
Definition at line 935 of file completionlib.php.


| internal_systemerror | ( | $ | error | ) |
This is to be used only for system errors (things that shouldn't happen) and not user-level errors.
object
| string | $error | Error string (will not be displayed to user unless debugging is enabled) |
Definition at line 1335 of file completionlib.php.

| is_course_complete | ( | $ | user_id | ) |
Has the supplied user completed this course public
| $user_id | int User's id |
Definition at line 417 of file completionlib.php.
| is_course_locked | ( | ) |
Check if this course's completion criteria should be locked
Definition at line 692 of file completionlib.php.

| is_enabled | ( | $ | cm = null | ) |
Checks whether completion is enabled in a particular course and possibly activity.
object COMPLETION_DISABLED COMPLETION_ENABLED
| object | $cm | Course-module object. If not specified, returns the course completion enable state. |
Definition at line 187 of file completionlib.php.

| static is_enabled_for_site | ( | ) | [static] |
Determines whether completion is enabled across entire site.
Static function.
object
Definition at line 169 of file completionlib.php.

| is_tracked_user | ( | $ | userid | ) |
Checks to see if the userid supplied has a tracked role in this course
| $userid | User id |
Definition at line 1007 of file completionlib.php.

| print_help_icon | ( | ) |
Displays the 'Your progress' help icon, if completion tracking is enabled. Just prints the result of display_help_icon().
Definition at line 220 of file completionlib.php.

| 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
| object | $cm | Activity |
Definition at line 767 of file completionlib.php.

| 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
| object | $cm | Activity |
| int | $userid | User ID or 0 (default) for current user |
Definition at line 610 of file completionlib.php.

| 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
| object | $cm | Course-module |
| int | $possibleresult | Expected 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 | $userid | User ID to be updated. Default 0 = current user |
Definition at line 465 of file completionlib.php.


| static wipe_session_cache | ( | ) | [static] |
For testing only. Wipes information cached in user session.
object
Definition at line 1346 of file completionlib.php.

| $course_id |
Definition at line 128 of file completionlib.php.