From 16d6d23fbcd79e105113db63fdefec529d2c88c5 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 10 Jan 2014 14:16:04 -0500 Subject: [PATCH] Save state before unenrolling student from old course. --- .../student/management/commands/transfer_students.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/student/management/commands/transfer_students.py b/common/djangoapps/student/management/commands/transfer_students.py index 38585961aa..0e7edc7cfb 100644 --- a/common/djangoapps/student/management/commands/transfer_students.py +++ b/common/djangoapps/student/management/commands/transfer_students.py @@ -44,11 +44,14 @@ class Command(BaseCommand): # Move the Student between the classes. mode = enrollment.mode + old_is_active = enrollment.is_active CourseEnrollment.unenroll(user,source) new_enrollment = CourseEnrollment.enroll(user, dest, mode=mode) - if not enrollment.is_active: - CourseEnrollment.unenroll(user,dest) + # Unenroll from the new coures if the user had unenrolled + # form the old course. + if not old_is_active: + new_enrollment.update_enrollment(is_active=False) if mode == 'verified': try: