mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
MDL-13085 delete grades and items when uninstalling module; merged from MOODLE_19_STABLE
This commit is contained in:
parent
7993f4bdaa
commit
8a0a6046a3
@ -144,6 +144,10 @@
|
||||
notify("Error occurred while deleting the $strmodulename records from the config table");
|
||||
}
|
||||
|
||||
// cleanup the gradebook
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_uninstalled_module($module->name);
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($module->name, "$CFG->dirroot/mod/$module->name/db/install.xml", false);
|
||||
|
||||
|
@ -1135,6 +1135,26 @@ function remove_course_grades($courseid, $showfeedback) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does gradebook cleanup when module uninstalled.
|
||||
*/
|
||||
function grade_uninstalled_module($modname) {
|
||||
global $CFG;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM {$CFG->prefix}grade_items
|
||||
WHERE itemtype='mod' AND itemmodule='$modname'";
|
||||
|
||||
// go all items for this module and delete them including the grades
|
||||
if ($rs = get_recordset_sql($sql)) {
|
||||
while ($item = rs_fetch_next_record($rs)) {
|
||||
$grade_item = new grade_item($item, false);
|
||||
$grade_item->delete('moduninstall');
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Grading cron job
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user