Skip to content

fix: enroll with the open mode the course offers instead of hardcoded audit - #75

Open
ccantillo wants to merge 1 commit into
mainfrom
crls/fix/start-course-auto-enroll
Open

fix: enroll with the open mode the course offers instead of hardcoded audit#75
ccantillo wants to merge 1 commit into
mainfrom
crls/fix/start-course-auto-enroll

Conversation

@ccantillo

Copy link
Copy Markdown
Contributor

Fix "Start Course" enrollment failure — openedx-corporate

Problem

Clicking Start Course on a catalog course card showed "Enrollment failed"
for users not yet enrolled in the course. The card already calls
POST /partner_catalog/api/v1/catalogs/{id}/courses/{course_id}/enroll/, but
for open courses the backend always requested the LMS enrollment with a
hardcoded audit mode. NAU courses are configured with honor instead, so
the LMS raised CourseModeNotFoundError (an unhandled 500).

This is also why the button "started working" after enrolling through the
course page: the learning MFE enrolls with the course's default mode, and once
any LMS enrollment exists the failing add_enrollment call is skipped.

What changed

partner_catalog/services/platform_enrollment.py

  • ensure_edx_platform_enrollment now resolves open-access targets to the
    open mode the course actually offers (audit preferred, honor fallback)
    instead of passing audit blindly.
  • An existing open-mode enrollment satisfies an open-access target without an
    unnecessary update_enrollment call.
  • The function returns the effective LMS mode. This also fixes the same
    latent crash in downgrade_to_audit (unenrollment) for honor-mode courses.

partner_catalog/services/enrollments.py

  • _sync_lms_for_catalog_access reports the effective mode returned by the
    sync instead of assuming the hardcoded target, so the API response's
    lms_enrollment_mode is accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant