Skip to content

Commit

Permalink
Merge branch 'MDL-50955-master' of git://github.com/peterRd/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Nov 17, 2020
2 parents a2da1d0 + 8e3031a commit a370cb4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -2994,5 +2994,23 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021052500.36);
}

if ($oldversion < 2021052500.42) {
// Get all lessons that are set with a completion criteria of 'requires grade' but with no grade type set.
$sql = "SELECT cm.id
FROM {course_modules} cm
JOIN {lesson} l ON l.id = cm.instance
JOIN {modules} m ON m.id = cm.module
WHERE m.name = :name AND cm.completiongradeitemnumber IS NOT NULL AND l.grade = :grade";

do {
if ($invalidconfigrations = $DB->get_records_sql($sql, ['name' => 'lesson', 'grade' => 0], 0, 1000)) {
list($insql, $inparams) = $DB->get_in_or_equal(array_keys($invalidconfigrations), SQL_PARAMS_NAMED);
$DB->set_field_select('course_modules', 'completiongradeitemnumber', null, "id $insql", $inparams);
}
} while ($invalidconfigrations);

upgrade_main_savepoint(true, 2021052500.42);
}

return true;
}

0 comments on commit a370cb4

Please sign in to comment.