Skip to content

fix: show staff lock on prerequisite-gated subsections - #3319

Open
AhtishamShahid wants to merge 1 commit into
openedx:masterfrom
AhtishamShahid:ahtisham/hq-13997-gated-staff-lock
Open

AhtishamShahid wants to merge 1 commit into
openedx:masterfrom
AhtishamShahid:ahtisham/hq-13997-gated-staff-lock

Conversation

@AhtishamShahid

@AhtishamShahid AhtishamShahid commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

When a subsection has a prerequisite, Studio reports its visibility_state as "gated", even when the subsection is hidden from learners (has_explicit_staff_lock: true). The outline sidebar's Visibility setting and the configure modal only checked for "staff_only". So a hidden, gated subsection showed Student Visible, and the only sign it was hidden was the "Staff only" badge on its units.

Unchecking "Hide from learners" on one of those units does nothing. The unit inherits the lock from its subsection, so it stays staff only after Save, and nothing on the page points to the subsection as the cause.

This change also treats hasExplicitStaffLock as staff only in:

  • VisibilitySection (outline sidebar)
  • ConfigureModal (initial "Hide entire subsection" value and the warning)

Impacts: Course Author.

Demo

Before/after on a local Tutor stack (75s, no audio):

pr-3319-before-after.mp4

Testing instructions

  1. Enable subsection prerequisites for the course (Advanced settings, "Enable Subsection Prerequisites").
  2. Create a section with two subsections, A and B, and add a unit to B.
  3. Make A a prerequisite of B, and set B to Staff Only.
  4. Select B in the outline and open Settings in the sidebar.
    • Before: Visibility shows "Student Visible". After: "Staff Only".
  5. Open B's Configure modal and go to the Visibility tab.
    • Before: "Show entire subsection" is selected. After: "Hide entire subsection" is selected.
  6. Click "Student Visible" on B. The unit's "Staff only" badge goes away.

Other information

  • The outline badge for such a subsection still says "Gated", because getItemStatus checks visibilityState alone. I left that unchanged.
  • Tested locally on Tutor: steps 4 to 6 in the browser. New unit tests cover the sidebar and the modal, and both fail without this change.

Studio reports a subsection with a prerequisite as visibilityState
"gated", even when the subsection is hidden from learners. The outline
sidebar and the configure modal only checked for "staff_only", so a
hidden gated subsection showed "Student Visible", and unchecking
"Hide from learners" on its units had no effect because they inherit
the lock. Use hasExplicitStaffLock as well.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 09:37
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 21, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @AhtishamShahid!

This repository is currently maintained by @bradenmacdonald.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes consistently handle explicit staff locks and include regression coverage, with no blocking issues identified; tests were not executed.

No open issues 🎉

What changed in this PR

Corrects Studio’s visibility controls for prerequisite-gated subsections that have an explicit staff lock.

Changes:

  • Recognizes explicit staff locks in the sidebar and configure modal.
  • Adds the lock field to the shared configuration type.
  • Adds regression tests for both interfaces.
File Description
src/​generic/​configure-modal/​ConfigureModal.tsx Applies explicit locks to initial visibility and warnings.
src/​generic/​configure-modal/​ConfigureModal.test.tsx Tests hidden selection for locked, gated subsections.
src/​data/​types.ts Exposes the optional explicit-lock field.
src/​course-outline/​outline-sidebar/​info-sidebar/​sharedSettings/​VisibilitySection.tsx Includes explicit locks in sidebar visibility state.
src/​course-outline/​outline-sidebar/​info-sidebar/​sharedSettings/​VisibilitySection.test.tsx Tests the sidebar’s staff-only state.

Review effort: Balanced

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.20%. Comparing base (de0c6ad) to head (72202f5).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #3319    +/-   ##
========================================
  Coverage   96.20%   96.20%            
========================================
  Files        1446     1446            
  Lines       35384    35385     +1     
  Branches     8179     8476   +297     
========================================
+ Hits        34041    34043     +2     
+ Misses       1301     1300     -1     
  Partials       42       42            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Oct 22, 2026
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: Ready for Review

Development

Successfully merging this pull request may close these issues.

4 participants