feat: Add enrollments actions endpoints#38290
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. DetailsWhere 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. |
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 |
51c3f03 to
2406345
Compare
|
tested it and works as expected 👍 |
diana-villalvazo-wgu
left a comment
There was a problem hiding this comment.
Pls update the PR description with the last endpoints and changes
c9508ab to
aae2f39
Compare
aae2f39 to
84250fd
Compare
d577495 to
c301f44
Compare
wgu-taylor-payne
left a comment
There was a problem hiding this comment.
Overall looks good, some smaller questions/issues:
| * email_students (optional): Send email notification (default: false) | ||
| * reason (optional): Reason for the change | ||
|
|
||
| **Response Values** |
There was a problem hiding this comment.
Please check that these fields and values match up with what is returned from this view.
| * email_students (optional): Send email notification (default: false) | ||
| * auto_enroll (optional): Auto-enroll in the course (add action; default: false) | ||
|
|
||
| **Response Values** |
There was a problem hiding this comment.
Please check that these fields and values match up with what is returned from this view.
…for instructor API v2
c301f44 to
b688835
Compare
Description
Adds two new v2 instructor API endpoints to support the Enrollments Actions tab in the Instructor Dashboard MFE, along with updated API spec documentation.
These endpoints provide structured JSON responses for MFE consumption, enabling bulk enroll/unenroll and beta tester management operations.
New Endpoints
1.
POST /api/instructor/v2/courses/{course_id}/enrollments/modifyEnroll or unenroll one or more learners in a course by email or username.
CAN_ENROLL(course staff, instructors)identifier(list of emails/usernames),action(enrollorunenroll),auto_enroll,email_students, andreasonbefore/afterenrollment state (user,enrollment,allowed,auto_enroll)invalidIdentifier: true; errors returnerror: trueManualEnrollmentAuditrecords for traceability{ "action": "enroll", "auto_enroll": false, "results": [ { "identifier": "learner@example.com", "before": {"user": true, "enrollment": false, "allowed": false, "auto_enroll": false}, "after": {"user": true, "enrollment": true, "allowed": false, "auto_enroll": false} }, { "identifier": "not-an-email", "invalidIdentifier": true } ] }2.
POST /api/instructor/v2/courses/{course_id}/beta_testers/modifyAdd or remove one or more beta testers for a course.
CAN_BETATEST(course staff, instructors)identifier(list of emails/usernames),action(addorremove),email_students, andauto_enrollerror(bool) anduserDoesNotExist(bool) fields{ "action": "add", "results": [ {"identifier": "learner@example.com", "error": false, "userDoesNotExist": false, "is_active": true}, {"identifier": "nobody@example.com", "error": true, "userDoesNotExist": true, "is_active": null} ] }Other Changes
enrollment-v2-api-spec.yamlto match the actual implemented API surfaceEnrollmentStatusViewendpoint (the existing v1get_student_enrollment_statusis sufficient)ChangeEnrollmentModeViewendpoint (mode changes will be handled through a different workflow)Impacted Roles
Supporting information
Testing instructions
Enroll learners:
/api/instructor/v2/courses/{course_id}/enrollments/modifywith{"identifier": ["learner@example.com"], "action": "enroll"}before/afterstate shows enrollment changeManualEnrollmentAuditrecord is createdCourseEnrollmentAllowedis created"not-an-email") to verifyinvalidIdentifier: trueUnenroll learners:
"action": "unenroll"for an enrolled learnerbefore.enrollmentistrueandafter.enrollmentisfalseAdd beta testers:
/api/instructor/v2/courses/{course_id}/beta_testers/modifywith{"identifier": ["learner@example.com"], "action": "add"}auto_enroll: trueto verify auto-enrollmentRemove beta testers:
"action": "remove"for an existing beta testerDeadline
None
Other information