feat: Instructor Dashboard - Add Certificates and generation history v2 api#38176
Conversation
|
Thanks for the pull request, @wgu-jesse-stewart! 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. |
…s://github.com/WGU-Open-edX/edx-platform into wgu-jesse-stewart/instructor-certificates-list
brianjbuck-wgu
left a comment
There was a problem hiding this comment.
Overall a good start, I'd like to see a refactor to have the get_queryset() methods return querysets and then work on those querysets in separate methods. Also, I'd like to see some tests.
| def get_queryset(self): | ||
| """ | ||
| Returns the queryset of certificate generation history. | ||
| """ | ||
| from lms.djangoapps.certificates.models import CertificateGenerationHistory | ||
|
|
||
| course_id = self.kwargs["course_id"] | ||
| course_key = CourseKey.from_string(course_id) | ||
|
|
||
| # Validate that the course exists | ||
| get_course_by_id(course_key) | ||
|
|
||
| # Get generation history | ||
| history = CertificateGenerationHistory.objects.filter( | ||
| course_id=course_key | ||
| ).select_related('generated_by', 'instructor_task').order_by('-created') | ||
|
|
||
| # Build result list | ||
| results = [] | ||
| for entry in history: | ||
| # Determine task name | ||
| task_name = "Regenerated" if entry.is_regeneration else "Generated" | ||
|
|
||
| # Format date | ||
| date = entry.created.strftime("%B %d, %Y") | ||
|
|
||
| # Get details about what was generated/regenerated | ||
| details = str(entry.get_certificate_generation_candidates()) | ||
|
|
||
| results.append({ | ||
| 'task_name': task_name, | ||
| 'date': date, | ||
| 'details': details, | ||
| }) | ||
|
|
||
| return results |
There was a problem hiding this comment.
This also should also return a queryset instead of a list.
Great feedback - thank you - I will work on this |
…s://github.com/WGU-Open-edX/edx-platform into wgu-jesse-stewart/instructor-certificates-list
closes: #37916
closes: #37915
Description
This pull request adds new REST API endpoints to support certificate management functionality in the instructor dashboard, enabling the frontend to migrate to a micro-frontend architecture. The changes introduce four new API endpoints for viewing, regenerating, and configuring certificates.
Impact on User Roles:
Course Instructors/Staff: Will be able to access enhanced certificate management features through a new micro-frontend interface, including:
Developers: New API endpoints are available for integration with the instructor micro-frontend application
New API Endpoints:
GET /api/instructor/v2/courses/{course_id}/certificates/issued- List issued certificates with filtering and searchGET /api/instructor/v2/courses/{course_id}/certificates/generation_history- View certificate generation historyPOST /api/instructor/v2/courses/{course_id}/certificates/regenerate- Trigger certificate regeneration tasksGET /api/instructor/v2/courses/{course_id}/certificates/config- Check if certificate generation is enabledConfiguration Changes:
INSTRUCTOR_MICROFRONTEND_URLconfiguration to devstack environment pointing tohttp://apps.local.openedx.io:2003Supporting information
This change supports the migration of instructor dashboard functionality to a micro-frontend architecture, specifically for certificate management features.
Testing instructions
http://apps.local.openedx.io:8000/api-docs/#/instructor/instructor_v2_courses_certificates_issued_list
Setup: Ensure you have a course with various certificate statuses (downloadable, notpassing, audit_passing, etc.)
Test Issued Certificates Endpoint:
List all certificates
GET /api/instructor/v2/courses/{course_id}/certificates/issued
Search by username
GET /api/instructor/v2/courses/{course_id}/certificates/issued?search=student1
Filter by status
GET /api/instructor/v2/courses/{course_id}/certificates/issued?filter=received
GET /api/instructor/v2/courses/{course_id}/certificates/issued?filter=granted_exceptions
GET /api/instructor/v2/courses/{course_id}/certificates/issued?filter=audit_passing
Test Certificate Generation History:
GET /api/instructor/v2/courses/{course_id}/certificates/generation_history
Test Certificate Regeneration:
Regenerate specific statuses
POST /api/instructor/v2/courses/{course_id}/certificates/regenerate
Body: {"statuses": ["downloadable", "notpassing"]}
Generate for allowlisted students
POST /api/instructor/v2/courses/{course_id}/certificates/regenerate
Body: {"student_set": "allowlisted"}
Test Certificate Configuration:
GET /api/instructor/v2/courses/{course_id}/certificates/config
Verify Permissions: Ensure endpoints return 403 for users without instructor permissions
Verify Pagination: Test pagination with page and page_size parameters on list endpoints
Deadline
None
Other information