Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | Static Protected Member Functions | List of all members
core_competency\api Class Reference

Class for doing things with competency frameworks. More...

Static Public Member Functions

static add_competency_to_course ($courseid, $competencyid)
 Add a competency to this course. More...
 
static add_competency_to_course_module ($cmorid, $competencyid)
 Add a competency to this course module. More...
 
static add_competency_to_plan ($planid, $competencyid)
 Add a competency to a plan. More...
 
static add_competency_to_template ($templateid, $competencyid)
 Add a competency to this template. More...
 
static add_evidence ($userid, $competencyorid, $contextorid, $action, $descidentifier, $desccomponent, $desca=null, $recommend=false, $url=null, $grade=null, $actionuserid=null, $note=null)
 Create an evidence from a list of parameters. More...
 
static add_related_competency ($competencyid, $relatedcompetencyid)
 Add a related competency. More...
 
static approve_plan ($planorid)
 Approve a plan. More...
 
static check_enabled ()
 Restore the checking that competencies are enabled with any api function.
 
static competency_framework_viewed ($frameworkorid)
 Logg the competency framework viewed event. More...
 
static competency_viewed ($competencyorid)
 Logg the competency viewed event. More...
 
static complete_plan ($planorid)
 Complete a plan. More...
 
static count_competencies ($filters)
 Perform a search based on the provided filters and return a paginated list of records. More...
 
static count_competencies_in_course ($courseid)
 Count all the competencies in a course. More...
 
static count_competencies_in_template ($templateorid)
 Count all the competencies in a learning plan template. More...
 
static count_competencies_in_template_with_no_courses ($templateorid)
 Count all the competencies in a learning plan template with no linked courses. More...
 
static count_course_module_competencies ($cmorid)
 Count the competencies associated to a course module. More...
 
static count_courses_using_competency ($competencyid)
 Count all the courses using a competency. More...
 
static count_frameworks ($context, $includes)
 Perform a search based on the provided filters and return a paginated list of records. More...
 
static count_plans_for_template ($templateorid, $status=0)
 Count the plans in the template, filtered by status. More...
 
static count_proficient_competencies_in_course_for_user ($courseid, $userid)
 Count the proficient competencies in a course for one user. More...
 
static count_templates ($context, $includes)
 Perform a search based on the provided filters and return how many results there are. More...
 
static count_templates_using_competency ($competencyid)
 Count all the templates using a competency. More...
 
static count_user_competency_plans_for_template ($templateorid, $proficiency=null)
 Count the user-completency-plans in the template, optionally filtered by proficiency. More...
 
static create_competency (stdClass $record)
 Create a competency from a record containing all the data for the class. More...
 
static create_framework (stdClass $record)
 Create a competency framework from a record containing all the data for the class. More...
 
static create_plan (stdClass $record)
 Creates a learning plan based on the provided data. More...
 
static create_plan_from_template ($templateorid, $userid)
 Create a learning plan from a template. More...
 
static create_plans_from_template_cohort ($templateorid, $cohortid, $recreateunlinked=false)
 Create learning plans from a template and cohort. More...
 
static create_template (stdClass $record)
 Create a learning plan template from a record containing all the data for the class. More...
 
static create_template_cohort ($templateorid, $cohortorid)
 Create a relation between a template and a cohort. More...
 
static create_user_evidence ($data, $draftitemid=null)
 Create a new user evidence. More...
 
static create_user_evidence_competency ($userevidenceorid, $competencyid)
 Link a user evidence with a competency. More...
 
static delete_competency ($id)
 Delete a competency by id. More...
 
static delete_evidence ($evidenceorid)
 Delete an evidence. More...
 
static delete_framework ($id)
 Delete a competency framework by id. More...
 
static delete_plan ($id)
 Deletes a plan. More...
 
static delete_template ($id, $deleteplans=true)
 Delete a learning plan template by id. More...
 
static delete_template_cohort ($templateorid, $cohortorid)
 Remove a relation between a template and a cohort. More...
 
static delete_user_evidence ($id)
 Delete a user evidence. More...
 
static delete_user_evidence_competency ($userevidenceorid, $competencyid)
 Delete a relationship between a user evidence and a competency. More...
 
static duplicate_framework ($id)
 Duplicate a competency framework by id. More...
 
static duplicate_template ($id)
 Duplicate a learning plan template. More...
 
static filter_users_with_capability_on_user_context_sql ($capability, $userid=0, $type=SQL_PARAMS_QM, $prefix='param')
 Function used to return a list of users where the given user has a particular capability. More...
 
static get_least_proficient_competencies_for_course ($courseid, $skip=0, $limit=100)
 Get the most often not completed competency for this course. More...
 
static get_least_proficient_competencies_for_template ($templateorid, $skip=0, $limit=100)
 Get the most often not completed competency for this template. More...
 
static get_plan_competency ($planorid, $competencyid)
 Get a single competency from the user plan. More...
 
static get_related_contexts ($context, $includes, array $hasanycapability=null)
 Fetches all the relevant contexts. More...
 
static get_user_competency ($userid, $competencyid)
 Get a user competency. More...
 
static get_user_competency_by_id ($usercompetencyid)
 Get a user competency by ID. More...
 
static get_user_competency_in_course ($courseid, $userid, $competencyid)
 Get a user competency in a course. More...
 
static grade_competency ($userid, $competencyid, $grade, $note=null)
 Manually grade a user competency. More...
 
static grade_competency_in_course ($courseorid, $userid, $competencyid, $grade, $note=null)
 Manually grade a user course competency from the course page. More...
 
static grade_competency_in_plan ($planorid, $competencyid, $grade, $note=null)
 Manually grade a user competency from the plans page. More...
 
static hook_cohort_deleted (\stdClass $cohort)
 Action to perform when a cohort is deleted. More...
 
static hook_course_deleted (stdClass $course)
 Action to perform when a course is deleted. More...
 
static hook_course_module_deleted (stdClass $cm)
 Action to perform when a course module is deleted. More...
 
static hook_course_reset_competency_ratings ($courseid)
 Action to perform when a course is being reset. More...
 
static hook_user_deleted ($userid)
 Action to perform when a user is deleted. More...
 
static is_enabled ()
 Returns whether competencies are enabled. More...
 
static is_scale_used_anywhere ($scaleid)
 Checks whether a scale is used anywhere in the plugin. More...
 
static list_competencies ($filters, $sort='', $order='ASC', $skip=0, $limit=0)
 Perform a search based on the provided filters and return a paginated list of records. More...
 
static list_competencies_in_template ($templateorid)
 List all the competencies in a template. More...
 
static list_course_competencies ($courseorid)
 List the competencies associated to a course. More...
 
static list_course_module_competencies ($cmorid)
 List the competencies associated to a course module. More...
 
static list_course_module_competencies_in_course_module ($cmorid)
 List all the competencies linked to a course module. More...
 
static list_course_modules_using_competency ($competencyid, $courseid)
 List all the courses modules using a competency in a course. More...
 
static list_courses_using_competency ($competencyid)
 List all the courses using a competency. More...
 
static list_evidence ($userid=0, $competencyid=0, $planid=0, $sort='timecreated', $order='DESC', $skip=0, $limit=0)
 List all the evidence for a user competency. More...
 
static list_evidence_in_course ($userid=0, $courseid=0, $competencyid=0, $sort='timecreated', $order='DESC', $skip=0, $limit=0)
 List all the evidence for a user competency in a course. More...
 
static list_frameworks ($sort, $order, $skip, $limit, $context, $includes='children', $onlyvisible=false, $query='')
 Perform a search based on the provided filters and return a paginated list of records. More...
 
static list_plan_competencies ($planorid)
 List the competencies in a user plan. More...
 
static list_plans_for_template ($templateorid, $status=0, $skip=0, $limit=100)
 List the plans in the template, filtered by status. More...
 
static list_plans_to_review ($skip=0, $limit=100, $userid=null)
 List the plans to review. More...
 
static list_plans_with_competency ($userid, $competencyorid)
 List the plans with a competency. More...
 
static list_related_competencies ($competencyid)
 List all the related competencies. More...
 
static list_templates ($sort, $order, $skip, $limit, $context, $includes='children', $onlyvisible=false)
 Perform a search based on the provided filters and return a paginated list of records. More...
 
static list_templates_using_competency ($competencyid)
 List all the learning plan templatesd using a competency. More...
 
static list_user_competencies_in_course ($courseid, $userid)
 List all the user competencies in a course. More...
 
static list_user_competencies_to_review ($skip=0, $limit=50, $userid=null)
 List the user competencies to review. More...
 
static list_user_evidence ($userid)
 List the user evidence of a user. More...
 
static list_user_plans ($userid)
 Lists user plans. More...
 
static move_down_competency ($id)
 Reorder this competency. More...
 
static move_up_competency ($id)
 Reorder this competency. More...
 
static observe_course_completed (\core\event\course_completed $event)
 Observe when a course is marked as completed. More...
 
static observe_course_module_completion_updated (\core\event\course_module_completion_updated $event)
 Observe when a course module is marked as completed. More...
 
static plan_cancel_review_request ($planorid)
 Cancel the review of a plan. More...
 
static plan_request_review ($planorid)
 Request the review of a plan. More...
 
static plan_start_review ($planorid)
 Start the review of a plan. More...
 
static plan_stop_review ($planorid)
 Stop reviewing a plan. More...
 
static plan_viewed ($planorid)
 Plan event viewed. More...
 
static read_competency ($id, $includerelated=false)
 Read a the details for a single competency and return a record. More...
 
static read_course_competency_settings ($courseid)
 Get the competency settings for a course. More...
 
static read_evidence ($evidenceid)
 Read an evidence. More...
 
static read_framework ($id)
 Read a the details for a single competency framework and return a record. More...
 
static read_plan ($id)
 Returns a plan data. More...
 
static read_template ($id)
 Read a the details for a single learning plan template and return a record. More...
 
static read_user_evidence ($id)
 Read a user evidence. More...
 
static remove_competency_from_course ($courseid, $competencyid)
 Remove a competency from this course. More...
 
static remove_competency_from_course_module ($cmorid, $competencyid)
 Remove a competency from this course module. More...
 
static remove_competency_from_plan ($planid, $competencyid)
 Remove a competency from a plan. More...
 
static remove_competency_from_template ($templateid, $competencyid)
 Remove a competency from this template. More...
 
static remove_related_competency ($competencyid, $relatedcompetencyid)
 Remove a related competency. More...
 
static reopen_plan ($planorid)
 Reopen a plan. More...
 
static reorder_course_competency ($courseid, $competencyidfrom, $competencyidto)
 Move the course competency up or down in the display list. More...
 
static reorder_course_module_competency ($cmorid, $competencyidfrom, $competencyidto)
 Move the course module competency up or down in the display list. More...
 
static reorder_plan_competency ($planid, $competencyidfrom, $competencyidto)
 Move the plan competency up or down in the display list. More...
 
static reorder_template_competency ($templateid, $competencyidfrom, $competencyidto)
 Move the template competency up or down in the display list. More...
 
static request_review_of_user_evidence_linked_competencies ($id)
 Send request review for user evidence competencies. More...
 
static require_enabled ()
 Throws an exception if competencies are not enabled. More...
 
static search_competencies ($textsearch, $competencyframeworkid)
 Perform a text search based and return all results and their parents. More...
 
static set_course_competency_ruleoutcome ($coursecompetencyorid, $ruleoutcome)
 Update ruleoutcome value for a course competency. More...
 
static set_course_module_competency_ruleoutcome ($coursemodulecompetencyorid, $ruleoutcome)
 Update ruleoutcome value for a course module competency. More...
 
static set_parent_competency ($id, $newparentid)
 Move this competency so it sits in a new parent. More...
 
static show_links ()
 When competencies used to be enabled, we can show the text but do not include links. More...
 
static skip_enabled ()
 Allow calls to competency api functions even if competencies are not currently enabled.
 
static template_has_related_data ($templateid)
 Check if template has related data. More...
 
static template_viewed ($templateorid)
 Template event viewed. More...
 
static unapprove_plan ($planorid)
 Unapprove a plan. More...
 
static unlink_plan_from_template ($planorid)
 Unlink a plan from its template. More...
 
static update_competency ($record)
 Update the details for a competency. More...
 
static update_course_competency_settings ($courseid, $settings)
 Update the competency settings for a course. More...
 
static update_framework ($record)
 Update the details for a competency framework. More...
 
static update_plan (stdClass $record)
 Updates a plan. More...
 
static update_template ($record)
 Update the details for a learning plan template. More...
 
static update_user_evidence ($data, $draftitemid=null)
 Create a new user evidence. More...
 
static user_competency_cancel_review_request ($userid, $competencyid)
 Cancel a user competency review request. More...
 
static user_competency_plan_viewed ($usercompetencyplanorid)
 Log user competency plan viewed event. More...
 
static user_competency_request_review ($userid, $competencyid)
 Request a user competency review. More...
 
static user_competency_start_review ($userid, $competencyid)
 Start a user competency review. More...
 
static user_competency_stop_review ($userid, $competencyid)
 Stop a user competency review. More...
 
static user_competency_viewed ($usercompetencyorid)
 Log user competency viewed event. More...
 
static user_competency_viewed_in_course ($usercoursecompetencyorid)
 Log user competency viewed in course event. More...
 
static user_competency_viewed_in_plan ($usercompetencyorid, $planid)
 Log user competency viewed in plan event. More...
 

Static Protected Member Functions

static apply_competency_rules_from_usercompetency (user_competency $usercompetency, competency $competency=null)
 Apply the competency rules from a user competency. More...
 
static archive_user_competencies_in_plan ($plan)
 Archive user competencies in a plan. More...
 
static duplicate_competency_tree ($frameworkid, $tree, $oldparent=0, $newparent=0)
 Recursively duplicate competencies from a tree, we start duplicating from parents to children to have a correct path. More...
 
static migrate_competency_tree_rules ($tree, $matchids)
 Recursively migrate competency rules. More...
 
static remove_archived_user_competencies_in_plan ($plan)
 Delete archived user competencies in a plan. More...
 
static validate_course ($courseorid, $throwexception=true)
 Validate if current user have acces to the course if hidden. More...
 
static validate_course_module ($cmmixed, $throwexception=true)
 Validate if current user have acces to the course_module if hidden. More...
 

Detailed Description

Class for doing things with competency frameworks.

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

Member Function Documentation

◆ add_competency_to_course()

static core_competency\api::add_competency_to_course (   $courseid,
  $competencyid 
)
static

Add a competency to this course.

Parameters
int$courseidThe id of the course
int$competencyidThe id of the competency
Return values
bool

◆ add_competency_to_course_module()

static core_competency\api::add_competency_to_course_module (   $cmorid,
  $competencyid 
)
static

Add a competency to this course module.

Parameters
mixed$cmoridThe course module, or id of the course module
int$competencyidThe id of the competency
Return values
bool

◆ add_competency_to_plan()

static core_competency\api::add_competency_to_plan (   $planid,
  $competencyid 
)
static

Add a competency to a plan.

Parameters
int$planidThe id of the plan
int$competencyidThe id of the competency
Return values
bool

◆ add_competency_to_template()

static core_competency\api::add_competency_to_template (   $templateid,
  $competencyid 
)
static

Add a competency to this template.

Parameters
int$templateidThe id of the template
int$competencyidThe id of the competency
Return values
bool

◆ add_evidence()

static core_competency\api::add_evidence (   $userid,
  $competencyorid,
  $contextorid,
  $action,
  $descidentifier,
  $desccomponent,
  $desca = null,
  $recommend = false,
  $url = null,
  $grade = null,
  $actionuserid = null,
  $note = null 
)
static

Create an evidence from a list of parameters.

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

Parameters
int$useridThe user id for which evidence is added.
competency | int$competencyoridThe competency, or its id for which evidence is added.
context | int$contextoridThe context in which the evidence took place.
int$actionThe type of action to take on the competency. core_competency\evidence::ACTION_*.
string$descidentifierThe strings identifier.
string$desccomponentThe strings component.
mixed$descaAny arguments the string requires.
bool$recommendWhen true, the user competency will be sent for review.
string$urlThe url the evidence may link to.
int$gradeThe grade, or scale ID item.
int$actionuseridThe ID of the user who took the action of adding the evidence. Null when system. This should be used when the action was taken by a real person, this will allow to keep track of all the evidence given by a certain person.
string$noteA note to attach to the evidence.
Return values
evidence
Exceptions
coding_exception
invalid_persistent_exception
moodle_exception

◆ add_related_competency()

static core_competency\api::add_related_competency (   $competencyid,
  $relatedcompetencyid 
)
static

Add a related competency.

Parameters
int$competencyidThe id of the competency
int$relatedcompetencyidThe id of the related competency.
Return values
boolFalse when create failed, true on success, or if the relation already existed.

◆ apply_competency_rules_from_usercompetency()

static core_competency\api::apply_competency_rules_from_usercompetency ( user_competency  $usercompetency,
competency  $competency = null 
)
staticprotected

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

Parameters
user_competency$usercompetencyThe user competency recently completed.
competency | null$competencyThe competency of the user competency, useful to avoid unnecessary read.
Return values
void

◆ approve_plan()

static core_competency\api::approve_plan (   $planorid)
static

Approve a plan.

This means making the plan active.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ archive_user_competencies_in_plan()

static core_competency\api::archive_user_competencies_in_plan (   $plan)
staticprotected

Archive user competencies in a plan.

Parameters
int$planThe plan object.
Return values
void

◆ competency_framework_viewed()

static core_competency\api::competency_framework_viewed (   $frameworkorid)
static

Logg the competency framework viewed event.

Parameters
competency_framework | int$frameworkoridThe competency_framework object or competency framework id
Return values
bool

◆ competency_viewed()

static core_competency\api::competency_viewed (   $competencyorid)
static

Logg the competency viewed event.

Parameters
competency | int$competencyoridThe competency object or competency id
Return values
bool

◆ complete_plan()

static core_competency\api::complete_plan (   $planorid)
static

Complete a plan.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ count_competencies()

static core_competency\api::count_competencies (   $filters)
static

Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/competency:competencyview capability at some context.

Parameters
array$filtersA list of filters to apply to the list.
Return values
int

◆ count_competencies_in_course()

static core_competency\api::count_competencies_in_course (   $courseid)
static

Count all the competencies in a course.

Parameters
int$courseidThe id of the course to check.
Return values
int

◆ count_competencies_in_template()

static core_competency\api::count_competencies_in_template (   $templateorid)
static

Count all the competencies in a learning plan template.

Parameters
template | int$templateoridThe template or its ID.
Return values
int

◆ count_competencies_in_template_with_no_courses()

static core_competency\api::count_competencies_in_template_with_no_courses (   $templateorid)
static

Count all the competencies in a learning plan template with no linked courses.

Parameters
template | int$templateoridThe template or its ID.
Return values
int

◆ count_course_module_competencies()

static core_competency\api::count_course_module_competencies (   $cmorid)
static

Count the competencies associated to a course module.

Parameters
mixed$cmoridThe course module, or its ID.
Return values
int

◆ count_courses_using_competency()

static core_competency\api::count_courses_using_competency (   $competencyid)
static

Count all the courses using a competency.

Parameters
int$competencyidThe id of the competency to check.
Return values
int

◆ count_frameworks()

static core_competency\api::count_frameworks (   $context,
  $includes 
)
static

Perform a search based on the provided filters and return a paginated list of records.

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

Parameters
context$contextThe parent context of the frameworks.
string$includesDefines what other contexts to fetch frameworks from. Accepted values are:
  • children: All descendants
  • parents: All parents, grand parents, etc...
  • self: Context passed only.
Return values
int

◆ count_plans_for_template()

static core_competency\api::count_plans_for_template (   $templateorid,
  $status = 0 
)
static

Count the plans in the template, filtered by status.

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

Parameters
mixed$templateoridThe id or the template.
int$statusOne of the plan status constants (or 0 for all plans).
Return values
int

◆ count_proficient_competencies_in_course_for_user()

static core_competency\api::count_proficient_competencies_in_course_for_user (   $courseid,
  $userid 
)
static

Count the proficient competencies in a course for one user.

Parameters
int$courseidThe id of the course to check.
int$useridThe id of the user to check.
Return values
int

◆ count_templates()

static core_competency\api::count_templates (   $context,
  $includes 
)
static

Perform a search based on the provided filters and return how many results there are.

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

Parameters
context$contextThe parent context of the frameworks.
string$includesDefines what other contexts to fetch frameworks from. Accepted values are:
  • children: All descendants
  • parents: All parents, grand parents, etc...
  • self: Context passed only.
Return values
int

◆ count_templates_using_competency()

static core_competency\api::count_templates_using_competency (   $competencyid)
static

Count all the templates using a competency.

Parameters
int$competencyidThe id of the competency to check.
Return values
int

◆ count_user_competency_plans_for_template()

static core_competency\api::count_user_competency_plans_for_template (   $templateorid,
  $proficiency = null 
)
static

Count the user-completency-plans in the template, optionally filtered by proficiency.

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

Parameters
mixed$templateoridThe id or the template.
mixed$proficiencyIf true, filter by proficiency, if false filter by not proficient, if null - no filter.
Return values
int

◆ create_competency()

static core_competency\api::create_competency ( stdClass  $record)
static

Create a competency from a record containing all the data for the class.

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

Parameters
stdClass$recordRecord containing all the data for an instance of the class.
Return values
competency

◆ create_framework()

static core_competency\api::create_framework ( stdClass  $record)
static

Create a competency framework from a record containing all the data for the class.

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

Parameters
stdClass$recordRecord containing all the data for an instance of the class.
Return values
competency_framework

◆ create_plan()

static core_competency\api::create_plan ( stdClass  $record)
static

Creates a learning plan based on the provided data.

Parameters
stdClass$record
Return values
core_competency

◆ create_plan_from_template()

static core_competency\api::create_plan_from_template (   $templateorid,
  $userid 
)
static

Create a learning plan from a template.

Parameters
mixed$templateoridThe template object or ID.
int$userid
Return values
false|core_competency

◆ create_plans_from_template_cohort()

static core_competency\api::create_plans_from_template_cohort (   $templateorid,
  $cohortid,
  $recreateunlinked = false 
)
static

Create learning plans from a template and cohort.

Parameters
mixed$templateoridThe template object or ID.
int$cohortidThe cohort ID.
bool$recreateunlinkedWhen true the plans that were unlinked from this template will be re-created.
Return values
intThe number of plans created.

◆ create_template()

static core_competency\api::create_template ( stdClass  $record)
static

Create a learning plan template from a record containing all the data for the class.

Requires moodle/competency:templatemanage capability.

Parameters
stdClass$recordRecord containing all the data for an instance of the class.
Return values
template

◆ create_template_cohort()

static core_competency\api::create_template_cohort (   $templateorid,
  $cohortorid 
)
static

Create a relation between a template and a cohort.

This silently ignores when the relation already existed.

Parameters
template | int$templateoridThe template or its ID.
stdClass | int$cohortoridThe cohort ot its ID.
Return values
template_cohort

◆ create_user_evidence()

static core_competency\api::create_user_evidence (   $data,
  $draftitemid = null 
)
static

Create a new user evidence.

Parameters
object$dataThe data.
int$draftitemidThe draft ID in which files have been saved.
Return values
user_evidence

◆ create_user_evidence_competency()

static core_competency\api::create_user_evidence_competency (   $userevidenceorid,
  $competencyid 
)
static

Link a user evidence with a competency.

Parameters
user_evidence | int$userevidenceoridUser evidence or its ID.
int$competencyidCompetency ID.
Return values
user_evidence_competency

◆ delete_competency()

static core_competency\api::delete_competency (   $id)
static

Delete a competency by id.

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

Parameters
int$idThe record to delete. This will delete alot of related data - you better be sure.
Return values
boolean

◆ delete_evidence()

static core_competency\api::delete_evidence (   $evidenceorid)
static

Delete an evidence.

Parameters
evidence | int$evidenceoridThe evidence, or its ID.
Return values
bool

◆ delete_framework()

static core_competency\api::delete_framework (   $id)
static

Delete a competency framework by id.

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

Parameters
int$idThe record to delete. This will delete alot of related data - you better be sure.
Return values
boolean

◆ delete_plan()

static core_competency\api::delete_plan (   $id)
static

Deletes a plan.

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

Parameters
int$id
Return values
boolSuccess?

◆ delete_template()

static core_competency\api::delete_template (   $id,
  $deleteplans = true 
)
static

Delete a learning plan template by id.

If the learning plan template has associated cohorts they will be deleted.

Requires moodle/competency:templatemanage capability.

Parameters
int$idThe record to delete.
boolean$deleteplansTrue to delete plans associaated to template, false to unlink them.
Return values
boolean

◆ delete_template_cohort()

static core_competency\api::delete_template_cohort (   $templateorid,
  $cohortorid 
)
static

Remove a relation between a template and a cohort.

Parameters
template | int$templateoridThe template or its ID.
stdClass | int$cohortoridThe cohort ot its ID.
Return values
booleanTrue on success or when the relation did not exist.

◆ delete_user_evidence()

static core_competency\api::delete_user_evidence (   $id)
static

Delete a user evidence.

Parameters
int$idThe user evidence ID.
Return values
bool

◆ delete_user_evidence_competency()

static core_competency\api::delete_user_evidence_competency (   $userevidenceorid,
  $competencyid 
)
static

Delete a relationship between a user evidence and a competency.

Parameters
user_evidence | int$userevidenceoridUser evidence or its ID.
int$competencyidCompetency ID.
Return values
bool

◆ duplicate_competency_tree()

static core_competency\api::duplicate_competency_tree (   $frameworkid,
  $tree,
  $oldparent = 0,
  $newparent = 0 
)
staticprotected

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.

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

◆ duplicate_framework()

static core_competency\api::duplicate_framework (   $id)
static

Duplicate a competency framework by id.

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

Parameters
int$idThe record to duplicate. All competencies associated and related will be duplicated.
Return values
competency_frameworkthe framework duplicated

◆ duplicate_template()

static core_competency\api::duplicate_template (   $id)
static

Duplicate a learning plan template.

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

Parameters
int$idthe template id.
Return values
template

◆ filter_users_with_capability_on_user_context_sql()

static core_competency\api::filter_users_with_capability_on_user_context_sql (   $capability,
  $userid = 0,
  $type = SQL_PARAMS_QM,
  $prefix = 'param' 
)
static

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.

Parameters
string$capability- The capability string we are filtering for. If '' is passed, an always matching filter is returned.
int$userid- The user id we are using for the access checks. Defaults to current user.
int$type- The type of named params to return (passed to $DB->get_in_or_equal).
string$prefix- The type prefix for the db table (passed to $DB->get_in_or_equal).
Return values
list($sql,$params)Same as $DB->get_in_or_equal().
Todo:
MDL-52243 Move this function to lib/accesslib.php

◆ get_least_proficient_competencies_for_course()

static core_competency\api::get_least_proficient_competencies_for_course (   $courseid,
  $skip = 0,
  $limit = 100 
)
static

Get the most often not completed competency for this course.

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

Parameters
int$courseidThe course id
int$skipThe number of records to skip
int$limitThe max number of records to return
Return values
competency[]

◆ get_least_proficient_competencies_for_template()

static core_competency\api::get_least_proficient_competencies_for_template (   $templateorid,
  $skip = 0,
  $limit = 100 
)
static

Get the most often not completed competency for this template.

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

Parameters
mixed$templateoridThe id or the template.
int$skipThe number of records to skip
int$limitThe max number of records to return
Return values
competency[]

◆ get_plan_competency()

static core_competency\api::get_plan_competency (   $planorid,
  $competencyid 
)
static

Get a single competency from the user plan.

Parameters
int$planoridThe plan, or its ID.
int$competencyidThe competency id.
Return values
(object)array( 'competency' => core_competency\competency, 'usercompetency' => core_competency\user_competency 'usercompetencyplan' => core_competency\user_competency_plan ) The values of of keys usercompetency and usercompetencyplan cannot be defined at the same time.

◆ get_related_contexts()

static core_competency\api::get_related_contexts (   $context,
  $includes,
array  $hasanycapability = null 
)
static

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.

Parameters
context$contextThe context to start from.
string$includesDefines what other contexts to find. Accepted values are:
  • children: All descendants
  • parents: All parents, grand parents, etc...
  • self: Context passed only.
array$hasanycapabilityArray of capabilities passed to has_any_capability() in each context.
Return values
context[]An array of contexts where keys are context IDs.

◆ get_user_competency()

static core_competency\api::get_user_competency (   $userid,
  $competencyid 
)
static

Get a user competency.

Parameters
int$useridThe user ID.
int$competencyidThe competency ID.
Return values
user_competency

◆ get_user_competency_by_id()

static core_competency\api::get_user_competency_by_id (   $usercompetencyid)
static

Get a user competency by ID.

Parameters
int$usercompetencyidThe user competency ID.
Return values
user_competency

◆ get_user_competency_in_course()

static core_competency\api::get_user_competency_in_course (   $courseid,
  $userid,
  $competencyid 
)
static

Get a user competency in a course.

Parameters
int$courseidThe id of the course to check.
int$useridThe id of the course to check.
int$competencyidThe id of the competency.
Return values
user_competency_course

◆ grade_competency()

static core_competency\api::grade_competency (   $userid,
  $competencyid,
  $grade,
  $note = null 
)
static

Manually grade a user competency.

Parameters
int$userid
int$competencyid
int$grade
string$noteA note to attach to the evidence
Return values
arrayof core_competency\user_competency

◆ grade_competency_in_course()

static core_competency\api::grade_competency_in_course (   $courseorid,
  $userid,
  $competencyid,
  $grade,
  $note = null 
)
static

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.

Parameters
mixed$courseorid
int$userid
int$competencyid
int$grade
string$noteA note to attach to the evidence
Return values
arrayof core_competency\user_competency

◆ grade_competency_in_plan()

static core_competency\api::grade_competency_in_plan (   $planorid,
  $competencyid,
  $grade,
  $note = null 
)
static

Manually grade a user competency from the plans page.

Parameters
mixed$planorid
int$competencyid
int$grade
string$noteA note to attach to the evidence
Return values
arrayof core_competency\user_competency

◆ hook_cohort_deleted()

static core_competency\api::hook_cohort_deleted ( \stdClass  $cohort)
static

Action to perform when a cohort is deleted.

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

Parameters
stdClass$cohortThe cohort object.
Return values
void

◆ hook_course_deleted()

static core_competency\api::hook_course_deleted ( stdClass  $course)
static

Action to perform when a course is deleted.

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

Parameters
stdClass$courseThe course object.
Return values
void

◆ hook_course_module_deleted()

static core_competency\api::hook_course_module_deleted ( stdClass  $cm)
static

Action to perform when a course module is deleted.

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

Parameters
stdClass$cmThe CM object.
Return values
void

◆ hook_course_reset_competency_ratings()

static core_competency\api::hook_course_reset_competency_ratings (   $courseid)
static

Action to perform when a course is being reset.

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

Parameters
int$courseidThe course ID.
Return values
void

◆ hook_user_deleted()

static core_competency\api::hook_user_deleted (   $userid)
static

Action to perform when a user is deleted.

Parameters
int$useridThe user id.

◆ is_enabled()

static core_competency\api::is_enabled ( )
static

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 values
booleanTrue when enabled.

◆ is_scale_used_anywhere()

static core_competency\api::is_scale_used_anywhere (   $scaleid)
static

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 (self::is_enabled()).
Parameters
int$scaleidThe scale ID.
Return values
bool

◆ list_competencies()

static core_competency\api::list_competencies (   $filters,
  $sort = '',
  $order = 'ASC',
  $skip = 0,
  $limit = 0 
)
static

Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/competency:competencyview capability at some context.

Parameters
array$filtersA list of filters to apply to the list.
string$sortThe column to sort on
string$order('ASC' or 'DESC')
int$skipNumber of records to skip (pagination)
int$limitMax of records to return (pagination)
Return values
arrayof competencies

◆ list_competencies_in_template()

static core_competency\api::list_competencies_in_template (   $templateorid)
static

List all the competencies in a template.

Parameters
template | int$templateoridThe template or its ID.
Return values
arrayof competencies

◆ list_course_competencies()

static core_competency\api::list_course_competencies (   $courseorid)
static

List the competencies associated to a course.

Parameters
mixed$courseoridThe course, or its ID.
Return values
array(array( 'competency' => core_competency\competency, 'coursecompetency' => core_competency\course_competency ))

◆ list_course_module_competencies()

static core_competency\api::list_course_module_competencies (   $cmorid)
static

List the competencies associated to a course module.

Parameters
mixed$cmoridThe course module, or its ID.
Return values
array(array( 'competency' => core_competency\competency, 'coursemodulecompetency' => core_competency\course_module_competency ))

◆ list_course_module_competencies_in_course_module()

static core_competency\api::list_course_module_competencies_in_course_module (   $cmorid)
static

List all the competencies linked to a course module.

Parameters
mixed$cmoridThe course module, or its ID.
Return values
array[competency]Array of competency records.

◆ list_course_modules_using_competency()

static core_competency\api::list_course_modules_using_competency (   $competencyid,
  $courseid 
)
static

List all the courses modules using a competency in a course.

Parameters
int$competencyidThe id of the competency to check.
int$courseidThe id of the course to check.
Return values
array[int]Array of course modules ids.

◆ list_courses_using_competency()

static core_competency\api::list_courses_using_competency (   $competencyid)
static

List all the courses using a competency.

Parameters
int$competencyidThe id of the competency to check.
Return values
array[stdClass]Array of stdClass containing id and shortname.

◆ list_evidence()

static core_competency\api::list_evidence (   $userid = 0,
  $competencyid = 0,
  $planid = 0,
  $sort = 'timecreated',
  $order = 'DESC',
  $skip = 0,
  $limit = 0 
)
static

List all the evidence for a user competency.

Parameters
int$useridThe user id - only used if usercompetencyid is 0.
int$competencyidThe competency id - only used it usercompetencyid is 0.
int$planidThe plan id - not used yet - but can be used to only list archived evidence if a plan is completed.
string$sortThe field to sort the evidence by.
string$orderThe ordering of the sorting.
int$skipNumber of records to skip.
int$limitNumber of records to return.
Return values
core_competency

◆ list_evidence_in_course()

static core_competency\api::list_evidence_in_course (   $userid = 0,
  $courseid = 0,
  $competencyid = 0,
  $sort = 'timecreated',
  $order = 'DESC',
  $skip = 0,
  $limit = 0 
)
static

List all the evidence for a user competency in a course.

Parameters
int$useridThe user ID.
int$courseidThe course ID.
int$competencyidThe competency ID.
string$sortThe field to sort the evidence by.
string$orderThe ordering of the sorting.
int$skipNumber of records to skip.
int$limitNumber of records to return.
Return values
core_competency

◆ list_frameworks()

static core_competency\api::list_frameworks (   $sort,
  $order,
  $skip,
  $limit,
  $context,
  $includes = 'children',
  $onlyvisible = false,
  $query = '' 
)
static

Perform a search based on the provided filters and return a paginated list of records.

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

Parameters
string$sortThe column to sort on
string$order('ASC' or 'DESC')
int$skipNumber of records to skip (pagination)
int$limitMax of records to return (pagination)
context$contextThe parent context of the frameworks.
string$includesDefines what other contexts to fetch frameworks from. Accepted values are:
  • children: All descendants
  • parents: All parents, grand parents, etc...
  • self: Context passed only.
bool$onlyvisibleIf true return only visible frameworks
string$queryA string to use to filter down the frameworks.
Return values
arrayof competency_framework

◆ list_plan_competencies()

static core_competency\api::list_plan_competencies (   $planorid)
static

List the competencies in a user plan.

Parameters
int$planoridThe plan, or its ID.
Return values
array((object)array( 'competency' => core_competency\competency, 'usercompetency' => core_competency\user_competency 'usercompetencyplan' => core_competency\user_competency_plan )) The values of of keys usercompetency and usercompetencyplan cannot be defined at the same time.

◆ list_plans_for_template()

static core_competency\api::list_plans_for_template (   $templateorid,
  $status = 0,
  $skip = 0,
  $limit = 100 
)
static

List the plans in the template, filtered by status.

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

Parameters
mixed$templateoridThe id or the template.
int$statusOne of the plan status constants (or 0 for all plans).
int$skipThe number of records to skip
int$limitThe max number of records to return
Return values
plan[]

◆ list_plans_to_review()

static core_competency\api::list_plans_to_review (   $skip = 0,
  $limit = 100,
  $userid = null 
)
static

List the plans to review.

The method returns values in this format:

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

Parameters
int$skipThe number of records to skip.
int$limitThe number of results to return.
int$useridThe user we're getting the plans to review for.
Return values
arrayContaining the keys 'count', and 'plans'. The 'plans' key contains an object which contains 'plan', 'template' and 'owner'.

◆ list_plans_with_competency()

static core_competency\api::list_plans_with_competency (   $userid,
  $competencyorid 
)
static

List the plans with a competency.

Parameters
int$useridThe user id we want the plans for.
int$competencyoridThe competency, or its ID.
Return values
array[plan]Array of learning plans.

◆ list_related_competencies()

static core_competency\api::list_related_competencies (   $competencyid)
static

List all the related competencies.

Parameters
int$competencyidThe id of the competency to check.
Return values
competency[]

◆ list_templates()

static core_competency\api::list_templates (   $sort,
  $order,
  $skip,
  $limit,
  $context,
  $includes = 'children',
  $onlyvisible = false 
)
static

Perform a search based on the provided filters and return a paginated list of records.

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

Parameters
string$sortThe column to sort on
string$order('ASC' or 'DESC')
int$skipNumber of records to skip (pagination)
int$limitMax of records to return (pagination)
context$contextThe parent context of the frameworks.
string$includesDefines what other contexts to fetch frameworks from. Accepted values are:
  • children: All descendants
  • parents: All parents, grand parents, etc...
  • self: Context passed only.
bool$onlyvisibleIf should list only visible templates
Return values
arrayof competency_framework

◆ list_templates_using_competency()

static core_competency\api::list_templates_using_competency (   $competencyid)
static

List all the learning plan templatesd using a competency.

Parameters
int$competencyidThe id of the competency to check.
Return values
array[stdClass]Array of stdClass containing id and shortname.

◆ list_user_competencies_in_course()

static core_competency\api::list_user_competencies_in_course (   $courseid,
  $userid 
)
static

List all the user competencies in a course.

Parameters
int$courseidThe id of the course to check.
int$useridThe id of the course to check.
Return values
arrayof user_competency_course objects

◆ list_user_competencies_to_review()

static core_competency\api::list_user_competencies_to_review (   $skip = 0,
  $limit = 50,
  $userid = null 
)
static

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) )

Parameters
int$skipThe number of records to skip.
int$limitThe number of results to return.
int$useridThe user we're getting the competencies to review for.
Return values
arrayContaining the keys 'count', and 'competencies'. The 'competencies' key contains an object which contains 'competency', 'usercompetency' and 'user'.

◆ list_user_evidence()

static core_competency\api::list_user_evidence (   $userid)
static

List the user evidence of a user.

Parameters
int$useridThe user ID.
Return values
user_evidence[]

◆ list_user_plans()

static core_competency\api::list_user_plans (   $userid)
static

Lists user plans.

Parameters
int$userid
Return values
core_competency

◆ migrate_competency_tree_rules()

static core_competency\api::migrate_competency_tree_rules (   $tree,
  $matchids 
)
staticprotected

Recursively migrate competency rules.

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

◆ move_down_competency()

static core_competency\api::move_down_competency (   $id)
static

Reorder this competency.

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

Parameters
int$idThe id of the competency to move.
Return values
boolean

◆ move_up_competency()

static core_competency\api::move_up_competency (   $id)
static

Reorder this competency.

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

Parameters
int$idThe id of the competency to move.
Return values
boolean

◆ observe_course_completed()

static core_competency\api::observe_course_completed ( \core\event\course_completed  $event)
static

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!

Parameters
core\event\course_completed$event
Return values
void

◆ observe_course_module_completion_updated()

static core_competency\api::observe_course_module_completion_updated ( \core\event\course_module_completion_updated  $event)
static

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!

Parameters
core\event\course_module_completion_updated$event
Return values
void

◆ plan_cancel_review_request()

static core_competency\api::plan_cancel_review_request (   $planorid)
static

Cancel the review of a plan.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ plan_request_review()

static core_competency\api::plan_request_review (   $planorid)
static

Request the review of a plan.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ plan_start_review()

static core_competency\api::plan_start_review (   $planorid)
static

Start the review of a plan.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ plan_stop_review()

static core_competency\api::plan_stop_review (   $planorid)
static

Stop reviewing a plan.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ plan_viewed()

static core_competency\api::plan_viewed (   $planorid)
static

Plan event viewed.

Parameters
mixed$planoridThe id or the plan.
Return values
boolean

◆ read_competency()

static core_competency\api::read_competency (   $id,
  $includerelated = false 
)
static

Read a the details for a single competency and return a record.

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

Parameters
int$idThe id of the competency to read.
bool$includerelatedInclude related tags or not.
Return values
stdClass

◆ read_course_competency_settings()

static core_competency\api::read_course_competency_settings (   $courseid)
static

Get the competency settings for a course.

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

Parameters
int$courseidThe course id
Return values
course_competency_settings

◆ read_evidence()

static core_competency\api::read_evidence (   $evidenceid)
static

Read an evidence.

Parameters
int$evidenceidThe evidence ID.
Return values
evidence

◆ read_framework()

static core_competency\api::read_framework (   $id)
static

Read a the details for a single competency framework and return a record.

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

Parameters
int$idThe id of the framework to read.
Return values
competency_framework

◆ read_plan()

static core_competency\api::read_plan (   $id)
static

Returns a plan data.

Parameters
int$id
Return values
core_competency

◆ read_template()

static core_competency\api::read_template (   $id)
static

Read a the details for a single learning plan template and return a record.

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

Parameters
int$idThe id of the template to read.
Return values
template

◆ read_user_evidence()

static core_competency\api::read_user_evidence (   $id)
static

Read a user evidence.

Parameters
int$id
Return values
user_evidence

◆ remove_archived_user_competencies_in_plan()

static core_competency\api::remove_archived_user_competencies_in_plan (   $plan)
staticprotected

Delete archived user competencies in a plan.

Parameters
int$planThe plan object.
Return values
void

◆ remove_competency_from_course()

static core_competency\api::remove_competency_from_course (   $courseid,
  $competencyid 
)
static

Remove a competency from this course.

Parameters
int$courseidThe id of the course
int$competencyidThe id of the competency
Return values
bool

◆ remove_competency_from_course_module()

static core_competency\api::remove_competency_from_course_module (   $cmorid,
  $competencyid 
)
static

Remove a competency from this course module.

Parameters
mixed$cmoridThe course module, or id of the course module
int$competencyidThe id of the competency
Return values
bool

◆ remove_competency_from_plan()

static core_competency\api::remove_competency_from_plan (   $planid,
  $competencyid 
)
static

Remove a competency from a plan.

Parameters
int$planidThe plan id
int$competencyidThe id of the competency
Return values
bool

◆ remove_competency_from_template()

static core_competency\api::remove_competency_from_template (   $templateid,
  $competencyid 
)
static

Remove a competency from this template.

Parameters
int$templateidThe id of the template
int$competencyidThe id of the competency
Return values
bool

◆ remove_related_competency()

static core_competency\api::remove_related_competency (   $competencyid,
  $relatedcompetencyid 
)
static

Remove a related competency.

Parameters
int$competencyidThe id of the competency.
int$relatedcompetencyidThe id of the related competency.
Return values
boolTrue when it was deleted, false when it wasn't or the relation doesn't exist.

◆ reopen_plan()

static core_competency\api::reopen_plan (   $planorid)
static

Reopen a plan.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ reorder_course_competency()

static core_competency\api::reorder_course_competency (   $courseid,
  $competencyidfrom,
  $competencyidto 
)
static

Move the course competency up or down in the display list.

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

Parameters
int$courseidThe course
int$competencyidfromThe id of the competency we are moving.
int$competencyidtoThe id of the competency we are moving to.
Return values
boolean

◆ reorder_course_module_competency()

static core_competency\api::reorder_course_module_competency (   $cmorid,
  $competencyidfrom,
  $competencyidto 
)
static

Move the course module competency up or down in the display list.

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

Parameters
mixed$cmoridThe course module, or id of the course module
int$competencyidfromThe id of the competency we are moving.
int$competencyidtoThe id of the competency we are moving to.
Return values
boolean

◆ reorder_plan_competency()

static core_competency\api::reorder_plan_competency (   $planid,
  $competencyidfrom,
  $competencyidto 
)
static

Move the plan competency up or down in the display list.

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

Parameters
int$planidThe plan id
int$competencyidfromThe id of the competency we are moving.
int$competencyidtoThe id of the competency we are moving to.
Return values
boolean

◆ reorder_template_competency()

static core_competency\api::reorder_template_competency (   $templateid,
  $competencyidfrom,
  $competencyidto 
)
static

Move the template competency up or down in the display list.

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

Parameters
int$templateidThe template id
int$competencyidfromThe id of the competency we are moving.
int$competencyidtoThe id of the competency we are moving to.
Return values
boolean

◆ request_review_of_user_evidence_linked_competencies()

static core_competency\api::request_review_of_user_evidence_linked_competencies (   $id)
static

Send request review for user evidence competencies.

Parameters
int$idThe user evidence ID.
Return values
bool

