Skip to content

feat: explain archived competency rules in the course row - #3411

Open
bsparks wants to merge 59 commits into
openedx:masterfrom
bsparks:ashatsila/841-archived-course-rules-message
Open

bsparks wants to merge 59 commits into
openedx:masterfrom
bsparks:ashatsila/841-archived-course-rules-message

Conversation

@bsparks

@bsparks bsparks commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes openedx/openedx-core#841. On the Competency Management page, expanding a course whose rules for the selected competency were archived shows a message in place of the course's outline:

This course's rules for this competency were archived, so no new competency criteria associations can be added. This applies only to this course run. Learners' recorded progress is kept.

What changed:

  • The archived message. CourseRow renders the message, in the same place and with the same small-text markup as the existing "This course has no gradeable subsections." text, instead of mounting CourseOutlineSubtree. Because the subtree is never mounted, the outline of an archived course is never requested, and the message replaces every other state of the row: another competency's association, no write access, no gradeable subsections, and an outline error.
  • Loading. While the associations data is loading, a newly expanded row shows a small spinner instead of the outline, and requests no outline. The row reads the provider's status, the same value the Competency Criteria Associations panel uses, so the two panels agree on when the data is ready. Once it has loaded, the row shows the message or the outline without a page reload.
  • An outline that is already shown stays. When the data reloads after a competency switch, a search, or a page change, a row that already shows its outline keeps it, so the sections the author expanded stay expanded. Its add controls are hidden until the data has loaded. If the course is archived for the new selection, the message replaces the outline once the data arrives.
  • After a delete. A delete's background refetch keeps the previous data, so no spinner appears. A course that the delete archived switches from its outline to the message, and a row that already shows the message keeps it throughout.
  • Load failure. If the associations data fails to load, an expanded row shows its outline with no add controls.
  • Keyboard focus. When the outline is replaced by the message and keyboard focus was inside the outline, focus moves to the message, so a screen reader reads it. This includes removing the course's last association from its chip with the keyboard: Chromium drops focus to the page body when the remove button is disabled for the delete, so the outline remembers that focus was inside it when the delete began. Focus that is anywhere else stays where it is, and the message is not announced, because it has no live region.
  • The response type. archivedCourseKeys is a required field of CompetencyCriteriaGroupsResponse. A response without it reads as "no course archived".

Roles affected: Course Author (Competency Management page).

Screenshots

00-outline-not-archived 01-archived-message 02-loading 03-load-failed 04-archived-message-narrow 05-before-remove 06-after-remove-archived

Supporting information

Testing instructions

You need openedx-core 1.29.0 or later, a Competency taxonomy, and a course you can edit in Studio in which a learner has recorded progress against one of the competency's rules.

  1. On the Competency Management page of the taxonomy (/authoring/taxonomy/<id>/competencies), select the competency. In the Courses & Content panel, expand the course. Its sections and gradeable subsections are shown.
  2. In the Competency Criteria Associations panel, delete the course's last Rule Group for this competency. Because a learner has progress, the backend archives the course-level group instead of deleting it.
  3. Without reloading, the expanded course row now shows the archived message in place of its outline. Collapse and expand the row: the message is shown again. In the browser's developer tools, confirm that no course_index request was made for the course after the archive.
  4. Search for the course by title. It is listed, and expanding it shows the message.
  5. Select another competency for which the course has no archived rules and expand the course. Its outline is shown as usual. Select the first competency again: the message is back.
  6. Expand another run of the same course whose rules are not archived. Its outline is shown.
  7. Reload the page with the network throttled to "Slow 3G". Select a competency and expand a course before the Competency Criteria Associations panel has finished loading. The row shows a spinner and no add control. When the panel finishes loading, the row shows the message or the outline without a reload.
  8. Expand a course that is not archived and expand one of its sections. Select another competency. The outline stays in place with the section still expanded, and its add controls return once the data has loaded.
  9. Block the criteria-groups request in the developer tools and reload. Expanding a course shows its outline, and no subsection offers an add control.
  10. Keyboard: with a course whose last association is shown as a chip in its own outline, Tab to that chip's remove button and press Enter. If the removal archives the course, the row shows the message and focus is on it, so a screen reader reads it. Repeat with focus outside the row (for example on the search field) and trigger the archive from the associations panel: focus stays where it was and the message is not announced.

