feat: expose field type and options in advanced settings API#38784
feat: expose field type and options in advanced settings API#38784SantiagoSuHe wants to merge 1 commit into
Conversation
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>
|
Thanks for the pull request, @SantiagoSuHe! 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. |
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 asetting 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_allnow 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 withoutinferring it from the value's shape.
options— the field'svalues: a list of{display_name, value}choices for enum-like fields, a constraints dict (e.g.
{"min": 0}) for somenumeric fields, or
nullfor free-form fields.valuesto enum settings that lacked them, so their validchoices are defined in the backend:
showanswer,rerandomize,show_correctness(xmodule/modulestore/inheritance.py)certificates_display_behavior(xmodule/course_block.py)xmodule/course_settings_field_options.pythat holdsthe canonical option lists.
values(catalog_visibility,course_visibility,video_sharing_options) are exposed automatically by theserializer change — no per-field edit needed.
The problem-level field definitions in
xmodule/capa_block.pyare 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
CourseMetadata.fetch_allreturnstypeandoptionsfor allsettings via the CMS shell (all 8 enum settings now carry their options;
booleans report
type: "Boolean"; numeric fields reporttype: "Integer"/"Float").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