Move the variation to a field in the exercise#1236
Merged
rolandgeider merged 2 commits intomasterfrom Apr 14, 2026
Merged
Conversation
Also, refactor the variation component and extract it so that the variations for existing exercises can be edited as well.
Collaborator
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the frontend to align with backend changes by replacing the old numeric variations/variationId linkage with a variation_group UUID field on exercises, and refactors the variation selection UI so variations can be edited for existing exercises.
Changes:
- Replaced
variationId/variationswithvariationGroup/variation_groupacross models, state, services, and test fixtures. - Extracted the variation picker into a reusable
VariationSelectcomponent and reused it in the exercise creation flow. - Added an edit UI (
EditExerciseVariation) to modify an existing exercise’s variation group (including creating a new group and assigning two exercises to it).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/responseApi.ts | Updates mocked API response/expected model to use variation_group/variationGroup. |
| src/tests/exerciseTestdata.ts | Migrates exercise test fixtures from variationId to variationGroup. |
| src/tests/exercises/searchResponse.ts | Updates search response fixtures to use variationGroup. |
| src/state/exerciseSubmissionState.tsx | Renames submission state field to variationGroup (string UUID). |
| src/state/exerciseSubmissionReducer.ts | Updates variation action to accept string UUID and stores into variationGroup. |
| src/services/variation.ts | Removes now-obsolete variation creation service. |
| src/services/variation.test.ts | Removes tests for the deleted variation service. |
| src/services/exercise.ts | Updates variation query/filter and submission payload to use variation_group. |
| src/services/exercise.test.ts | Adjusts mocked PATCH response field to variation_group. |
| src/components/Exercises/queries/variations.ts | Removes obsolete mutation hook for creating variations. |
| src/components/Exercises/models/exercise.ts | Renames model field to variationGroup and maps from variation_group. |
| src/components/Exercises/forms/VariationSelect.tsx | New extracted UI component to search/group/select variations. |
| src/components/Exercises/forms/Variation.tsx | New edit component to update an exercise’s variation_group. |
| src/components/Exercises/Detail/ExerciseDetails.tsx | Updates variations query to key off variationGroup. |
| src/components/Exercises/Detail/ExerciseDetailEdit.tsx | Adds a new “Variations” section for editing variation groups. |
| src/components/Exercises/Detail/ExerciseDetailEdit.test.tsx | Import ordering adjustment related to the edit view test setup. |
| src/components/Exercises/Add/Step6Overview.tsx | Submits variationGroup and updates display text to reference it. |
| src/components/Exercises/Add/Step6Overview.test.tsx | Updates step 6 test state to use variationGroup. |
| src/components/Exercises/Add/Step2Variations.tsx | Refactors step 2 to use the new VariationSelect component. |
Comments suppressed due to low confidence (1)
src/state/exerciseSubmissionReducer.ts:51
setVariationIdnow takes a UUID string (variation group) but the action creator name andSET_VARIATION_IDconstant still imply a numeric variation ID. Renaming these tosetVariationGroup/SET_VARIATION_GROUP(and updating call sites) would reduce confusion and make the state shape self-describing.
export const setVariationId = (id: string | null): ExerciseSubmissionAction => {
return { type: SetExerciseSubmissionState.SET_VARIATION_ID, payload: id };
};
export const setNewBaseVariationId = (id: number | null): ExerciseSubmissionAction => {
return { type: SetExerciseSubmissionState.SET_NEW_VARIATION_BASE_ID, payload: id };
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Implement changes from the backend and move the variation to a field in the exercise. Also, refactor the variation component and extract it so that the variations for existing exercises can be edited as well.