feat: Add enrollments actions endpoints#38290
feat: Add enrollments actions endpoints#38290brianjbuck-wgu wants to merge 5 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @brianjbuck-wgu! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf 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 PRYour 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
55e65a1 to
7649a8b
Compare
7649a8b to
b6e9ba3
Compare
There was a problem hiding this comment.
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_statuswith structured status/mode response (including pending viaCourseEnrollmentAllowed). - Added
POST /api/instructor/v2/courses/{course_id}/change_enrollment_modeto change a learner’s mode and create aManualEnrollmentAuditrecord. - 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.
|
do we really need to create a new endpoint for this |
|
I think is missing POST apis for enroll and unenroll learners, also to add/remove beta testers |
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
GetStudentEnrollmentStatusendpoint and adding a new mode-change capability.New Endpoints
1.
GET /api/instructor/v2/courses/{course_id}/enrollment_statusCheck the enrollment status of a learner. Resolves the learner's state as one of:
active,inactive,pending(CourseEnrollmentAllowed exists), ornever_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" }VIEW_ENROLLMENTS(course staff, instructors)email_or_usernamequery parameter (email or username lookup)never_enrolled)CourseEnrollmentAllowedfor pending invitations2.
POST /api/instructor/v2/courses/{course_id}/change_enrollment_modeChange a learner's enrollment mode (e.g., audit → verified). Creates a
ManualEnrollmentAuditrecord 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." }CAN_ENROLL(course staff, instructors)CourseMode.modes_for_course_dictImpacted Roles
Supporting information
Testing instructions
Enrollment status check:
/api/instructor/v2/courses/{course_id}/enrollment_status?email_or_username=<learner>activefor enrolled user,inactivefor deactivated enrollment,pendingfor CEA-only user,never_enrolledfor unknown userChange enrollment mode:
/api/instructor/v2/courses/{course_id}/change_enrollment_modewith{"email_or_username": "<learner>", "mode": "verified"}ManualEnrollmentAuditrecord is createdDeadline
None
Other information