Skip to content

Commit

Permalink
Refine NumericInput's Rubric type (#1761)
Browse files Browse the repository at this point in the history
## 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: #1761
  • Loading branch information
Myranae authored Oct 28, 2024
1 parent 39e1292 commit dbe17d1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-comics-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Refine NumericInput's Rubric type
9 changes: 7 additions & 2 deletions packages/perseus/src/validation.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
PerseusMatcherWidgetOptions,
PerseusMatrixWidgetOptions,
PerseusNumberLineWidgetOptions,
PerseusNumericInputWidgetOptions,
PerseusNumericInputAnswer,
PerseusOrdererWidgetOptions,
PerseusPlotterWidgetOptions,
PerseusRadioWidgetOptions,
Expand Down Expand Up @@ -137,7 +137,12 @@ export type PerseusNumberLineUserInput = {
divisionRange: ReadonlyArray<number>;
};

export type PerseusNumericInputRubric = PerseusNumericInputWidgetOptions;
export type PerseusNumericInputRubric = {
// A list of all the possible correct and incorrect answers
answers: ReadonlyArray<PerseusNumericInputAnswer>;
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ describe("static function validate", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};

Expand All @@ -54,9 +51,6 @@ describe("static function validate", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};

Expand Down Expand Up @@ -89,9 +83,6 @@ describe("static function validate", () => {
value: 45.289,
},
],
labelText: "",
size: "normal",
static: false,
coefficient: false,
};

Expand Down Expand Up @@ -127,9 +118,6 @@ describe("static function validate", () => {
answerForms: ["pi"],
},
],
labelText: "",
size: "normal",
static: false,
coefficient: false,
};

Expand All @@ -154,9 +142,6 @@ describe("static function validate", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};

Expand All @@ -181,9 +166,6 @@ describe("static function validate", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};

Expand All @@ -208,9 +190,6 @@ describe("static function validate", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};

Expand Down Expand Up @@ -246,9 +225,6 @@ describe("static function validate", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};

Expand Down Expand Up @@ -292,9 +268,6 @@ describe("static function validate", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ describe("static function getOneCorrectAnswerFromRubric", () => {
message: "",
},
],
labelText: "",
size: "normal",
static: false,
coefficient: true,
};
const singleAnswer =
Expand Down

0 comments on commit dbe17d1

Please sign in to comment.