Skip to content

f-1221 Add JSON import functionality for exercise creation and validation#1249

Open
morozov-av wants to merge 3 commits into
RunestoneInteractive:mainfrom
morozov-av:f-1221
Open

f-1221 Add JSON import functionality for exercise creation and validation#1249
morozov-av wants to merge 3 commits into
RunestoneInteractive:mainfrom
morozov-av:f-1221

Conversation

@morozov-av

@morozov-av morozov-av commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-06-23.at.14.44.49.mov

@morozov-av morozov-av requested a review from bnmnetp as a code owner June 23, 2026 11:50
Copilot AI review requested due to automatic review settings June 23, 2026 11:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 parseQuestionJsonInput and validateQuestionJsonForType utilities for parsing and validating pasted question JSON.
  • Adds an ImportQuestionJsonModal and wires it into CreateExercise for 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>
Copilot AI review requested due to automatic review settings June 23, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

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 = ({
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants