Skip to content

Commit

Permalink
MDL-36914: Assignment upgrade. Clean up patch to include outcomes in …
Browse files Browse the repository at this point in the history
…the upgrade

Thanks to Nathan Mares for reporting this issue.
  • Loading branch information
Damyon Wiese committed Nov 29, 2012
1 parent fb9c26d commit 16d31e2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mod/assign/upgradelib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ public function upgrade_assignment($oldassignmentid, & $log) {


$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;


Expand All @@ -243,9 +245,10 @@ public function upgrade_assignment($oldassignmentid, & $log) {
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) {
Expand Down

0 comments on commit 16d31e2

Please sign in to comment.