Other information

  • Dependency. The message needs openedx-core 1.29.0 or later. Against an older backend the response has no archived_course_keys, so no course reads as archived and the page behaves as it did before.
  • Question for reviewers. The ticket's loading scenario says a course expanded while the associations data loads shows a loading indicator. A row expanded during the load does. A row that already shows its outline keeps it during a reload, as described above, because replacing it with the spinner would collapse the author's expanded sections on every competency switch or search. Until the data arrives, that row can show the outline, without add controls, of a course that is archived for the new selection.
  • Rejected creates. If another author archives a course while this author has its outline open, the backend rejects the create and the row keeps offering its add controls until the next refetch, because the create hook refetches only on success. This predates this PR; a follow-up could refetch on settle, as the delete hooks do.
  • Naming. The predicate is isCourseGroupArchived, not isCourseArchived, because "archived course" in this repository already means an ended Studio course run.
  • Tests. The PR adds 24 tests: 20 in the new CourseRow.test.tsx, 3 in CompetencyAssociationsContext.test.tsx, and 1 in CourseSearchBrowse.test.tsx. All 837 tests in src/taxonomy/competency-management pass. tsc --noEmit and dprint are clean. npx oxlint --type-aware reports one no-floating-promises error in CompetencyAssociationsContext.tsx, on a queryClient.invalidateQueries call for blocked courses; that line is unchanged from master. jsdom does not move focus off a button that becomes disabled and has no assistive technology, so step 10 above covers what the focus tests cannot; the keyboard removal was also checked in headless Chromium against a devstack with openedx-core 1.30.0.
  • AI assistance. This PR was written with Claude Code (Anthropic). A developer reviewed the code, the tests and this description.

Best Practices Checklist

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. The new and changed files import siblings within src/taxonomy/competency-management with ../, matching the rest of that folder.

🤖 Generated with Claude (Fable 5.2)

AShatsila and others added 30 commits November 6, 2026 23:11
Adds the API client, query hooks, types and index utilities for the CBE
criteria-groups, criteria and rule-profile endpoints, and the
associations context that the criteria UI builds on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expanding a course now focuses its last bottom-tier group and rule box
unless focus is already in that course, and the provider exposes
whether course outlines are still loading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ProcessingNotification takes an optional icon, threaded through
showToast. The already-associated toast uses InfoOutline and the
create-criterion failure toasts use Error; every other toast keeps the
spinning gear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Switching the active competency reset the expanded-course set, so a
course left expanded in the content panel lost its select controls until
it was collapsed and expanded again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A create request that finishes after the author switches competency no
longer replaces the new competency's focus. A course expanded before the
criteria groups and default profile load now gets its group and rule
focus once they arrive, unless the author has picked a group or rule
since.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pending course expansion is no longer applied in the render that
switches competency, where the index may already hold the new
competency's cached tree. A create response is matched against a
per-switch selection counter, so leaving and returning to the same
competency no longer lets an old response overwrite the author's focus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The component now renders info and error toasts as well as the saving
spinner, so the name describes the generic toast, with the spinner as
the default icon. The icon tests assert that the passed icon renders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The provider exposes one status/error across groups, profile and
  course outlines instead of raw query objects, and the status stays
  successful for the rest of a competency once it settles.
- Each create handles its own result through mutateAsync, the context
  exposes isAssociating, and the mutation stays pending until the
  groups refetch completes.
- Competency-switch bookkeeping lives in one reducer, which also drops
  create responses from an earlier competency visit.
- A missing default profile shows the failure toast instead of a
  silent no-op.
- Rename index to groupsIndex and lastRealRuleKeyIn to lastRuleKeyIn,
  drop the archived field the groups endpoint never sends, and move
  the provider test fixtures into __mocks__.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the course group, rule box and criterion chip components and wires
gradeable-subsection association selection into the competency
management page's course search panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The associations panel shows its loading state until course outlines
resolve, and subsection rows offer the add control only once the
criteria groups and default rule profile have loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nest course groups, criteria groups and rule boxes with a left accent bar
on the focused item at each level. Render the subsection association as
a single pill with applied and available states. Out-of-scope actions
(removing a criterion or an association, editing the score threshold)
are shown as inert icons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The course group list shows its loading and error states from the
context status, so the empty state appears only after a successful
load. The subsection association button stays disabled until the data
has loaded and while a create is in flight. The test mock provider
moves to __mocks__ with the flat context shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The context value is a discriminated union on status, so a successful
  load always carries the groups tree and the default profile. An
  outline 403 or 404 hides that course; any other outline error is a
  load error, so a failed load never reads as "no associations".
- When the focused rule key matches none of the group's boxes, focus
  moves to the group's last box, and a create always sends the focused
  group's id.
