From dbe17d1ee9c22d11ec916e898cb5ca4a01409896 Mon Sep 17 00:00:00 2001 From: Tamara <60857422+Myranae@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:16:50 -0500 Subject: [PATCH] Refine NumericInput's Rubric type (#1761) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary: As part of the Server Side Scoring project, this refactors NumericInput's Rubric type to contain only what is needed for scoring. It also updates associated tests. Issue: LEMS-2470 ## Test plan: - Confirm all tests pass - Confirm NumericInput still works as expected in Storybook Author: Myranae Reviewers: handeyeco Required Reviewers: Approved By: handeyeco Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/1761 --- .changeset/wild-comics-chew.md | 5 ++++ packages/perseus/src/validation.types.ts | 9 +++++-- .../numeric-input-validator.test.ts | 27 ------------------- .../numeric-input/numeric-input.test.ts | 3 --- 4 files changed, 12 insertions(+), 32 deletions(-) create mode 100644 .changeset/wild-comics-chew.md diff --git a/.changeset/wild-comics-chew.md b/.changeset/wild-comics-chew.md new file mode 100644 index 0000000000..a300256b12 --- /dev/null +++ b/.changeset/wild-comics-chew.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Refine NumericInput's Rubric type diff --git a/packages/perseus/src/validation.types.ts b/packages/perseus/src/validation.types.ts index d8f6c4c068..da31a9e99a 100644 --- a/packages/perseus/src/validation.types.ts +++ b/packages/perseus/src/validation.types.ts @@ -9,7 +9,7 @@ import type { PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, - PerseusNumericInputWidgetOptions, + PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioWidgetOptions, @@ -137,7 +137,12 @@ export type PerseusNumberLineUserInput = { divisionRange: ReadonlyArray; }; -export type PerseusNumericInputRubric = PerseusNumericInputWidgetOptions; +export type PerseusNumericInputRubric = { + // A list of all the possible correct and incorrect answers + answers: ReadonlyArray; + // A coefficient style number allows the student to use - for -1 and an empty string to mean 1. + coefficient: boolean; +}; export type PerseusNumericInputUserInput = { currentValue: string; diff --git a/packages/perseus/src/widgets/numeric-input/numeric-input-validator.test.ts b/packages/perseus/src/widgets/numeric-input/numeric-input-validator.test.ts index cd3f905bf9..7fcb5b9dcf 100644 --- a/packages/perseus/src/widgets/numeric-input/numeric-input-validator.test.ts +++ b/packages/perseus/src/widgets/numeric-input/numeric-input-validator.test.ts @@ -27,9 +27,6 @@ describe("static function validate", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; @@ -54,9 +51,6 @@ describe("static function validate", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; @@ -89,9 +83,6 @@ describe("static function validate", () => { value: 45.289, }, ], - labelText: "", - size: "normal", - static: false, coefficient: false, }; @@ -127,9 +118,6 @@ describe("static function validate", () => { answerForms: ["pi"], }, ], - labelText: "", - size: "normal", - static: false, coefficient: false, }; @@ -154,9 +142,6 @@ describe("static function validate", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; @@ -181,9 +166,6 @@ describe("static function validate", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; @@ -208,9 +190,6 @@ describe("static function validate", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; @@ -246,9 +225,6 @@ describe("static function validate", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; @@ -292,9 +268,6 @@ describe("static function validate", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; diff --git a/packages/perseus/src/widgets/numeric-input/numeric-input.test.ts b/packages/perseus/src/widgets/numeric-input/numeric-input.test.ts index 88bda6c402..7e61108d5b 100644 --- a/packages/perseus/src/widgets/numeric-input/numeric-input.test.ts +++ b/packages/perseus/src/widgets/numeric-input/numeric-input.test.ts @@ -143,9 +143,6 @@ describe("static function getOneCorrectAnswerFromRubric", () => { message: "", }, ], - labelText: "", - size: "normal", - static: false, coefficient: true, }; const singleAnswer =