Skip to content

feat: expose field type and options in advanced settings API#38784

Draft
SantiagoSuHe wants to merge 1 commit into
openedx:masterfrom
Schema-Education:schema/advanced-settings-backend-metadata
Draft

feat: expose field type and options in advanced settings API#38784
SantiagoSuHe wants to merge 1 commit into
openedx:masterfrom
Schema-Education:schema/advanced-settings-backend-metadata

Conversation

@SantiagoSuHe

Copy link
Copy Markdown

Description

The Advanced Settings API (/api/contentstore/v0/advanced_settings/{course_id})
returns, for each setting, only value, display_name, help, deprecated,
and hide_on_enabled_publisher. It does not tell clients what type a
setting is, nor what valid choices an enum-like setting accepts.

This forces any UI that wants to render type-specific controls (toggles, number
fields, dropdowns) to hardcode that metadata on the client. That duplication
drifts from the platform over time and can cause silent data loss — e.g. a
dropdown that omits a value the course actually has set.

This PR moves that metadata to the backend, which already knows it, so it can be
the single source of truth.

Changes

  • CourseMetadata.fetch_all now includes two additional fields per setting:
    • type — the XBlock field class name (String, Boolean, Integer,
      Float, List, Dict, …), so clients can choose an input type without
      inferring it from the value's shape.
    • options — the field's values: a list of {display_name, value}
      choices for enum-like fields, a constraints dict (e.g. {"min": 0}) for some
      numeric fields, or null for free-form fields.
  • Adds course-level values to enum settings that lacked them, so their valid
    choices are defined in the backend:
    • showanswer, rerandomize, show_correctness (xmodule/modulestore/inheritance.py)
    • certificates_display_behavior (xmodule/course_block.py)
    • These reference a new xmodule/course_settings_field_options.py that holds
      the canonical option lists.
  • Settings that already declared values (catalog_visibility,
    course_visibility, video_sharing_options) are exposed automatically by the
    serializer change — no per-field edit needed.

The problem-level field definitions in xmodule/capa_block.py are unchanged.
As a follow-up, those could be migrated to reference the same shared option lists
so the problem and course levels share a single source.

The response is additive and backward compatible: existing fields are untouched,
the two new keys are simply added.

Context

This is the backend counterpart to the Advanced Settings redesign frontend PR
openedx/frontend-app-authoring#3019. It addresses review feedback there that the
redesign should not hardcode field metadata in the frontend, but source it from
the backend instead.

Testing

  • Verified CourseMetadata.fetch_all returns type and options for all
    settings via the CMS shell (all 8 enum settings now carry their options;
    booleans report type: "Boolean"; numeric fields report type: "Integer"/
    "Float").
  • Verified end-to-end against the redesigned authoring MFE: enum settings render
    as dropdowns populated from the backend options, booleans as toggles, etc.

Draft

Opened as a draft as the companion to the frontend PR and to gather feedback on
the approach before requesting formal review.

🤖 Generated with Claude Code

Add `type` and `options` to each setting returned by the Advanced Settings
API (CourseMetadata.fetch/fetch_all) so clients can render type-specific
inputs and enum dropdowns without hardcoding that metadata in the frontend.

- course_metadata.py: include the field's class name as `type` and the
  field's `values` as `options` in the serialized output.
- Add course-level `values` to enum settings that lacked them (showanswer,
  rerandomize, show_correctness, certificates_display_behavior) via a new
  shared xmodule/course_settings_field_options module, so their valid
  choices live in the backend as a single source of truth.

The problem-level definitions in capa_block.py are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jun 19, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @SantiagoSuHe!

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.

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

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). 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.

2 participants