- The subsection pill is the row's only control, with an accessible
  label, rendered only once the data has loaded and the course is
  editable, and disabled while a create is in flight.
- Group headers and rule-box threshold lines are native buttons marked
  with aria-current; a collapsed course card reopens when focus moves
  into it; course card toggles name their course.
- Inert remove icons, the score chevron and their unused props and
  branches are removed until the removal and editing tickets add them.
- Stylesheets use Paragon tokens and Stack gaps, criteria-groups no
  longer imports from course-search, and test fixtures are shared via
  __mocks__, with an integration test over the real provider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An "Associate" click with focus outside the subsection's course now adds
to that course's last group and rule box instead of creating a new group.
Expanding a course reopens its collapsed card, a failed permission check
shows an error, and isAssociating applies only to the selected competency.
The threshold label is one ICU message with a formatted percent, the
rule-box overlay uses Paragon's stretched-link, and tests are hardened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use a bold span for the course name in the card heading, name the
stale-rule-key action fields and pull their resolution into a helper,
keep the chip list above the rule box's stretched link, reword a
translator description, and tighten several tests and mock comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Space the "Demonstrate Mastery For" line evenly from the label and the
first card, center the competency badge on its text, tighten the course
card header, and use Paragon tokens for fractional font and spacing values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shrink the collapse toggle to its 16px icon, align it and the body with
the Figma offsets, and keep a single keyboard focus ring on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AShatsila and others added 24 commits November 9, 2026 19:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A saved rule box's score now opens a "Competency Completion Rule"
popover with Cancel and Save, and Save asks for confirmation before
anything is sent. Choosing a new any/all value on a saved criteria
group asks for the same confirmation right away; Cancel switches the
dropdown back. A failed save keeps the dialog open with an error alert
instead of a toast, so the author's edit stays on screen.

Unsaved placeholder rule boxes and groups keep their inline behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ility

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
When a course run's course-level group for the selected competency is
archived, the expanded row in the Courses & Content panel shows a message
in place of the outline, and the outline is never fetched. The archived
course runs come from the groups response's archived_course_keys (openedx#840),
read through the provider as isCourseGroupArchived. While the groups or
profile query is loading, an expanded row shows a spinner. Keyboard focus
moves to the message only when it was inside the outline at the moment
the outline unmounted.

Closes openedx/openedx-core#841

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Upstream master already contains the competency management work this
branch was stacked on, plus a score settings popover with an editable
operator. This merge takes upstream's version of every file. The edit
confirmation is re-applied on top of upstream's popover in the commits
that follow.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Editing a saved rule box's score or a saved criteria group's any/all
value on the Competency Management page asks the author to confirm
before anything is saved. The dialog states that the change applies
only to future evaluations of the competency.

The score settings popover has Cancel and Save buttons. On a saved rule
box, Save and Enter open the confirmation, and Cancel, Escape, and a
click outside discard the draft. Cancelling the confirmation reopens
the popover with the unsaved operator and percentage. A failed save
keeps the dialog open with an alert, so the author can retry.

The unsaved placeholder rule box and group keep saving without a
dialog, because no learner has been evaluated against them.

DeleteModal takes an isPending prop that blocks dismissal and shows the
confirm button's pending state while a save is in flight.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings in upstream master and the edit confirmation built on upstream's
score settings popover. The archived course rules message is kept on top
of upstream's blocked-course handling: an archived course shows the
message in place of its outline, so the blocked-course tooltip inside
the outline does not render for it.

The test for an expanded row while the groups load expects the loading
spinner, because the row does not know whether the course is archived
until the groups arrive.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…chived message

- A shown outline stays mounted while the associations data reloads, so
  its expanded sections survive a competency switch or a search or page
  change. The spinner shows only before the outline's first mount.
- The "focus was inside the outline" flag survives a spinner between the
  outline and the archived message.
- Removing the last association from its chip with the keyboard moves
  focus to the archived message. Chromium drops focus to the body when
  the remove button is disabled for the delete, so the outline remembers
  that focus was inside it when the delete began.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 4, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @bsparks!

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.

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.59%. Comparing base (475a3df) to head (c6251f5).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #3411    +/-   ##
========================================
  Coverage   96.58%   96.59%            
========================================
  Files        1473     1473            
  Lines       37169    37210    +41     
  Branches     8828     9177   +349     
========================================
+ Hits        35901    35942    +41     
+ Misses       1227     1213    -14     
- Partials       41       55    +14     

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

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.

[FE] Explain archived competency rules in the Courses & Content panel

3 participants