Skip to content

[FE] Manage & Apply Competencies: change an existing bottom-tier group's combining logic and an existing rule box's score #794

Description

@thelmick-unicon

User Story

As a course author, I want to change how an existing bottom-tier group combines its rule boxes, or the score an existing rule box requires, in order to correct a mastery rule without deleting and rebuilding the whole branch.

Acceptance Criteria

Scenario: Change how a saved bottom-tier group combines its rule boxes
  Given a bottom-tier group whose rule boxes already have saved content, set to require any one of them
  When I change it to require all of them
  Then the change is saved
  And it still reads as requiring all of them after I reload

Scenario: Change the score a rule box requires
  Given a rule box that already has content associated with it
  When I change the score it requires
  Then every piece of content in that rule box is judged by the new score
  And the new score is still shown after I reload

Scenario: A persisted rule box's score cannot duplicate one already in the same group
  Given a bottom-tier group containing two rule boxes with different scores, both already holding content
  When I change one rule box's score to match the other's
  Then the change is refused and the reason is shown
  And both rule boxes keep the scores they had

Scenario: Setting a rule box back to the default value returns it to the default
  Given a rule box I previously changed to a score of my own
  When I set it back to the same value the system default supplies
  Then the displayed score is unchanged, since the page never distinguishes a default from a matching override (see #672)
  And inspecting the underlying data directly confirms the override has been cleared and the criterion now follows the system default

Scenario: A change is rejected by the backend
  Given I change how a bottom-tier group combines its rule boxes, or the score a rule box requires
  When the save is rejected
  Then the control returns to the value it held before my change
  And an error is shown, following this feature's existing generic error-handling pattern

Scenario: I lack permission to change an existing bottom-tier group's or rule box's settings
  Given a bottom-tier group or rule box I am not permitted to edit
  When I view it
  Then no control to change how it combines its children or what score it requires is offered
  And I can still read the combining choice and the score it currently has

Description

#672 renders the bottom-tier group cards and rule boxes and builds the two controls this ticket makes editable: the combining-logic control on a bottom-tier group and the score field on a rule box. Both render as read-only text there, because each takes an optional change handler and #672 passes none. This ticket passes one on a persisted row, wired to the backend.

Technical Details

This section is background and a suggested approach, not the ticket's source of truth. The User Story and Acceptance Criteria define what must be true when the work is done; what follows exists to save the implementer some thinking, not to bind them.

In short

This ticket adds no new rendering. #672's LogicOperatorSelect and ScoreThresholdField already render an editable control when given a change handler and read-only text when not, and #672 passes none. This ticket passes one on a persisted bottom-tier group and a persisted rule box, wired to a mutation, when the requesting user is permitted to make the change. Nothing about the components themselves changes, and there is no second "is it editable" flag to keep in step with the handler.

Two different endpoints back the two controls. The any/all control on a persisted bottom-tier group calls #760, which changes how a Competency Criteria Group combines the criteria and groups beneath it, addressed by the bottom-tier group's own id. The score field on a persisted rule box calls #759, which changes the rule that a set of Competency Criteria are evaluated by in one request, addressed by every criterion id currently inside that rule box. A rule box is a display grouping of criteria that share one rule, so changing "the box's score" really means re-issuing #759's batch update against every criterion in it, so that they continue to share one rule, and therefore remain one rule box, afterward.

A rule box's identity is still its rule, which constrains what a score change can validly produce. If the new score matches another rule box already in the same group, the criteria being updated would, after the call succeeds, share a rule with that other box and merge into it on the next refetch, leaving the author looking at one box where there had been two, with no explanation. This ticket refuses that value in the field before the call is made. #672 owns both halves of the check: the helper that computes a rule's identity key and the helper that lists a group's existing rule boxes. Write the check directly against those two rather than extracting a shared validator; #671 writes the same one-line check for a not-yet-saved rule box, and neither ticket needs the other to exist.

Setting an override back to the applicable default is not a special case this ticket needs to detect. Per ADR 0002's own write-event rules, the backend itself reassigns a criterion from a matching override back to a profile reference whenever the value matches, so this ticket only needs to send whatever value the author entered. The "following the default again" outcome is the backend's doing, and #672's effective-rule display already renders that state correctly whether the value arrived as a profile reference or as a matching override.

Rejection rolls the control back to what it displayed before the change, mirroring #672's own rejection handling for the create call: the control is optimistic-free, meaning it does not adopt the attempted value until the mutation succeeds, so "rolling back" is simply not having changed the displayed value in the first place, and only the error needs surfacing.

Implementation specifics

Files to create and modify New files

File Purpose
src/taxonomy/competency-management/criteria-groups/CriteriaGroupBox.edit.test.tsx Editing a persisted bottom-tier group's operator, rejection rollback, and the permission-gated read-only rendering.
src/taxonomy/competency-management/criteria-groups/RuleBox.edit.test.tsx Editing a persisted rule box's score, the duplicate-score refusal, rejection rollback, and the permission-gated read-only rendering.

Modified files

File Nature of modification
src/taxonomy/competency-management/data/api.ts Add updateCompetencyCriteriaGroupOperator and updateCompetencyCriteriaRule.
src/taxonomy/competency-management/data/apiHooks.ts Add useUpdateCompetencyCriteriaGroupOperator and useUpdateCompetencyCriteriaRule, both invalidating the groups query on success.
src/taxonomy/competency-management/criteria-groups/CriteriaGroupBox.tsx Pass an onChange to LogicOperatorSelect on a persisted bottom-tier group, wired to the group-operator mutation and gated by the permission predicate.
src/taxonomy/competency-management/criteria-groups/RuleBox.tsx Pass an onChange and a getInlineValidationMessage to ScoreThresholdField on a persisted rule box, wired to the rule mutation and gated by the permission predicate.
src/taxonomy/competency-management/messages.ts Add the duplicate-score message if it is not already present.

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions