Skip to content

fix: adjust studio_grading_url to use the correct URL#38415

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

fix: adjust studio_grading_url to use the correct URL#38415
dwong2708 wants to merge 14 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.

Details
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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Apr 22, 2026
@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 thread lms/djangoapps/instructor/views/serializers_v2.py Outdated
Comment thread lms/djangoapps/instructor/views/serializers_v2.py Outdated
Comment thread lms/djangoapps/instructor/tests/test_api_v2.py
Comment thread lms/djangoapps/instructor/views/api_v2.py
Comment thread lms/djangoapps/instructor/tests/test_api_v2.py Outdated
Comment thread lms/djangoapps/instructor/views/serializers_v2.py Outdated
@diana-villalvazo-wgu
Copy link
Copy Markdown
Contributor

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

@dwong2708 dwong2708 marked this pull request as ready for review April 24, 2026 16:38
Copy link
Copy Markdown
Contributor

@brianjbuck-wgu brianjbuck-wgu left a comment

Choose a reason for hiding this comment

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

LGTM!

@dwong2708 dwong2708 force-pushed the dwong2708/fix-studio-grading-url branch from 6a40994 to df9e5fd Compare April 24, 2026 16:51
@dwong2708 dwong2708 marked this pull request as draft April 24, 2026 17:00
@dwong2708 dwong2708 force-pushed the dwong2708/fix-studio-grading-url branch from 2a4fbba to 17d04df Compare April 24, 2026 19:31
@dwong2708 dwong2708 marked this pull request as ready for review April 24, 2026 20:13
Copy link
Copy Markdown
Contributor

@wgu-taylor-payne wgu-taylor-payne left a comment

Choose a reason for hiding this comment

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

Nice work on the admin_console_url feature — the access gating and test coverage across instructor, staff, and data researcher roles look solid.

Two things I think we should address before merging, both around how the MFE URL settings are sourced.

Review assisted by Kiro

Comment on lines +463 to +467
mfe_base_url = configuration_helpers.get_value(
'MFE_CONFIG',
getattr(settings, 'MFE_CONFIG', None)
)
mfe_base_url = mfe_base_url.get('COURSE_AUTHORING_MICROFRONTEND_URL') if mfe_base_url else None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should probably use the standalone COURSE_AUTHORING_MICROFRONTEND_URL setting rather than pulling it out of MFE_CONFIG. Based on what I can tell, every other MFE URL consumed by LMS backend code (CATALOG_MICROFRONTEND_URL, ACCOUNT_MICROFRONTEND_URL, LEARNING_MICROFRONTEND_URL, DISCUSSIONS_MICROFRONTEND_URL, PROFILE_MICROFRONTEND_URL, WRITABLE_GRADEBOOK_URL, etc.) reads from a standalone setting — none of them go through MFE_CONFIG. MFE_CONFIG is the config surface served to frontends via the MFE Config API; it's not really intended as a settings source for backend logic. (There is one instance in course_groups/rest_api/views.py that reads STUDIO_BASE_URL from MFE_CONFIG, but that key has no standalone equivalent — different situation.)

tutor-mfe does happen to inject COURSE_AUTHORING_MICROFRONTEND_URL into MFE_CONFIG in its LMS settings patches, so this works for Tutor deployments. But I don't think we should rely on deployment tooling for that contract.

Using configuration_helpers.get_value with the standalone setting name is the right call for site-config override support — we'd just want to change what it's looking up:

Suggested change
mfe_base_url = configuration_helpers.get_value(
'MFE_CONFIG',
getattr(settings, 'MFE_CONFIG', None)
)
mfe_base_url = mfe_base_url.get('COURSE_AUTHORING_MICROFRONTEND_URL') if mfe_base_url else None
mfe_base_url = configuration_helpers.get_value(
'COURSE_AUTHORING_MICROFRONTEND_URL',
getattr(settings, 'COURSE_AUTHORING_MICROFRONTEND_URL', None)
)

Since both LMS and CMS now need this setting, it should probably be moved from cms/envs/common.py to openedx/envs/common.py — that's where the other shared MFE URLs live (ACCOUNT_MICROFRONTEND_URL, LEARNING_MICROFRONTEND_URL, DISCUSSIONS_MICROFRONTEND_URL).

Comment on lines +476 to +478
mfe_base_url = configuration_helpers.get_value(
'ADMIN_CONSOLE_MICROFRONTEND_URL',
getattr(settings, 'ADMIN_CONSOLE_MICROFRONTEND_URL', None)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The configuration_helpers.get_value usage here looks right, but ADMIN_CONSOLE_MICROFRONTEND_URL doesn't appear to be defined in any edx-platform settings module currently — the getattr fallback to None keeps it safe, but deployers won't know this setting exists without reading the serializer code.

I think we should add it to openedx/envs/common.py (defaulting to None) with the standard annotation block (setting_name, setting_description, setting_creation_date, setting_use_cases, etc.). The admin console MFE is pretty CMS-centric, and LMS needs the URL now — putting it in the shared settings avoids a future move or duplication if CMS needs it too. This would follow the same pattern as the other MFE URL settings.

@dwong2708 dwong2708 force-pushed the dwong2708/fix-studio-grading-url branch from 17d04df to 0ae3b6a Compare April 25, 2026 01:13
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.

6 participants