fix: adjust studio_grading_url to use the correct URL#38415
fix: adjust studio_grading_url to use the correct URL#38415dwong2708 wants to merge 7 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @dwong2708! 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. |
134b1cd to
d07678c
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Instructor API v2 course metadata response to better support micro-frontend (MFE) URL configuration, including org-specific overrides, and adds a new admin_console_url field gated by instructor-level access.
Changes:
- Add
admin_console_urltoCourseInformationSerializerV2, returning a configured Admin Console authz URL only for users with instructor access. - Update
studio_grading_urlto readCOURSE_AUTHORING_MICROFRONTEND_URLfromMFE_CONFIG, with org-level override support via site configuration helpers. - Update API docs example response and extend/modernize tests (pytest-style assertions) for the new/updated fields.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
lms/djangoapps/instructor/views/serializers_v2.py |
Adds admin_console_url and switches studio_grading_url to org-aware config lookup. |
lms/djangoapps/instructor/views/api_v2.py |
Updates the documented example response to include admin_console_url. |
lms/djangoapps/instructor/tests/test_api_v2.py |
Updates assertions and adds coverage for admin_console_url / studio_grading_url. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mfe_base_url = configuration_helpers.get_value_for_org( | ||
| course_key.org, | ||
| 'MFE_CONFIG', | ||
| getattr(settings, 'MFE_CONFIG', None) | ||
| ) |
| mfe_base_url = configuration_helpers.get_value_for_org( | ||
| course_key.org, | ||
| 'ADMIN_CONSOLE_MICROFRONTEND_URL', | ||
| getattr(settings, 'ADMIN_CONSOLE_MICROFRONTEND_URL', None) |
| def test_admin_console_url_requires_instructor_access(self): | ||
| """ | ||
| Test that the admin console URL is only available to users with instructor access. | ||
| """ | ||
| # data researcher has access to course but is not an instructor | ||
| self.client.force_authenticate(user=self.data_researcher) | ||
| response = self.client.get(self._get_url()) | ||
|
|
||
| assert response.status_code == status.HTTP_200_OK | ||
| assert 'admin_console_url' in response.data | ||
| data = response.data | ||
| assert data['admin_console_url'] is None |
| "grade_cutoffs": "A is 0.9, B is 0.8, C is 0.7, D is 0.6", | ||
| "course_errors": [], | ||
| "studio_url": "https://studio.example.com/course/course-v1:edX+DemoX+2024", | ||
| "admin_console_url": "http://apps.local.openedx.io:2025/admin-console/authz", |
| self.assertIn('has_ended', data) # noqa: PT009 | ||
| self.assertIn('analytics_dashboard_message', data) # noqa: PT009 | ||
| assert 'num_sections' in data | ||
| assert 'tabs' in data |
| mfe_base_url = configuration_helpers.get_value_for_org( | ||
| course_key.org, | ||
| 'MFE_CONFIG', | ||
| getattr(settings, 'MFE_CONFIG', None) | ||
| ) | ||
| mfe_base_url = mfe_base_url.get('COURSE_AUTHORING_MICROFRONTEND_URL') if mfe_base_url else None |
|
Tested on openedx/frontend-app-instructor-dashboard#180 works as expected 👍 |
Summary
Add
admin_console_urlfield to the Course Metadata API (v2) with instructor-level access control and organization-specific MFE configuration support.What Changed
New Feature
admin_console_urlfield to theCourseInformationSerializerV2that returns the URL to the admin console's authorization management pageADMIN_CONSOLE_MICROFRONTEND_URLis configured (supports org-specific configuration)nullif either condition is not metConfiguration Enhancement
studio_grading_urllogic to use organization-specific configuration viaconfiguration_helpers.get_value_for_org()MFE_CONFIG['COURSE_AUTHORING_MICROFRONTEND_URL']with org-level override support instead of directly usingsettings.COURSE_AUTHORING_MICROFRONTEND_URLTest Improvements
self.assertEqual()withassert ==self.assertIn()withassert inself.assertIsInstance()withassert isinstance()self.assertGreaterEqual()withassert >=# noqa: PT009comments (no longer needed with pytest assertions)admin_console_urlfield:nullfor non-instructor users (data researcher test case)@override_settingsdecorators to properly configure MFE URLs in testsTechnical Details
API Response Changes:
{ "admin_console_url": "http://localhost:2025/admin-console/authz", "studio_grading_url": "http://localhost:2001/authoring/course/{course_id}/settings/grading" }Access Control:
instructoraccess level receive a non-nulladmin_console_urlnullConfiguration:
nullif MFE URL not configuredTesting
test_admin_console_url_requires_instructor_access)Files Modified
lms/djangoapps/instructor/views/serializers_v2.py- Added new field and updated configuration logiclms/djangoapps/instructor/views/api_v2.py- Updated API documentation examplelms/djangoapps/instructor/tests/test_api_v2.py- Enhanced tests with new coverage and pytest assertionsDependencies
ADMIN_CONSOLE_MICROFRONTEND_URLsetting to be configured for the feature to be activeopenedx.core.djangoapps.site_configuration.helpersfor org-specific configurationNote: This change is backward compatible - the new field is always present in the response but returns
nullwhen not applicable, ensuring existing API consumers continue to work without modification.