MDL-63876 badges: Competency deletion

Do not delete a competency if it is a criteria for a badge.
This commit is contained in:
Damyon Wiese
2019-03-29 11:31:15 +08:00
parent 6bdaf20462
commit f44557d045
3 changed files with 47 additions and 0 deletions
+9
View File
@@ -769,6 +769,8 @@ class competency extends persistent {
* @return bool True if we can delete the competencies.
*/
public static function can_all_be_deleted($ids) {
global $CFG;
if (empty($ids)) {
return true;
}
@@ -792,6 +794,13 @@ class competency extends persistent {
if (user_competency_plan::has_records_for_competencies($ids)) {
return false;
}
require_once($CFG->libdir . '/badgeslib.php');
// Check if competency is used in a badge.
if (badge_award_criteria_competency_has_records_for_competencies($ids)) {
return false;
}
return true;
}