Skip to content

fix: write course certificate settings to the draft branch - #395

Merged
AliAlfaifi merged 1 commit into
mainfrom
fix/certificates-write-draft-branch
Oct 1, 2026
Merged

AliAlfaifi merged 1 commit into
mainfrom
fix/certificates-write-draft-branch

Conversation

@AliAlfaifi

Copy link
Copy Markdown
Contributor

Description:

Fixes PUT /api/fx/courses/v1/certificates/<course_id>/ with enabled=1 (#393, shipped in v0.13.5). Found in the prod end-to-end test on 2026-10-01.

Bug: the LMS modulestore defaults to the published branch (published-only, confirmed on a prod pod). enable_course_certificates therefore wrote the certificate configuration and cert_html_view_enabled only to the published course:

  • Studio's Certificates page reads the draft branch, so it showed "no certificates" (course-v1:lms+HP101+etw22: draft [], published [Course Certificate, active]).
  • CourseOverview.has_any_active_web_certificate stayed False.
  • The next Studio settings save re-publishes the draft over the published course and silently reverts the change.

Fix: read and update the course inside modulestore().branch_setting(ModuleStoreEnum.Branch.draft_preferred, course_key), which is how Studio edits course settings. The course block is in DIRECT_ONLY_CATEGORIES, so split's update_item auto-publishes it (_auto_publish_no_children) and emits course_published, which refreshes the course overview. I read this behaviour in the Teak source; it is to be confirmed on stage.

enabled=0 is unchanged (it only writes the issuance flag).

Testing

  • tox -e py311-teak/sumac/redwood: 2250 passed, 100% coverage; tox -e quality passes.
  • The new assertion checks that the course is read and updated inside the draft branch context. It fails on the current main (4 failures) and passes with this fix.
  • Before merge: stage image pinned to this branch, then on stage check that enabled=1 puts the config in both draft and published, Studio shows it active, and has_any_active_web_certificate is true.

Related Issue:

🤖 Generated with Claude Code

The LMS modulestore defaults to the published branch, so enabling certificates wrote the configuration and cert_html_view_enabled only to the published course. Studio reads the draft branch (it showed no certificate), the course overview was not refreshed, and the next Studio settings save re-published the draft over it. Editing inside a draft_preferred branch context matches Studio: the course block is a direct-only category, so the update is auto-published and course_published fires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AliAlfaifi
AliAlfaifi merged commit b4a8fa3 into main Oct 1, 2026
2 checks passed
@AliAlfaifi
AliAlfaifi deleted the fix/certificates-write-draft-branch branch October 1, 2026 16:58
@AliAlfaifi AliAlfaifi mentioned this pull request Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant