Merge branch 'MDL-36914-master' of git://github.com/damyon/moodle

This commit is contained in:
Dan Poltawski 2012-12-03 14:45:04 +08:00
commit e1c93ed97b

View file

@ -238,14 +238,12 @@ class assign_upgrade_manager {
$newassignment->update_calendar($newcoursemodule->id); $newassignment->update_calendar($newcoursemodule->id);
// copy the grades from the old assignment to the new one // 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);
$gradeitem = $DB->get_record('grade_items', array('iteminstance'=>$oldassignment->id, 'itemmodule'=>'assignment'), 'id', IGNORE_MISSING);
if ($gradeitem) {
$gradeitem->iteminstance = $newassignment->get_instance()->id;
$gradeitem->itemmodule = 'assign';
$DB->update_record('grade_items', $gradeitem);
}
$gradesdone = true; $gradesdone = true;
} catch (Exception $exception) { } catch (Exception $exception) {
@ -256,13 +254,10 @@ class assign_upgrade_manager {
if ($rollback) { if ($rollback) {
// roll back the grades changes // roll back the grades changes
if ($gradesdone) { if ($gradesdone) {
// copy the grades from the old assignment to the new one // Reassociate grade_items from the new assign instance to the old assignment instance.
$gradeitem = $DB->get_record('grade_items', array('iteminstance'=>$newassignment->get_instance()->id, 'itemmodule'=>'assign'), 'id', IGNORE_MISSING); $params = array('assignment', $oldassignment->id, 'assign', $newassignment->get_instance()->id);
if ($gradeitem) { $sql = 'UPDATE {grade_items} SET itemmodule = ?, iteminstance = ? WHERE itemmodule = ? AND iteminstance = ?';
$gradeitem->iteminstance = $oldassignment->id; $DB->execute($sql, $params);
$gradeitem->itemmodule = 'assignment';
$DB->update_record('grade_items', $gradeitem);
}
} }
// roll back the completion changes // roll back the completion changes
if ($completiondone) { if ($completiondone) {