MDL-86010 competency: Delete competency evidence on cm delete
Evidence recorded against course module competencies was not deleted with the course module. This led to errors when attempting to view the competency record on a learning plan. This change will delete associated evidence records with the cm, and will clean up any existing orphaned records on upgrade. Co-Authored-By: Mark Johnson <[email protected]>
This commit is contained in:
co-authored by
Mark Johnson
parent
e27e1ed7bc
commit
57b29b7a55
@@ -4781,6 +4781,8 @@ class api {
|
||||
public static function hook_course_module_deleted(stdClass $cm) {
|
||||
global $DB;
|
||||
$DB->delete_records(course_module_competency::TABLE, array('cmid' => $cm->id));
|
||||
$context = context_module::instance($cm->id);
|
||||
$DB->delete_records(evidence::TABLE, ['contextid' => $context->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1862,5 +1862,15 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2025041401.10);
|
||||
}
|
||||
|
||||
if ($oldversion < 2025041402.01) {
|
||||
// Remove any orphaned competency evidence records (pointing to non-existing contexts).
|
||||
$DB->delete_records_select('competency_evidence', 'NOT EXISTS (
|
||||
SELECT ctx.id FROM {context} ctx WHERE ctx.id = {competency_evidence}.contextid
|
||||
)');
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2025041402.01);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2025041402.00; // 20250414 = branching date YYYYMMDD - do not modify!
|
||||
$version = 2025041402.01; // 20250414 = branching date YYYYMMDD - do not modify!
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '5.0.2 (Build: 20250811)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user