Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

Class for loading/storing competencies from the DB.

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

Defines 1 class


Class: competency  - X-Ref

Class for loading/storing competencies from the DB.

define_properties()   X-Ref
Return the definition of the properties of this model.

return: array

before_validate()   X-Ref
Hook to execute before validate.

return: void

after_update($result)   X-Ref
Hook to execute after an update.

param: bool $result Whether or not the update was successful.
return: void

after_delete($result)   X-Ref
Hook to execute after a delete.

param: bool $result Whether or not the delete was successful.
return: void

get_default_grade()   X-Ref
Extracts the default grade from the scale configuration.

Returns an array where the first element is the grade, and the second
is a boolean representing whether or not this grade is considered 'proficient'.

return: array(int grade, bool proficient)

get_framework()   X-Ref
Get the competency framework.

return: competency_framework

get_level()   X-Ref
Get the competency level.

return: int

get_parent()   X-Ref
Return the parent competency.

return: null|competency

get_proficiency_of_grade($grade)   X-Ref
Extracts the proficiency of a grade from the scale configuration.

param: int $grade The grade (scale item ID).
return: array(int grade, bool proficient)

get_related_competencies()   X-Ref
Return the related competencies.

return: competency[]

get_rule_object()   X-Ref
Get the rule object.

return: null|competency_rule

get_scale()   X-Ref
Return the scale.

return: \grade_scale

has_user_competencies()   X-Ref
Returns true when the competency has user competencies.

This is useful to determine if the competency, or part of it, should be locked down.

return: boolean

is_parent_of(array $ids)   X-Ref
Check if the competency is the parent of passed competencies.

param: array $ids IDs of supposedly direct children.
return: boolean

reset_rule()   X-Ref
Reset the rule.

return: void

set_new_path(competency $parent = null)   X-Ref
Helper method to set the path.

param: competency $parent The parent competency object.
return: void

set_new_sortorder()   X-Ref
Helper method to set the sortorder.

return: void

search($searchtext, $competencyframeworkid)   X-Ref
This does a specialised search that finds all nodes in the tree with matching text on any text like field,
and returns this node and all its parents in a displayable sort order.

param: string $searchtext The text to search for.
param: int $competencyframeworkid The competency framework to limit the search.
return: persistent[]

validate_competencyframeworkid($value)   X-Ref
Validate the competency framework ID.

param: int $value The framework ID.
return: true|lang_string

validate_idnumber($value)   X-Ref
Validate the ID number.

param: string $value The ID number.
return: true|lang_string

validate_path($value)   X-Ref
Validate the path.

param: string $value The path.
return: true|lang_string

validate_parentid($value)   X-Ref
Validate the parent ID.

param: string $value The ID.
return: true|lang_string

validate_ruletype($value)   X-Ref
Validate the rule.

param: string $value The ID.
return: true|lang_string

validate_ruleconfig($value)   X-Ref
Validate the rule config.

param: string $value The ID.
return: true|lang_string

validate_scaleid($value)   X-Ref
Validate the scale ID.

Note that the value for a scale can never be 0, null has to be used when
the framework's scale has to be used.

param: int $value
return: true|lang_string

validate_scaleconfiguration($value)   X-Ref
Validate the scale configuration.

This logic is adapted from {@link \core_competency\competency_framework::validate_scaleconfiguration()}.

param: string $value The scale configuration.
return: bool|lang_string

share_same_framework(array $ids)   X-Ref
Return whether or not the competency IDs share the same framework.

param: array  $ids Competency IDs
return: bool

get_available_rules()   X-Ref
Get the available rules.

return: array Keys are the class names, values are the name of the rule.

get_framework_depth($frameworkid)   X-Ref
Return the current depth of a competency framework.

param: int $frameworkid The framework ID.
return: int

get_framework_tree($frameworkid)   X-Ref
Build a framework tree with competency nodes.

param: int  $frameworkid the framework id
return: stdClass[] tree of framework competency nodes

get_context()   X-Ref
Get the context from the framework.

return: \context

build_tree($all, $parentid)   X-Ref
Recursively build up the tree of nodes.

param: array $all - List of all competency classes.
param: int $parentid - The current parent ID. Pass 0 to build the tree from the top.
return: stdClass[] $tree tree of nodes

can_all_be_deleted($ids)   X-Ref
Check if we can delete competencies safely.

This moethod does not check any capablities.
Check if competency is used in a plan and user competency.
Check if competency is used in a template.
Check if competency is linked to a course.

param: array $ids Array of competencies ids.
return: bool True if we can delete the competencies.

delete_multiple($ids)   X-Ref
Delete the competencies.

This method is reserved to core usage.
This method does not trigger the after_delete event.
This method does not delete related objects such as related competencies and evidences.

param: array $ids The competencies ids.
return: bool True if the competencies were deleted successfully.

get_descendants_ids($competency)   X-Ref
Get descendant ids.

param: competency $competency The competency.
return: array Array of competencies ids.

get_ids_by_frameworkid($frameworkid)   X-Ref
Get competencyids by frameworkid.

param: int $frameworkid The competency framework ID.
return: array Array of competency ids.

delete_by_frameworkid($id)   X-Ref
Delete competencies by framework ID.

This method is reserved to core usage.
This method does not trigger the after_delete event.
This method does not delete related objects such as related competencies and evidences.

param: int $id the framework ID
return: bool Return true if delete was successful.

get_ancestors()   X-Ref
Get competency ancestors.

return: competency[] Return array of ancestors.