Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Class for loading/storing competency frameworks from the DB.

Copyright: 2015 Damyon Wiese
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 5373 lines (209 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

api:: (140 methods):
  is_enabled()
  show_links()
  skip_enabled()
  check_enabled()
  require_enabled()
  is_scale_used_anywhere()
  validate_course_module()
  validate_course()
  create_competency()
  delete_competency()
  move_down_competency()
  move_up_competency()
  set_parent_competency()
  update_competency()
  read_competency()
  search_competencies()
  list_competencies()
  count_competencies()
  create_framework()
  duplicate_framework()
  delete_framework()
  update_framework()
  read_framework()
  competency_framework_viewed()
  competency_viewed()
  list_frameworks()
  count_frameworks()
  get_related_contexts()
  count_courses_using_competency()
  list_course_modules_using_competency()
  list_course_module_competencies_in_course_module()
  list_courses_using_competency()
  count_proficient_competencies_in_course_for_user()
  count_competencies_in_course()
  list_course_competencies()
  get_user_competency()
  get_user_competency_by_id()
  count_course_module_competencies()
  list_course_module_competencies()
  get_user_competency_in_course()
  list_user_competencies_in_course()
  list_user_competencies_to_review()
  add_competency_to_course_module()
  remove_competency_from_course_module()
  reorder_course_module_competency()
  set_course_module_competency_ruleoutcome()
  add_competency_to_course()
  remove_competency_from_course()
  reorder_course_competency()
  set_course_competency_ruleoutcome()
  create_template()
  duplicate_template()
  delete_template()
  update_template()
  read_template()
  list_templates()
  count_templates()
  count_templates_using_competency()
  list_templates_using_competency()
  count_competencies_in_template()
  count_competencies_in_template_with_no_courses()
  list_competencies_in_template()
  add_competency_to_template()
  remove_competency_from_template()
  reorder_template_competency()
  create_template_cohort()
  delete_template_cohort()
  list_user_plans()
  list_plans_to_review()
  create_plan()
  create_plan_from_template()
  create_plans_from_template_cohort()
  unlink_plan_from_template()
  update_plan()
  read_plan()
  plan_viewed()
  delete_plan()
  plan_cancel_review_request()
  plan_request_review()
  plan_start_review()
  plan_stop_review()
  approve_plan()
  unapprove_plan()
  complete_plan()
  reopen_plan()
  get_plan_competency()
  list_plans_with_competency()
  list_plan_competencies()
  add_competency_to_plan()
  remove_competency_from_plan()
  reorder_plan_competency()
  user_competency_cancel_review_request()
  user_competency_request_review()
  user_competency_start_review()
  user_competency_stop_review()
  user_competency_viewed()
  user_competency_viewed_in_plan()
  user_competency_viewed_in_course()
  user_competency_plan_viewed()
  template_has_related_data()
  list_related_competencies()
  add_related_competency()
  remove_related_competency()
  read_user_evidence()
  create_user_evidence()
  update_user_evidence()
  delete_user_evidence()
  list_user_evidence()
  create_user_evidence_competency()
  delete_user_evidence_competency()
  request_review_of_user_evidence_linked_competencies()
  duplicate_competency_tree()
  migrate_competency_tree_rules()
  archive_user_competencies_in_plan()
  remove_archived_user_competencies_in_plan()
  list_evidence()
  list_evidence_in_course()
  add_evidence()
  read_evidence()
  delete_evidence()
  apply_competency_rules_from_usercompetency()
  observe_course_module_completion_updated()
  observe_course_completed()
  hook_course_module_deleted()
  hook_course_deleted()
  hook_course_reset_competency_ratings()
  hook_cohort_deleted()
  hook_user_deleted()
  grade_competency()
  grade_competency_in_plan()
  grade_competency_in_course()
  count_plans_for_template()
  count_user_competency_plans_for_template()
  list_plans_for_template()
  get_least_proficient_competencies_for_course()
  get_least_proficient_competencies_for_template()
  template_viewed()
  read_course_competency_settings()
  update_course_competency_settings()
  filter_users_with_capability_on_user_context_sql()


Class: api  - X-Ref

Class for doing things with competency frameworks.

is_enabled()   X-Ref
Returns whether competencies are enabled.

This method should never do more than checking the config setting, the reason
being that some other code could be checking the config value directly
to avoid having to load this entire file into memory.

return: boolean True when enabled.

show_links()   X-Ref
When competencies used to be enabled, we can show the text but do not include links.

return: boolean True means show links.

skip_enabled()   X-Ref
Allow calls to competency api functions even if competencies are not currently enabled.


check_enabled()   X-Ref
Restore the checking that competencies are enabled with any api function.


require_enabled()   X-Ref
Throws an exception if competencies are not enabled.

return: void

is_scale_used_anywhere($scaleid)   X-Ref
Checks whether a scale is used anywhere in the plugin.

This public API has two exceptions:
- It MUST NOT perform any capability checks.
- It MUST ignore whether competencies are enabled or not ({@link self::is_enabled()}).

return: bool
param: int $scaleid The scale ID.

validate_course_module($cmmixed, $throwexception = true)   X-Ref
Validate if current user have acces to the course_module if hidden.

return: bool
param: mixed $cmmixed The cm_info class, course module record or its ID.
param: bool $throwexception Throw an exception or not.

validate_course($courseorid, $throwexception = true)   X-Ref
Validate if current user have acces to the course if hidden.

return: bool
param: mixed $courseorid The course or it ID.
param: bool $throwexception Throw an exception or not.

create_competency(stdClass $record)   X-Ref
Create a competency from a record containing all the data for the class.

Requires moodle/competency:competencymanage capability at the system context.

return: competency
param: stdClass $record Record containing all the data for an instance of the class.

delete_competency($id)   X-Ref
Delete a competency by id.

Requires moodle/competency:competencymanage capability at the system context.

return: boolean
param: int $id The record to delete. This will delete alot of related data - you better be sure.

move_down_competency($id)   X-Ref
Reorder this competency.

Requires moodle/competency:competencymanage capability at the system context.

return: boolean
param: int $id The id of the competency to move.

move_up_competency($id)   X-Ref
Reorder this competency.

Requires moodle/competency:competencymanage capability at the system context.

return: boolean
param: int $id The id of the competency to move.

set_parent_competency($id, $newparentid)   X-Ref
Move this competency so it sits in a new parent.

Requires moodle/competency:competencymanage capability at the system context.

return: boolean
param: int $id The id of the competency to move.
param: int $newparentid The new parent id for the competency.

update_competency($record)   X-Ref
Update the details for a competency.

Requires moodle/competency:competencymanage capability at the system context.

return: boolean
param: stdClass $record The new details for the competency.

read_competency($id, $includerelated = false)   X-Ref
Read a the details for a single competency and return a record.

Requires moodle/competency:competencyview capability at the system context.

return: stdClass
param: int $id The id of the competency to read.
param: bool $includerelated Include related tags or not.

search_competencies($textsearch, $competencyframeworkid)   X-Ref
Perform a text search based and return all results and their parents.

Requires moodle/competency:competencyview capability at the framework context.

return: array of competencies
param: string $textsearch A string to search for.
param: int $competencyframeworkid The id of the framework to limit the search.

list_competencies($filters, $sort = '', $order = 'ASC', $skip = 0, $limit = 0)   X-Ref
Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/competency:competencyview capability at some context.

return: array of competencies
param: array $filters A list of filters to apply to the list.
param: string $sort The column to sort on
param: string $order ('ASC' or 'DESC')
param: int $skip Number of records to skip (pagination)
param: int $limit Max of records to return (pagination)

count_competencies($filters)   X-Ref
Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/competency:competencyview capability at some context.

return: int
param: array $filters A list of filters to apply to the list.

create_framework(stdClass $record)   X-Ref
Create a competency framework from a record containing all the data for the class.

Requires moodle/competency:competencymanage capability at the system context.

return: competency_framework
param: stdClass $record Record containing all the data for an instance of the class.

duplicate_framework($id)   X-Ref
Duplicate a competency framework by id.

Requires moodle/competency:competencymanage capability at the system context.

return: competency_framework the framework duplicated
param: int $id The record to duplicate. All competencies associated and related will be duplicated.

delete_framework($id)   X-Ref
Delete a competency framework by id.

Requires moodle/competency:competencymanage capability at the system context.

return: boolean
param: int $id The record to delete. This will delete alot of related data - you better be sure.

update_framework($record)   X-Ref
Update the details for a competency framework.

Requires moodle/competency:competencymanage capability at the system context.

return: boolean
param: stdClass $record The new details for the framework. Note - must contain an id that points to the framework to update.

read_framework($id)   X-Ref
Read a the details for a single competency framework and return a record.

Requires moodle/competency:competencyview capability at the system context.

return: competency_framework
param: int $id The id of the framework to read.

competency_framework_viewed($frameworkorid)   X-Ref
Logg the competency framework viewed event.

return: bool
param: competency_framework|int $frameworkorid The competency_framework object or competency framework id

competency_viewed($competencyorid)   X-Ref
Logg the competency viewed event.

return: bool
param: competency|int $competencyorid The competency object or competency id

list_frameworks($sort, $order, $skip, $limit, $context, $includes = 'children',$onlyvisible = false, $query = '')   X-Ref
Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/competency:competencyview capability at the system context.

return: array of competency_framework
param: string $sort The column to sort on
param: string $order ('ASC' or 'DESC')
param: int $skip Number of records to skip (pagination)
param: int $limit Max of records to return (pagination)
param: context $context The parent context of the frameworks.
param: string $includes Defines what other contexts to fetch frameworks from.
param: bool $onlyvisible If true return only visible frameworks
param: string $query A string to use to filter down the frameworks.

count_frameworks($context, $includes)   X-Ref
Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/competency:competencyview capability at the system context.

return: int
param: context $context The parent context of the frameworks.
param: string $includes Defines what other contexts to fetch frameworks from.

get_related_contexts($context, $includes, array $hasanycapability = null)   X-Ref
Fetches all the relevant contexts.

Note: This currently only supports system, category and user contexts. However user contexts
behave a bit differently and will fallback on the system context. This is what makes the most
sense because a user context does not have descendants, and only has system as a parent.

return: context[] An array of contexts where keys are context IDs.
param: context $context The context to start from.
param: string $includes Defines what other contexts to find.
param: array $hasanycapability Array of capabilities passed to {@link has_any_capability()} in each context.

count_courses_using_competency($competencyid)   X-Ref
Count all the courses using a competency.

return: int
param: int $competencyid The id of the competency to check.

list_course_modules_using_competency($competencyid, $courseid)   X-Ref
List all the courses modules using a competency in a course.

return: array[int] Array of course modules ids.
param: int $competencyid The id of the competency to check.
param: int $courseid The id of the course to check.

list_course_module_competencies_in_course_module($cmorid)   X-Ref
List all the competencies linked to a course module.

return: array[competency] Array of competency records.
param: mixed $cmorid The course module, or its ID.

list_courses_using_competency($competencyid)   X-Ref
List all the courses using a competency.

return: array[stdClass] Array of stdClass containing id and shortname.
param: int $competencyid The id of the competency to check.

count_proficient_competencies_in_course_for_user($courseid, $userid)   X-Ref
Count the proficient competencies in a course for one user.

return: int
param: int $courseid The id of the course to check.
param: int $userid The id of the user to check.

count_competencies_in_course($courseid)   X-Ref
Count all the competencies in a course.

return: int
param: int $courseid The id of the course to check.

list_course_competencies($courseorid)   X-Ref
List the competencies associated to a course.

return: array( array(
param: mixed $courseorid The course, or its ID.

get_user_competency($userid, $competencyid)   X-Ref
Get a user competency.

return: user_competency
param: int $userid The user ID.
param: int $competencyid The competency ID.

get_user_competency_by_id($usercompetencyid)   X-Ref
Get a user competency by ID.

return: user_competency
param: int $usercompetencyid The user competency ID.

count_course_module_competencies($cmorid)   X-Ref
Count the competencies associated to a course module.

return: int
param: mixed $cmorid The course module, or its ID.

list_course_module_competencies($cmorid)   X-Ref
List the competencies associated to a course module.

return: array( array(
param: mixed $cmorid The course module, or its ID.

get_user_competency_in_course($courseid, $userid, $competencyid)   X-Ref
Get a user competency in a course.

return: user_competency_course
param: int $courseid The id of the course to check.
param: int $userid The id of the course to check.
param: int $competencyid The id of the competency.

list_user_competencies_in_course($courseid, $userid)   X-Ref
List all the user competencies in a course.

return: array of user_competency_course objects
param: int $courseid The id of the course to check.
param: int $userid The id of the course to check.

list_user_competencies_to_review($skip = 0, $limit = 50, $userid = null)   X-Ref
List the user competencies to review.

The method returns values in this format:

array(
'competencies' => array(
(stdClass)(
'usercompetency' => (user_competency),
'competency' => (competency),
'user' => (user)
)
),
'count' => (int)
)

return: array Containing the keys 'count', and 'competencies'. The 'competencies' key contains an object
param: int $skip The number of records to skip.
param: int $limit The number of results to return.
param: int $userid The user we're getting the competencies to review for.

add_competency_to_course_module($cmorid, $competencyid)   X-Ref
Add a competency to this course module.

return: bool
param: mixed $cmorid The course module, or id of the course module
param: int $competencyid The id of the competency

remove_competency_from_course_module($cmorid, $competencyid)   X-Ref
Remove a competency from this course module.

return: bool
param: mixed $cmorid The course module, or id of the course module
param: int $competencyid The id of the competency

reorder_course_module_competency($cmorid, $competencyidfrom, $competencyidto)   X-Ref
Move the course module competency up or down in the display list.

Requires moodle/competency:coursecompetencymanage capability at the course module context.

return: boolean
param: mixed $cmorid The course module, or id of the course module
param: int $competencyidfrom The id of the competency we are moving.
param: int $competencyidto The id of the competency we are moving to.

set_course_module_competency_ruleoutcome($coursemodulecompetencyorid, $ruleoutcome)   X-Ref
Update ruleoutcome value for a course module competency.

return: bool True on success.
param: int|course_module_competency $coursemodulecompetencyorid The course_module_competency, or its ID.
param: int $ruleoutcome The value of ruleoutcome.

add_competency_to_course($courseid, $competencyid)   X-Ref
Add a competency to this course.

return: bool
param: int $courseid The id of the course
param: int $competencyid The id of the competency

remove_competency_from_course($courseid, $competencyid)   X-Ref
Remove a competency from this course.

return: bool
param: int $courseid The id of the course
param: int $competencyid The id of the competency

reorder_course_competency($courseid, $competencyidfrom, $competencyidto)   X-Ref
Move the course competency up or down in the display list.

Requires moodle/competency:coursecompetencymanage capability at the course context.

return: boolean
param: int $courseid The course
param: int $competencyidfrom The id of the competency we are moving.
param: int $competencyidto The id of the competency we are moving to.

set_course_competency_ruleoutcome($coursecompetencyorid, $ruleoutcome)   X-Ref
Update ruleoutcome value for a course competency.

return: bool True on success.
param: int|course_competency $coursecompetencyorid The course_competency, or its ID.
param: int $ruleoutcome The value of ruleoutcome.

create_template(stdClass $record)   X-Ref
Create a learning plan template from a record containing all the data for the class.

Requires moodle/competency:templatemanage capability.

return: template
param: stdClass $record Record containing all the data for an instance of the class.

duplicate_template($id)   X-Ref
Duplicate a learning plan template.

Requires moodle/competency:templatemanage capability at the template context.

return: template
param: int $id the template id.

delete_template($id, $deleteplans = true)   X-Ref
Delete a learning plan template by id.
If the learning plan template has associated cohorts they will be deleted.

Requires moodle/competency:templatemanage capability.

return: boolean
param: int $id The record to delete.
param: boolean $deleteplans True to delete plans associaated to template, false to unlink them.

update_template($record)   X-Ref
Update the details for a learning plan template.

Requires moodle/competency:templatemanage capability.

return: boolean
param: stdClass $record The new details for the template. Note - must contain an id that points to the template to update.

read_template($id)   X-Ref
Read a the details for a single learning plan template and return a record.

Requires moodle/competency:templateview capability at the system context.

return: template
param: int $id The id of the template to read.

list_templates($sort, $order, $skip, $limit, $context, $includes = 'children', $onlyvisible = false)   X-Ref
Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/competency:templateview capability at the system context.

return: array of competency_framework
param: string $sort The column to sort on
param: string $order ('ASC' or 'DESC')
param: int $skip Number of records to skip (pagination)
param: int $limit Max of records to return (pagination)
param: context $context The parent context of the frameworks.
param: string $includes Defines what other contexts to fetch frameworks from.
param: bool $onlyvisible If should list only visible templates

count_templates($context, $includes)   X-Ref
Perform a search based on the provided filters and return how many results there are.

Requires moodle/competency:templateview capability at the system context.

return: int
param: context $context The parent context of the frameworks.
param: string $includes Defines what other contexts to fetch frameworks from.

count_templates_using_competency($competencyid)   X-Ref
Count all the templates using a competency.

return: int
param: int $competencyid The id of the competency to check.

list_templates_using_competency($competencyid)   X-Ref
List all the learning plan templatesd using a competency.

return: array[stdClass] Array of stdClass containing id and shortname.
param: int $competencyid The id of the competency to check.

count_competencies_in_template($templateorid)   X-Ref
Count all the competencies in a learning plan template.

return: int
param: template|int $templateorid The template or its ID.

count_competencies_in_template_with_no_courses($templateorid)   X-Ref
Count all the competencies in a learning plan template with no linked courses.

return: int
param: template|int $templateorid The template or its ID.

list_competencies_in_template($templateorid)   X-Ref
List all the competencies in a template.

return: array of competencies
param: template|int $templateorid The template or its ID.

add_competency_to_template($templateid, $competencyid)   X-Ref
Add a competency to this template.

return: bool
param: int $templateid The id of the template
param: int $competencyid The id of the competency

remove_competency_from_template($templateid, $competencyid)   X-Ref
Remove a competency from this template.

return: bool
param: int $templateid The id of the template
param: int $competencyid The id of the competency

reorder_template_competency($templateid, $competencyidfrom, $competencyidto)   X-Ref
Move the template competency up or down in the display list.

Requires moodle/competency:templatemanage capability at the system context.

return: boolean
param: int $templateid The template id
param: int $competencyidfrom The id of the competency we are moving.
param: int $competencyidto The id of the competency we are moving to.

create_template_cohort($templateorid, $cohortorid)   X-Ref
Create a relation between a template and a cohort.

This silently ignores when the relation already existed.

return: template_cohort
param: template|int $templateorid The template or its ID.
param: stdClass|int $cohortorid   The cohort ot its ID.

delete_template_cohort($templateorid, $cohortorid)   X-Ref
Remove a relation between a template and a cohort.

return: boolean True on success or when the relation did not exist.
param: template|int $templateorid The template or its ID.
param: stdClass|int $cohortorid   The cohort ot its ID.

list_user_plans($userid)   X-Ref
Lists user plans.

return: \core_competency\plan[]
param: int $userid

list_plans_to_review($skip = 0, $limit = 100, $userid = null)   X-Ref
List the plans to review.

The method returns values in this format:

array(
'plans' => array(
(stdClass)(
'plan' => (plan),
'template' => (template),
'owner' => (stdClass)
)
),
'count' => (int)
)

return: array Containing the keys 'count', and 'plans'. The 'plans' key contains an object
param: int $skip The number of records to skip.
param: int $limit The number of results to return.
param: int $userid The user we're getting the plans to review for.

create_plan(stdClass $record)   X-Ref
Creates a learning plan based on the provided data.

return: \core_competency\plan
param: stdClass $record

create_plan_from_template($templateorid, $userid)   X-Ref
Create a learning plan from a template.

return: false|\core_competency\plan Returns false when the plan already exists.
param: mixed $templateorid The template object or ID.
param: int $userid

create_plans_from_template_cohort($templateorid, $cohortid, $recreateunlinked = false)   X-Ref
Create learning plans from a template and cohort.

return: int The number of plans created.
param: mixed $templateorid The template object or ID.
param: int $cohortid The cohort ID.
param: bool $recreateunlinked When true the plans that were unlinked from this template will be re-created.

unlink_plan_from_template($planorid)   X-Ref
Unlink a plan from its template.

return: bool
param: \core_competency\plan|int $planorid The plan or its ID.

update_plan(stdClass $record)   X-Ref
Updates a plan.

return: \core_competency\plan
param: stdClass $record

read_plan($id)   X-Ref
Returns a plan data.

return: \core_competency\plan
param: int $id

plan_viewed($planorid)   X-Ref
Plan event viewed.

return: boolean
param: mixed $planorid The id or the plan.

delete_plan($id)   X-Ref
Deletes a plan.

Plans based on a template can be removed just like any other one.

return: bool Success?
param: int $id

plan_cancel_review_request($planorid)   X-Ref
Cancel the review of a plan.

return: bool
param: int|plan $planorid The plan, or its ID.

plan_request_review($planorid)   X-Ref
Request the review of a plan.

return: bool
param: int|plan $planorid The plan, or its ID.

plan_start_review($planorid)   X-Ref
Start the review of a plan.

return: bool
param: int|plan $planorid The plan, or its ID.

plan_stop_review($planorid)   X-Ref
Stop reviewing a plan.

return: bool
param: int|plan $planorid The plan, or its ID.

approve_plan($planorid)   X-Ref
Approve a plan.

This means making the plan active.

return: bool
param: int|plan $planorid The plan, or its ID.

unapprove_plan($planorid)   X-Ref
Unapprove a plan.

This means making the plan draft.

return: bool
param: int|plan $planorid The plan, or its ID.

complete_plan($planorid)   X-Ref
Complete a plan.

return: bool
param: int|plan $planorid The plan, or its ID.

reopen_plan($planorid)   X-Ref
Reopen a plan.

return: bool
param: int|plan $planorid The plan, or its ID.

get_plan_competency($planorid, $competencyid)   X-Ref
Get a single competency from the user plan.

return: (object) array(
param: int $planorid The plan, or its ID.
param: int $competencyid The competency id.

list_plans_with_competency($userid, $competencyorid)   X-Ref
List the plans with a competency.

return: array[plan] Array of learning plans.
param: int $userid The user id we want the plans for.
param: int $competencyorid The competency, or its ID.

list_plan_competencies($planorid)   X-Ref
List the competencies in a user plan.

return: array((object) array(
param: int $planorid The plan, or its ID.

add_competency_to_plan($planid, $competencyid)   X-Ref
Add a competency to a plan.

return: bool
param: int $planid The id of the plan
param: int $competencyid The id of the competency

remove_competency_from_plan($planid, $competencyid)   X-Ref
Remove a competency from a plan.

return: bool
param: int $planid The plan id
param: int $competencyid The id of the competency

reorder_plan_competency($planid, $competencyidfrom, $competencyidto)   X-Ref
Move the plan competency up or down in the display list.

Requires moodle/competency:planmanage capability at the system context.

return: boolean
param: int $planid The plan  id
param: int $competencyidfrom The id of the competency we are moving.
param: int $competencyidto The id of the competency we are moving to.

user_competency_cancel_review_request($userid, $competencyid)   X-Ref
Cancel a user competency review request.

return: bool
param: int $userid       The user ID.
param: int $competencyid The competency ID.

user_competency_request_review($userid, $competencyid)   X-Ref
Request a user competency review.

return: bool
param: int $userid       The user ID.
param: int $competencyid The competency ID.

user_competency_start_review($userid, $competencyid)   X-Ref
Start a user competency review.

return: bool
param: int $userid       The user ID.
param: int $competencyid The competency ID.

user_competency_stop_review($userid, $competencyid)   X-Ref
Stop a user competency review.

return: bool
param: int $userid       The user ID.
param: int $competencyid The competency ID.

user_competency_viewed($usercompetencyorid)   X-Ref
Log user competency viewed event.

return: bool
param: user_competency|int $usercompetencyorid The user competency object or user competency id

user_competency_viewed_in_plan($usercompetencyorid, $planid)   X-Ref
Log user competency viewed in plan event.

return: bool
param: user_competency|int $usercompetencyorid The user competency object or user competency id
param: int $planid The plan ID

user_competency_viewed_in_course($usercoursecompetencyorid)   X-Ref
Log user competency viewed in course event.

return: bool
param: user_competency_course|int $usercoursecompetencyorid The user competency course object or its ID.
param: int $courseid The course ID

user_competency_plan_viewed($usercompetencyplanorid)   X-Ref
Log user competency plan viewed event.

return: bool
param: user_competency_plan|int $usercompetencyplanorid The user competency plan object or user competency plan id

template_has_related_data($templateid)   X-Ref
Check if template has related data.

return: boolean
param: int $templateid The id of the template to check.

list_related_competencies($competencyid)   X-Ref
List all the related competencies.

return: competency[]
param: int $competencyid The id of the competency to check.

add_related_competency($competencyid, $relatedcompetencyid)   X-Ref
Add a related competency.

return: bool False when create failed, true on success, or if the relation already existed.
param: int $competencyid The id of the competency
param: int $relatedcompetencyid The id of the related competency.

remove_related_competency($competencyid, $relatedcompetencyid)   X-Ref
Remove a related competency.

return: bool True when it was deleted, false when it wasn't or the relation doesn't exist.
param: int $competencyid The id of the competency.
param: int $relatedcompetencyid The id of the related competency.

read_user_evidence($id)   X-Ref
Read a user evidence.

return: user_evidence
param: int $id

create_user_evidence($data, $draftitemid = null)   X-Ref
Create a new user evidence.

return: user_evidence
param: object $data        The data.
param: int    $draftitemid The draft ID in which files have been saved.

update_user_evidence($data, $draftitemid = null)   X-Ref
Create a new user evidence.

return: user_evidence
param: object $data        The data.
param: int    $draftitemid The draft ID in which files have been saved.

delete_user_evidence($id)   X-Ref
Delete a user evidence.

return: bool
param: int $id The user evidence ID.

list_user_evidence($userid)   X-Ref
List the user evidence of a user.

return: user_evidence[]
param: int $userid The user ID.

create_user_evidence_competency($userevidenceorid, $competencyid)   X-Ref
Link a user evidence with a competency.

return: user_evidence_competency
param: user_evidence|int $userevidenceorid User evidence or its ID.
param: int $competencyid Competency ID.

delete_user_evidence_competency($userevidenceorid, $competencyid)   X-Ref
Delete a relationship between a user evidence and a competency.

return: bool
param: user_evidence|int $userevidenceorid User evidence or its ID.
param: int $competencyid Competency ID.

request_review_of_user_evidence_linked_competencies($id)   X-Ref
Send request review for user evidence competencies.

return: bool
param: int $id The user evidence ID.

duplicate_competency_tree($frameworkid, $tree, $oldparent = 0, $newparent = 0)   X-Ref
Recursively duplicate competencies from a tree, we start duplicating from parents to children to have a correct path.
This method does not copy the related competencies.

return: competency[] $matchids - List of old competencies ids matched with new competencies object.
param: int $frameworkid - framework id
param: competency[] $tree - array of competencies object
param: int $oldparent - old parent id
param: int $newparent - new parent id

migrate_competency_tree_rules($tree, $matchids)   X-Ref
Recursively migrate competency rules.

param: competency[] $tree - array of competencies object
param: competency[] $matchids - List of old competencies ids matched with new competencies object

archive_user_competencies_in_plan($plan)   X-Ref
Archive user competencies in a plan.

return: void
param: int $plan The plan object.

remove_archived_user_competencies_in_plan($plan)   X-Ref
Delete archived user competencies in a plan.

return: void
param: int $plan The plan object.

list_evidence($userid = 0, $competencyid = 0, $planid = 0, $sort = 'timecreated',$order = 'DESC', $skip = 0, $limit = 0)   X-Ref
List all the evidence for a user competency.

return: \core_competency\evidence[]
return: array of \core_competency\evidence
param: int $userid The user id - only used if usercompetencyid is 0.
param: int $competencyid The competency id - only used it usercompetencyid is 0.
param: int $planid The plan id - not used yet - but can be used to only list archived evidence if a plan is completed.
param: string $sort The field to sort the evidence by.
param: string $order The ordering of the sorting.
param: int $skip Number of records to skip.
param: int $limit Number of records to return.

list_evidence_in_course($userid = 0, $courseid = 0, $competencyid = 0, $sort = 'timecreated',$order = 'DESC', $skip = 0, $limit = 0)   X-Ref
List all the evidence for a user competency in a course.

return: \core_competency\evidence[]
param: int $userid The user ID.
param: int $courseid The course ID.
param: int $competencyid The competency ID.
param: string $sort The field to sort the evidence by.
param: string $order The ordering of the sorting.
param: int $skip Number of records to skip.
param: int $limit Number of records to return.

add_evidence($userid, $competencyorid, $contextorid, $action, $descidentifier, $desccomponent,$desca = null, $recommend = false, $url = null, $grade = null, $actionuserid = null,$note = null)   X-Ref
Create an evidence from a list of parameters.

Requires no capability because evidence can be added in many situations under any user.

return: evidence
param: int $userid The user id for which evidence is added.
param: competency|int $competencyorid The competency, or its id for which evidence is added.
param: context|int $contextorid The context in which the evidence took place.
param: int $action The type of action to take on the competency. \core_competency\evidence::ACTION_*.
param: string $descidentifier The strings identifier.
param: string $desccomponent The strings component.
param: mixed $desca Any arguments the string requires.
param: bool $recommend When true, the user competency will be sent for review.
param: string $url The url the evidence may link to.
param: int $grade The grade, or scale ID item.
param: int $actionuserid The ID of the user who took the action of adding the evidence. Null when system.
param: string $note A note to attach to the evidence.

read_evidence($evidenceid)   X-Ref
Read an evidence.

return: evidence
param: int $evidenceid The evidence ID.

delete_evidence($evidenceorid)   X-Ref
Delete an evidence.

return: bool
param: evidence|int $evidenceorid The evidence, or its ID.

apply_competency_rules_from_usercompetency(user_competency $usercompetency,competency $competency = null)   X-Ref
Apply the competency rules from a user competency.

The user competency passed should be one that was recently marked as complete.
A user competency is considered 'complete' when it's proficiency value is true.

This method will check if the parent of this usercompetency's competency has any
rules and if so will see if they match. When matched it will take the required
step to add evidence and trigger completion, etc...

return: void
param: user_competency $usercompetency The user competency recently completed.
param: competency|null $competency     The competency of the user competency, useful to avoid unnecessary read.

observe_course_module_completion_updated(\core\event\course_module_completion_updated $event)   X-Ref
Observe when a course module is marked as completed.

Note that the user being logged in while this happens may be anyone.
Do not rely on capability checks here!

return: void
param: \core\event\course_module_completion_updated $event

observe_course_completed(\core\event\course_completed $event)   X-Ref
Observe when a course is marked as completed.

Note that the user being logged in while this happens may be anyone.
Do not rely on capability checks here!

return: void
param: \core\event\course_completed $event

hook_course_module_deleted(stdClass $cm)   X-Ref
Action to perform when a course module is deleted.

Do not call this directly, this is reserved for core use.

return: void
param: stdClass $cm The CM object.

hook_course_deleted(stdClass $course)   X-Ref
Action to perform when a course is deleted.

Do not call this directly, this is reserved for core use.

return: void
param: stdClass $course The course object.

hook_course_reset_competency_ratings($courseid)   X-Ref
Action to perform when a course is being reset.

Do not call this directly, this is reserved for core use.

return: void
param: int $courseid The course ID.

hook_cohort_deleted(\stdClass $cohort)   X-Ref
Action to perform when a cohort is deleted.

Do not call this directly, this is reserved for core use.

return: void
param: \stdClass $cohort The cohort object.

hook_user_deleted($userid)   X-Ref
Action to perform when a user is deleted.

param: int $userid The user id.

grade_competency($userid, $competencyid, $grade, $note = null)   X-Ref
Manually grade a user competency.

return: array of \core_competency\user_competency
param: int $userid
param: int $competencyid
param: int $grade
param: string $note A note to attach to the evidence

grade_competency_in_plan($planorid, $competencyid, $grade, $note = null)   X-Ref
Manually grade a user competency from the plans page.

return: array of \core_competency\user_competency
param: mixed $planorid
param: int $competencyid
param: int $grade
param: string $note A note to attach to the evidence

grade_competency_in_course($courseorid, $userid, $competencyid, $grade, $note = null)   X-Ref
Manually grade a user course competency from the course page.

This may push the rating to the user competency
if the course is configured this way.

return: array of \core_competency\user_competency
param: mixed $courseorid
param: int $userid
param: int $competencyid
param: int $grade
param: string $note A note to attach to the evidence

count_plans_for_template($templateorid, $status = 0)   X-Ref
Count the plans in the template, filtered by status.

Requires moodle/competency:templateview capability at the system context.

return: int
param: mixed $templateorid The id or the template.
param: int $status One of the plan status constants (or 0 for all plans).

count_user_competency_plans_for_template($templateorid, $proficiency = null)   X-Ref
Count the user-completency-plans in the template, optionally filtered by proficiency.

Requires moodle/competency:templateview capability at the system context.

return: int
param: mixed $templateorid The id or the template.
param: mixed $proficiency If true, filter by proficiency, if false filter by not proficient, if null - no filter.

list_plans_for_template($templateorid, $status = 0, $skip = 0, $limit = 100)   X-Ref
List the plans in the template, filtered by status.

Requires moodle/competency:templateview capability at the system context.

return: plan[]
param: mixed $templateorid The id or the template.
param: int $status One of the plan status constants (or 0 for all plans).
param: int $skip The number of records to skip
param: int $limit The max number of records to return

get_least_proficient_competencies_for_course($courseid, $skip = 0, $limit = 100)   X-Ref
Get the most often not completed competency for this course.

Requires moodle/competency:coursecompetencyview capability at the course context.

return: competency[]
param: int $courseid The course id
param: int $skip The number of records to skip
param: int $limit The max number of records to return

get_least_proficient_competencies_for_template($templateorid, $skip = 0, $limit = 100)   X-Ref
Get the most often not completed competency for this template.

Requires moodle/competency:templateview capability at the system context.

return: competency[]
param: mixed $templateorid The id or the template.
param: int $skip The number of records to skip
param: int $limit The max number of records to return

template_viewed($templateorid)   X-Ref
Template event viewed.

Requires moodle/competency:templateview capability at the system context.

return: boolean
param: mixed $templateorid The id or the template.

read_course_competency_settings($courseid)   X-Ref
Get the competency settings for a course.

Requires moodle/competency:coursecompetencyview capability at the course context.

return: course_competency_settings
param: int $courseid The course id

update_course_competency_settings($courseid, $settings)   X-Ref
Update the competency settings for a course.

Requires moodle/competency:coursecompetencyconfigure capability at the course context.

return: bool
param: int $courseid The course id
param: stdClass $settings List of settings. The only valid setting ATM is pushratginstouserplans (boolean).

filter_users_with_capability_on_user_context_sql($capability, $userid = 0, $type = SQL_PARAMS_QM,$prefix='param')   X-Ref
Function used to return a list of users where the given user has a particular capability.

This is used e.g. to find all the users where someone is able to manage their learning plans,
it also would be useful for mentees etc.

return: list($sql, $params) Same as $DB->get_in_or_equal().
param: string $capability - The capability string we are filtering for. If '' is passed,
param: int $userid - The user id we are using for the access checks. Defaults to current user.
param: int $type - The type of named params to return (passed to $DB->get_in_or_equal).
param: string $prefix - The type prefix for the db table (passed to $DB->get_in_or_equal).