Skip to content

feat: Add enrollments actions endpoints#38290

Draft
brianjbuck-wgu wants to merge 5 commits intoopenedx:masterfrom
WGU-Open-edX:feature/37537-enrollments-api-actions
Draft

feat: Add enrollments actions endpoints#38290
brianjbuck-wgu wants to merge 5 commits intoopenedx:masterfrom
WGU-Open-edX:feature/37537-enrollments-api-actions

Conversation

@brianjbuck-wgu
Copy link
Copy Markdown
Contributor

@brianjbuck-wgu brianjbuck-wgu commented Apr 6, 2026

Description

Adds two new v2 instructor API endpoints to support the Enrollments Actions tab in the Instructor Dashboard MFE.

These endpoints provide structured JSON responses for MFE consumption, replacing the unstructured string responses from the v1 GetStudentEnrollmentStatus endpoint and adding a new mode-change capability.

New Endpoints

1. GET /api/instructor/v2/courses/{course_id}/enrollment_status

Check the enrollment status of a learner. Resolves the learner's state as one of: active, inactive, pending (CourseEnrollmentAllowed exists), or never_enrolled.

{
    "course_id": "course-v1:edX+DemoX+Demo_Course",
    "enrollment_status": "active",
    "mode": "audit",
    "email_or_username": "learner@example.com",
    "message": "Enrollment status for learner@example.com: active"
}
  • Permission: VIEW_ENROLLMENTS (course staff, instructors)
  • Accepts email_or_username query parameter (email or username lookup)
  • Handles non-existent users gracefully (returns never_enrolled)
  • Checks CourseEnrollmentAllowed for pending invitations

2. POST /api/instructor/v2/courses/{course_id}/change_enrollment_mode

Change a learner's enrollment mode (e.g., audit → verified). Creates a ManualEnrollmentAudit record for traceability.

{
    "course_id": "course-v1:edX+DemoX+Demo_Course",
    "email_or_username": "learner@example.com",
    "old_mode": "audit",
    "new_mode": "verified",
    "message": "Enrollment mode changed from audit to verified for learner@example.com."
}
  • Permission: CAN_ENROLL (course staff, instructors)
  • Validates the target mode against CourseMode.modes_for_course_dict
  • Returns 404 if user not found or not actively enrolled
  • Returns 400 if target mode is invalid or same as current mode

Impacted Roles

  • Course Staff / Instructors: New API endpoints for enrollment management actions
  • Developers: New v2 API surface for MFE integration

Supporting information

Testing instructions

  1. Enrollment status check:

    • As course staff, GET /api/instructor/v2/courses/{course_id}/enrollment_status?email_or_username=<learner>
    • Verify active for enrolled user, inactive for deactivated enrollment, pending for CEA-only user, never_enrolled for unknown user
  2. Change enrollment mode:

    • As course staff, POST /api/instructor/v2/courses/{course_id}/change_enrollment_mode with {"email_or_username": "<learner>", "mode": "verified"}
    • Verify mode is changed and ManualEnrollmentAudit record is created
    • Verify 400 for invalid mode or same-mode request
    • Verify 404 for non-existent or inactive user

Deadline

None

Other information

  • No database migrations required
  • No breaking changes to existing endpoints

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 6, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @brianjbuck-wgu!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Apr 6, 2026
@brianjbuck-wgu brianjbuck-wgu force-pushed the feature/37537-enrollments-api-actions branch 2 times, most recently from 55e65a1 to 7649a8b Compare April 6, 2026 17:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new Instructor API v2 endpoints to support the Instructor Dashboard MFE’s Enrollments Actions workflows by providing structured enrollment status lookup and enrollment mode change functionality.

Changes:

  • Added GET /api/instructor/v2/courses/{course_id}/enrollment_status with structured status/mode response (including pending via CourseEnrollmentAllowed).
  • Added POST /api/instructor/v2/courses/{course_id}/change_enrollment_mode to change a learner’s mode and create a ManualEnrollmentAudit record.
  • Registered both endpoints in the instructor v2 URLconf and added v2 API tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
lms/djangoapps/instructor/views/serializers_v2.py Adds request/response serializers for enrollment status lookup and mode change APIs.
lms/djangoapps/instructor/views/api_v2.py Implements the two new v2 endpoints (status lookup + mode change) and auditing.
lms/djangoapps/instructor/views/api_urls.py Wires new v2 routes for the endpoints.
lms/djangoapps/instructor/tests/test_api_v2.py Adds test coverage for both endpoints’ main success/error paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Apr 6, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Apr 6, 2026
@diana-villalvazo-wgu
Copy link
Copy Markdown

do we really need to create a new endpoint for this GET /api/instructor/v2/courses/{course_id}/enrollment_status?
Im currently using courses/${courseId}/instructor/api/get_student_enrollment_status and i don't see any new attribute that is needed/mandatory for the new mocks 🤔

@diana-villalvazo-wgu
Copy link
Copy Markdown

I think is missing POST apis for enroll and unenroll learners, also to add/remove beta testers

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

Labels

mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

5 participants