feat: Add enrollments v2 list endpoint#38155
feat: Add enrollments v2 list endpoint#38155brianjbuck-wgu wants to merge 1 commit 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. 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. |
There was a problem hiding this comment.
Pull request overview
Adds a new list_course_enrollments endpoint and enhances the existing list_course_role_members endpoint with search and pagination support for the instructor dashboard MFE.
Changes:
- New
ListCourseEnrollmentsViewwith DB-level search filtering and pagination for active course enrollments - Enhanced
ListCourseRoleMembersViewwith optionalsearch,page, andpage_sizeparameters (backward compatible) - New serializers and comprehensive test coverage for both endpoints
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lms/djangoapps/instructor/views/api.py | New ListCourseEnrollmentsView and search/pagination for ListCourseRoleMembersView |
| lms/djangoapps/instructor/views/api_urls.py | Registers the new list_course_enrollments URL |
| lms/djangoapps/instructor/views/serializer.py | New EnrollmentListSerializer and extended RoleNameSerializer with search/pagination fields |
| lms/djangoapps/instructor/tests/test_enrollment_list_api.py | Comprehensive tests for both endpoints |
| lms/djangoapps/instructor/tests/test_api.py | Updates existing tests to include new pagination metadata fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| """ | ||
| course_key = CourseKey.from_string(course_id) | ||
| course = get_course_with_access( | ||
| request.user, 'instructor', course_key, depth=None |
There was a problem hiding this comment.
Bug: get_course_with_access is called with 'instructor' access level, but permission_name is set to permissions.VIEW_ENROLLMENTS which corresponds to HasAccessRule('staff'). This means course staff users will pass the permission check but then get a 404 from get_course_with_access since they don't have instructor-level access. This should use 'staff' instead of 'instructor' to be consistent with the permission, or match what the ListCourseRoleMembersView does (which uses EDIT_COURSE_ACCESS permission with 'instructor' access level).
| request.user, 'instructor', course_key, depth=None | |
| request.user, 'staff', course_key, depth=None |
|
Why are we using POST instead of GET to retrieve lists? 🤔 |
0524417 to
95675b0
Compare
|
Also i just saw on the requirements that for the list we should have this:
|
4622cf0 to
854e7e7
Compare
|
get for enrollments list works as expected 👍 |
@diana-villalvazo-wgu, yes, this is planned for the actions branch/PR |
854e7e7 to
5300b8e
Compare
|
I tested GET |
7c7ef3f to
8207653
Compare
|
already tested filters, works as expected, maybe just update PR description and remove the role members endpoint not used as part of this PR |
|
@diana-villalvazo-wgu, I updated the description :) |
8207653 to
7dc01c6
Compare
7dc01c6 to
bf2cb5d
Compare
|
Approved and tested on branch openedx/frontend-app-instruct#139 |




Description
Migrates Enrollments endpoint to use in the instructor dashboard MFE:
list_course_enrollmentsendpoint — A newPOST /courses/{course_id}/instructor/api/list_course_enrollmentsendpoint that returns a paginated, searchable list of all active course enrollments. Returns user data (username, email, first_name, last_name) with total count and pagination metadata.Changes:
api.py: AddedListCourseEnrollmentsViewwithVIEW_ENROLLMENTSpermission (HasAccessRule('staff')).api_urls.py: Registered the newlist_course_enrollmentsURL pattern.serializer.py: AddedEnrollmentListSerializerfor request validation.Shared features across both endpoints:
page_size(default: 20, max: 100)count,num_pages, andcurrent_pagemetadataUser roles impacted: Course Staff, Course Instructors, Developers building against the instructor API.
Supporting information
Testing instructions
List Course Enrollments
POST /courses/{course_id}/instructor/api/list_course_enrollmentswith an empty body{}.course_id,enrollments(list of user objects),count,num_pages, andcurrent_page.{"search": "partial_username"}and verify filtered results.{"page": 1, "page_size": 5}and verify correct page size and metadata.{"page": 0}and{"page_size": 0}should return 400.Deadline
None
Other information
ListCourseEnrollmentsViewuses theVIEW_ENROLLMENTSpermission (HasAccessRule('staff')) to allow course staff and instructors access, consistent with other enrollment-viewing endpoints.Qobjects) for search, while the role members endpoint uses in-memory filtering sincelist_with_levelreturns a Python list.