f-1221 Add JSON import functionality for exercise creation and validation#1249
Open
morozov-av wants to merge 3 commits into
Open
f-1221 Add JSON import functionality for exercise creation and validation#1249morozov-av wants to merge 3 commits into
morozov-av wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a “paste/import question JSON” workflow to the Assignment Builder’s exercise creation/editing UI, including basic JSON parsing + per-exercise-type structural validation and accompanying unit tests.
Changes:
- Introduces
parseQuestionJsonInputandvalidateQuestionJsonForTypeutilities for parsing and validating pasted question JSON. - Adds an
ImportQuestionJsonModaland wires it intoCreateExercisefor create-mode import and edit-mode view/replace. - Adds Vitest coverage for the new utils, modal behavior, and CreateExercise integration points.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
bases/rsptx/assignment_server_api/assignment_builder/src/utils/importQuestionJson.ts |
New parsing + type-based required-field validation for imported question JSON. |
bases/rsptx/assignment_server_api/assignment_builder/src/utils/importQuestionJson.spec.ts |
Unit tests covering parse failures/success and per-type validation behavior. |
bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/components/CreateExercise/CreateExercise.tsx |
Adds import/view-replace JSON entry points and applies imported JSON into the exercise factory initial data. |
bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/components/CreateExercise/CreateExercise.spec.tsx |
Updates tests for new UI buttons and import application behavior. |
bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/components/CreateExercise/components/ImportQuestionJsonModal.tsx |
New modal UI for selecting a type (when unlocked), pasting JSON, showing errors, and applying validated data. |
bases/rsptx/assignment_server_api/assignment_builder/src/components/routes/AssignmentBuilder/components/exercises/components/CreateExercise/components/ImportQuestionJsonModal.spec.tsx |
Modal tests for required type selection, parse errors, validation errors, and apply behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { field: "questionText", type: "string" }, | ||
| { field: "blanks", type: "array" } | ||
| ], | ||
| clickablearea: [{ field: "questionText", type: "string" }], |
Comment on lines
+65
to
+74
| dragndrop: [ | ||
| { field: "left", type: "array" }, | ||
| { field: "right", type: "array" }, | ||
| { field: "correctAnswers", type: "array" } | ||
| ], | ||
| matching: [ | ||
| { field: "left", type: "array" }, | ||
| { field: "right", type: "array" }, | ||
| { field: "correctAnswers", type: "array" } | ||
| ], |
| { field: "questionText", type: "string" }, | ||
| { field: "blanks", type: "array" } | ||
| ], | ||
| clickablearea: [{ field: "questionText", type: "string" }], |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+65
to
+74
| dragndrop: [ | ||
| { field: "left", type: "array" }, | ||
| { field: "right", type: "array" }, | ||
| { field: "correctAnswers", type: "array" } | ||
| ], | ||
| matching: [ | ||
| { field: "left", type: "array" }, | ||
| { field: "right", type: "array" }, | ||
| { field: "correctAnswers", type: "array" } | ||
| ], |
Comment on lines
+234
to
+237
| expect(errors).toHaveLength(3); | ||
| expect(errors.find((message) => message.includes("left"))).toMatch(/must be an array/i); | ||
| expect(errors.some((message) => message.includes("right"))).toBe(true); | ||
| expect(errors.some((message) => message.includes("correctAnswers"))).toBe(true); |
Comment on lines
65
to
81
| @@ -70,31 +80,103 @@ export const CreateExercise = ({ | |||
| } | |||
| }; | |||
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.
Screen.Recording.2026-06-23.at.14.44.49.mov