Skip to content

fix: adjust studio_grading_url to use the correct URL#38415

Draft
dwong2708 wants to merge 7 commits intoopenedx:masterfrom
WGU-Open-edX:dwong2708/fix-studio-grading-url
Draft

fix: adjust studio_grading_url to use the correct URL#38415
dwong2708 wants to merge 7 commits intoopenedx:masterfrom
WGU-Open-edX:dwong2708/fix-studio-grading-url

Conversation

@dwong2708
Copy link
Copy Markdown
Contributor

@dwong2708 dwong2708 commented Apr 22, 2026

Summary

Add admin_console_url field to the Course Metadata API (v2) with instructor-level access control and organization-specific MFE configuration support.

What Changed

New Feature

  • Added admin_console_url field to the CourseInformationSerializerV2 that returns the URL to the admin console's authorization management page
  • The URL is conditionally returned based on:
    • User has instructor-level access to the course
    • ADMIN_CONSOLE_MICROFRONTEND_URL is configured (supports org-specific configuration)
  • Returns null if either condition is not met

Configuration Enhancement

  • Updated studio_grading_url logic to use organization-specific configuration via configuration_helpers.get_value_for_org()
  • Now checks MFE_CONFIG['COURSE_AUTHORING_MICROFRONTEND_URL'] with org-level override support instead of directly using settings.COURSE_AUTHORING_MICROFRONTEND_URL

Test Improvements

  • Migrated assertions from unittest to pytest style:
    • Replaced self.assertEqual() with assert ==
    • Replaced self.assertIn() with assert in
    • Replaced self.assertIsInstance() with assert isinstance()
    • Replaced self.assertGreaterEqual() with assert >=
    • Removed # noqa: PT009 comments (no longer needed with pytest assertions)
  • Added test coverage for the new admin_console_url field:
    • Verifies URL is present and correctly formatted for instructors
    • Verifies URL is null for non-instructor users (data researcher test case)
  • Added @override_settings decorators to properly configure MFE URLs in tests

Technical 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:

  • Only users with instructor access level receive a non-null admin_console_url
  • Staff, data researchers, and other roles receive null

Configuration:

  • Supports org-specific overrides via site configuration
  • Falls back to global settings if org-specific config not found
  • Returns null if MFE URL not configured

Testing

  • ✅ Existing test updated with new assertions and field validation
  • ✅ New test added for access control (test_admin_console_url_requires_instructor_access)
  • ✅ All assertions migrated to pytest style for consistency

Files Modified

  • lms/djangoapps/instructor/views/serializers_v2.py - Added new field and updated configuration logic
  • lms/djangoapps/instructor/views/api_v2.py - Updated API documentation example
  • lms/djangoapps/instructor/tests/test_api_v2.py - Enhanced tests with new coverage and pytest assertions

Dependencies

  • Requires ADMIN_CONSOLE_MICROFRONTEND_URL setting to be configured for the feature to be active
  • Uses existing openedx.core.djangoapps.site_configuration.helpers for org-specific configuration

Note: This change is backward compatible - the new field is always present in the response but returns null when not applicable, ensuring existing API consumers continue to work without modification.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 22, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Apr 22, 2026

Thanks for the pull request, @dwong2708!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If 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 PR

Your 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@dwong2708 dwong2708 force-pushed the dwong2708/fix-studio-grading-url branch from 134b1cd to d07678c Compare April 23, 2026 17:46
@dwong2708 dwong2708 marked this pull request as ready for review April 23, 2026 23:00
@dwong2708 dwong2708 requested a review from Copilot April 23, 2026 23:00
@dwong2708 dwong2708 marked this pull request as draft April 23, 2026 23:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_url to CourseInformationSerializerV2, returning a configured Admin Console authz URL only for users with instructor access.
  • Update studio_grading_url to read COURSE_AUTHORING_MICROFRONTEND_URL from MFE_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.

Comment on lines +461 to +465
mfe_base_url = configuration_helpers.get_value_for_org(
course_key.org,
'MFE_CONFIG',
getattr(settings, 'MFE_CONFIG', None)
)
Comment on lines +476 to +479
mfe_base_url = configuration_helpers.get_value_for_org(
course_key.org,
'ADMIN_CONSOLE_MICROFRONTEND_URL',
getattr(settings, 'ADMIN_CONSOLE_MICROFRONTEND_URL', None)
Comment on lines +183 to +194
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
Comment on lines +461 to +466
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
@diana-villalvazo-wgu
Copy link
Copy Markdown

Tested on openedx/frontend-app-instructor-dashboard#180 works as expected 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

4 participants