From 7acff0a39e43353ff53ae8b129871816cd5cc44e Mon Sep 17 00:00:00 2001 From: "Albert St. Aubin" Date: Thu, 8 Mar 2018 13:45:54 -0500 Subject: [PATCH] correct check for enrollment on an entitlement [LEARNER-4484] --- openedx/core/djangoapps/catalog/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openedx/core/djangoapps/catalog/utils.py b/openedx/core/djangoapps/catalog/utils.py index 6cea11d548..4cbefeda79 100644 --- a/openedx/core/djangoapps/catalog/utils.py +++ b/openedx/core/djangoapps/catalog/utils.py @@ -389,13 +389,17 @@ def get_fulfillable_course_runs_for_entitlement(entitlement, course_runs): search_time = datetime.datetime.now(UTC) for course_run in course_runs: course_id = CourseKey.from_string(course_run.get('key')) - is_enrolled = CourseEnrollment.is_enrolled(entitlement.user, course_id) + (user_enrollment_mode, is_active) = CourseEnrollment.enrollment_mode_for_user( + user=entitlement.user, + course_id=course_id + ) + is_enrolled_in_mode = user_enrollment_mode == entitlement.mode if is_course_run_entitlement_fulfillable(course_id, entitlement, search_time): - if (is_enrolled and + if (is_enrolled_in_mode and entitlement.enrollment_course_run and course_id == entitlement.enrollment_course_run.course_id): enrollable_sessions.append(course_run) - elif not is_enrolled: + elif not is_enrolled_in_mode: enrollable_sessions.append(course_run) enrollable_sessions.sort(key=lambda session: session.get('start'))