◆ require_enabled()

static core_competency\api::require_enabled ( )
static

Throws an exception if competencies are not enabled.

Return values
void
Exceptions
moodle_exception

◆ search_competencies()

static core_competency\api::search_competencies (   $textsearch,
  $competencyframeworkid 
)
static

Perform a text search based and return all results and their parents.

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

Parameters
string$textsearchA string to search for.
int$competencyframeworkidThe id of the framework to limit the search.
Return values
arrayof competencies

◆ set_course_competency_ruleoutcome()

static core_competency\api::set_course_competency_ruleoutcome (   $coursecompetencyorid,
  $ruleoutcome 
)
static

Update ruleoutcome value for a course competency.

Parameters
int | course_competency$coursecompetencyoridThe course_competency, or its ID.
int$ruleoutcomeThe value of ruleoutcome.
Return values
boolTrue on success.

◆ set_course_module_competency_ruleoutcome()

static core_competency\api::set_course_module_competency_ruleoutcome (   $coursemodulecompetencyorid,
  $ruleoutcome 
)
static

Update ruleoutcome value for a course module competency.

Parameters
int | course_module_competency$coursemodulecompetencyoridThe course_module_competency, or its ID.
int$ruleoutcomeThe value of ruleoutcome.
Return values
boolTrue on success.

◆ set_parent_competency()

static core_competency\api::set_parent_competency (   $id,
  $newparentid 
)
static

Move this competency so it sits in a new parent.

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

Parameters
int$idThe id of the competency to move.
int$newparentidThe new parent id for the competency.
Return values
boolean

◆ show_links()

static core_competency\api::show_links ( )
static

When competencies used to be enabled, we can show the text but do not include links.

Return values
booleanTrue means show links.

◆ template_has_related_data()

static core_competency\api::template_has_related_data (   $templateid)
static

Check if template has related data.

Parameters
int$templateidThe id of the template to check.
Return values
boolean

◆ template_viewed()

static core_competency\api::template_viewed (   $templateorid)
static

Template event viewed.

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

Parameters
mixed$templateoridThe id or the template.
Return values
boolean

◆ unapprove_plan()

static core_competency\api::unapprove_plan (   $planorid)
static

Unapprove a plan.

This means making the plan draft.

Parameters
int | plan$planoridThe plan, or its ID.
Return values
bool

◆ unlink_plan_from_template()

static core_competency\api::unlink_plan_from_template (   $planorid)
static

Unlink a plan from its template.

Parameters
core_competency\plan | int$planoridThe plan or its ID.
Return values
bool

◆ update_competency()

static core_competency\api::update_competency (   $record)
static

Update the details for a competency.

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

Parameters
stdClass$recordThe new details for the competency. Note - must contain an id that points to the competency to update.
Return values
boolean

◆ update_course_competency_settings()

static core_competency\api::update_course_competency_settings (   $courseid,
  $settings 
)
static

Update the competency settings for a course.

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

Parameters
int$courseidThe course id
stdClass$settingsList of settings. The only valid setting ATM is pushratginstouserplans (boolean).
Return values
bool

◆ update_framework()

static core_competency\api::update_framework (   $record)
static

Update the details for a competency framework.

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

Parameters
stdClass$recordThe new details for the framework. Note - must contain an id that points to the framework to update.
Return values
boolean

◆ update_plan()

static core_competency\api::update_plan ( stdClass  $record)
static

Updates a plan.

Parameters
stdClass$record
Return values
core_competency

◆ update_template()

static core_competency\api::update_template (   $record)
static

Update the details for a learning plan template.

Requires moodle/competency:templatemanage capability.

Parameters
stdClass$recordThe new details for the template. Note - must contain an id that points to the template to update.
Return values
boolean

◆ update_user_evidence()

static core_competency\api::update_user_evidence (   $data,
  $draftitemid = null 
)
static

Create a new user evidence.

Parameters
object$dataThe data.
int$draftitemidThe draft ID in which files have been saved.
Return values
user_evidence

◆ user_competency_cancel_review_request()

static core_competency\api::user_competency_cancel_review_request (   $userid,
  $competencyid 
)
static

Cancel a user competency review request.

Parameters
int$useridThe user ID.
int$competencyidThe competency ID.
Return values
bool

◆ user_competency_plan_viewed()

static core_competency\api::user_competency_plan_viewed (   $usercompetencyplanorid)
static

Log user competency plan viewed event.

Parameters
user_competency_plan | int$usercompetencyplanoridThe user competency plan object or user competency plan id
Return values
bool

◆ user_competency_request_review()

static core_competency\api::user_competency_request_review (   $userid,
  $competencyid 
)
static

Request a user competency review.

Parameters
int$useridThe user ID.
int$competencyidThe competency ID.
Return values
bool

◆ user_competency_start_review()

static core_competency\api::user_competency_start_review (   $userid,
  $competencyid 
)
static

Start a user competency review.

Parameters
int$useridThe user ID.
int$competencyidThe competency ID.
Return values
bool

◆ user_competency_stop_review()

static core_competency\api::user_competency_stop_review (   $userid,
  $competencyid 
)
static

Stop a user competency review.

Parameters
int$useridThe user ID.
int$competencyidThe competency ID.
Return values
bool

◆ user_competency_viewed()

static core_competency\api::user_competency_viewed (   $usercompetencyorid)
static

Log user competency viewed event.

Parameters
user_competency | int$usercompetencyoridThe user competency object or user competency id
Return values
bool

◆ user_competency_viewed_in_course()

static core_competency\api::user_competency_viewed_in_course (   $usercoursecompetencyorid)
static

Log user competency viewed in course event.

Parameters
user_competency_course | int$usercoursecompetencyoridThe user competency course object or its ID.
int$courseidThe course ID
Return values
bool

◆ user_competency_viewed_in_plan()

static core_competency\api::user_competency_viewed_in_plan (   $usercompetencyorid,
  $planid 
)
static

Log user competency viewed in plan event.

Parameters
user_competency | int$usercompetencyoridThe user competency object or user competency id
int$planidThe plan ID
Return values
bool

◆ validate_course()

static core_competency\api::validate_course (   $courseorid,
  $throwexception = true 
)
staticprotected

Validate if current user have acces to the course if hidden.

Parameters
mixed$courseoridThe course or it ID.
bool$throwexceptionThrow an exception or not.
Return values
bool

◆ validate_course_module()

static core_competency\api::validate_course_module (   $cmmixed,
  $throwexception = true 
)
staticprotected

Validate if current user have acces to the course_module if hidden.

Parameters
mixed$cmmixedThe cm_info class, course module record or its ID.
bool$throwexceptionThrow an exception or not.
Return values
bool

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