MDL-53879 competency: Remove limit on framework depth

This commit is contained in:
Frederic Massart
2016-04-28 16:41:24 +08:00
parent 6bd3ab0717
commit 8ea0f17ae9
9 changed files with 117 additions and 107 deletions
+12 -18
View File
@@ -133,6 +133,16 @@ class competency_framework extends persistent {
}
/**
* Return the current depth of a competency framework.
*
* @see competency::get_framework_depth()
* @return int
*/
public function get_depth() {
return competency::get_framework_depth($this->get_id());
}
/**
* Return the scale.
*
@@ -176,8 +186,8 @@ class competency_framework extends persistent {
unset($taxonomies[0]);
// Ensure that we do not return empty levels.
for ($i = 1; $i <= self::get_taxonomies_max_level(); $i++) {
if (empty($taxonomies[$i])) {
foreach ($taxonomies as $i => $taxonomy) {
if (empty($taxonomy)) {
$taxonomies[$i] = self::TAXONOMY_COMPETENCY;
}
}
@@ -335,10 +345,6 @@ class competency_framework extends persistent {
protected function validate_taxonomies($value) {
$terms = explode(',', $value);
if (count($terms) > self::get_taxonomies_max_level()) {
return new lang_string('invaliddata', 'error');
}
foreach ($terms as $term) {
if (!empty($term) && !array_key_exists($term, self::get_taxonomies_list())) {
return new lang_string('invalidtaxonomy', 'core_competency', $term);
@@ -410,18 +416,6 @@ class competency_framework extends persistent {
return self::get_taxonomies_list()[$constant];
}
/**
* Return the maximum number of taxonomy levels.
*
* This is a method and not a constant because we want to make it easy to adapt
* to the number of levels desired in the future.
*
* @return int
*/
public static function get_taxonomies_max_level() {
return 6;
}
/**
* Get the list of all taxonomies.
*