MDL-36914: Assignment upgrade. Clean up patch to include outcomes in the upgrade

Thanks to Nathan Mares for reporting this issue.
This commit is contained in:
Damyon Wiese 2012-11-29 16:07:20 +08:00
parent 8131a848dd
commit f264499fcf

View file

@ -238,9 +238,11 @@ class assign_upgrade_manager {
$newassignment->update_calendar($newcoursemodule->id); $newassignment->update_calendar($newcoursemodule->id);
// reassociate grade_items from the old assignment instance to the new assign instance. This includes outcome linked grade_items // Reassociate grade_items from the old assignment instance to the new assign instance.
$sql = "UPDATE {grade_items} SET itemmodule = 'assign', iteminstance = ? WHERE itemmodule = 'assignment' AND iteminstance = ?"; // This includes outcome linked grade_items.
$DB->execute($sql, array($newassignment->get_instance()->id, $oldassignment->id)); $params = array('assign', $newassignment->get_instance()->id, 'assignment', $oldassignment->id);
$sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
$DB->execute($sql, $params);
$gradesdone = true; $gradesdone = true;
@ -252,9 +254,10 @@ class assign_upgrade_manager {
if ($rollback) { if ($rollback) {
// roll back the grades changes // roll back the grades changes
if ($gradesdone) { if ($gradesdone) {
// reassociate grade_items from the new assign instance to the old assignment instance // Reassociate grade_items from the new assign instance to the old assignment instance.
$sql = "UPDATE {grade_items} SET itemmodule = 'assign', iteminstance = ? WHERE itemmodule = 'assignment' AND iteminstance = ?"; $params = array('assignment', $oldassignment->id, 'assign', $newassignment->get_instance()->id);
$DB->execute($sql, array($oldassignment->id, $newassignment->get_instance()->id)); $sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
$DB->execute($sql, $params);
} }
// roll back the completion changes // roll back the completion changes
if ($completiondone) { if ($completiondone) {