From f30ae71c23b3ad405e67d7ba86e989a4cfd8f9fd Mon Sep 17 00:00:00 2001 From: Troy Sankey Date: Mon, 15 Apr 2024 08:21:35 -0700 Subject: [PATCH] feat: add more verbose logging around force_enrollment After testing the enterprise bulk enrollment flow with force_enrollment=True, I'm finding that the enrollment is still not forced. This extra logging will hopefully help shed light on where this boolean might be accidentally ignored. --- common/djangoapps/student/models/course_enrollment.py | 5 +++-- openedx/features/enterprise_support/enrollments/utils.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/student/models/course_enrollment.py b/common/djangoapps/student/models/course_enrollment.py index d89a8d967a00..318a3afd8316 100644 --- a/common/djangoapps/student/models/course_enrollment.py +++ b/common/djangoapps/student/models/course_enrollment.py @@ -683,9 +683,10 @@ def enroll(cls, user, course_key, mode=None, check_access=False, can_upgrade=Fal if check_access: if cls.is_enrollment_closed(user, course) and not can_upgrade: log.warning( - "User %s failed to enroll in course %s because enrollment is closed", + "User %s failed to enroll in course %s because enrollment is closed (can_upgrade=%s).", user.username, - str(course_key) + str(course_key), + can_upgrade, ) raise EnrollmentClosedError diff --git a/openedx/features/enterprise_support/enrollments/utils.py b/openedx/features/enterprise_support/enrollments/utils.py index b64ff971b769..e0d5f65aedde 100644 --- a/openedx/features/enterprise_support/enrollments/utils.py +++ b/openedx/features/enterprise_support/enrollments/utils.py @@ -133,12 +133,13 @@ def lms_update_or_create_enrollment( except (CourseEnrollmentError, CourseEnrollmentNotUpdatableError) as error: log.exception( "Raising error [%s] for user " - "[%s]: course run = [%s], enterprise_uuid = [%s], is_active = [%s], ", + "[%s]: course run = [%s], enterprise_uuid = [%s], is_active = [%s], force_enrollment = [%s], ", error, username, course_id, str(enterprise_uuid), is_active, + force_enrollment, ) raise error finally: