returning enrollment mode for both active and inactive users

This commit is contained in:
John Jarvis
2014-05-13 17:47:52 -04:00
parent f8f542b677
commit 71c447768d

View File

@@ -871,10 +871,14 @@ class CourseEnrollment(models.Model):
`user` is a Django User object
`course_id` is our usual course_id string (e.g. "edX/Test101/2013_Fall)
Returns the mode for both inactive and active users.
Returns None if the courseenrollment record does not exist.
"""
try:
record = CourseEnrollment.objects.get(user=user, course_id=course_id)
if record.is_active:
if hasattr(record, 'mode'):
return record.mode
else:
return None