Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…the upgrade

Thanks to Nathan Mares for reporting this issue.
  • Loading branch information...
commit f264499fcf2640c22e2af306aa760bcfde8152ed 1 parent 8131a84
@damyon damyon authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 mod/assign/upgradelib.php
View
15 mod/assign/upgradelib.php
@@ -238,9 +238,11 @@ public function upgrade_assignment($oldassignmentid, & $log) {
$newassignment->update_calendar($newcoursemodule->id);
- // reassociate grade_items from the old assignment instance to the new assign instance. This includes outcome linked grade_items
- $sql = "UPDATE {grade_items} SET itemmodule = 'assign', iteminstance = ? WHERE itemmodule = 'assignment' AND iteminstance = ?";
- $DB->execute($sql, array($newassignment->get_instance()->id, $oldassignment->id));
+ // Reassociate grade_items from the old assignment instance to the new assign instance.
+ // This includes outcome linked grade_items.
+ $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;
@@ -252,9 +254,10 @@ public function upgrade_assignment($oldassignmentid, & $log) {
if ($rollback) {
// roll back the grades changes
if ($gradesdone) {
- // 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 = ?";
- $DB->execute($sql, array($oldassignment->id, $newassignment->get_instance()->id));
+ // Reassociate grade_items from the new assign instance to the old assignment instance.
+ $params = array('assignment', $oldassignment->id, 'assign', $newassignment->get_instance()->id);
+ $sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
+ $DB->execute($sql, $params);
}
// roll back the completion changes
if ($completiondone) {
Please sign in to comment.
Something went wrong with that request. Please try again.