MDL-68715 completion: fix form default value for course prerequisites.

Adds filtering on the completion criteria form to ensure we are only
selecting actual course instances of this type. Prior to this change
we would also get NULL values from unrelated criteria types.
This commit is contained in:
Paul Holden
2020-07-14 12:46:02 +01:00
parent ee23a8cf25
commit 8acaa4e356
4 changed files with 46 additions and 3 deletions
+11
View File
@@ -2498,5 +2498,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2020062600.01);
}
if ($oldversion < 2020071100.01) {
// Clean up completion criteria records referring to NULL course prerequisites.
$select = 'criteriatype = :type AND courseinstance IS NULL';
$params = ['type' => 8]; // COMPLETION_CRITERIA_TYPE_COURSE.
$DB->delete_records_select('course_completion_criteria', $select, $params);
// Main savepoint reached.
upgrade_main_savepoint(true, 2020071100.01);
}
return true;
}