Skip to content

Add a v1 version of input-number options; migrate from v0#3656

Draft
benchristel wants to merge 3 commits into
mainfrom
benc/input-number-v2-take-2
Draft

Add a v1 version of input-number options; migrate from v0#3656
benchristel wants to merge 3 commits into
mainfrom
benc/input-number-v2-take-2

Conversation

@benchristel
Copy link
Copy Markdown
Member

Summary:

We are in the process of replacing input-number with numeric-input. See
LEMS-4081 for context.

This PR changes the input-number options schema to match the options of
numeric-input. The idea is that the migrated options can be passed directly
to a NumericInput component, paving the way for us to replace InputNumber
with NumericInput simply by registering NumericInput under the
input-number widget name.

Issue: LEMS-4111

Test plan:

CI checks should pass.

@github-actions
Copy link
Copy Markdown
Contributor

Size Change: +1.26 kB (+0.25%)

Total Size: 506 kB

📦 View Changed
Filename Size Change
packages/perseus-core/dist/es/index.item-splitting.js 12.6 kB +557 B (+4.61%) 🔍
packages/perseus-core/dist/es/index.js 26.4 kB +245 B (+0.94%)
packages/perseus-editor/dist/es/index.js 104 kB +53 B (+0.05%)
packages/perseus-score/dist/es/index.js 10.2 kB +198 B (+1.98%)
packages/perseus/dist/es/index.js 198 kB +212 B (+0.11%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.32 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-linter/dist/es/index.js 9.41 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 8.5 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

Comment on lines 386 to +407
type: "input-number",
version: {major: 0, minor: 0},
version: {major: 1, minor: 0},
options: {
simplify: "required",
answers: [
{
value: 42,
simplify: "required",
status: "correct",
strict: true,
answerForms: [
"integer",
"decimal",
"proper",
"improper",
"mixed",
],
message: "",
maxError: 0,
},
],
size: "normal",
value: "",
coefficient: false,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We could use the generator functions here. It might be good to update all these tests to use them.

*/
strict: boolean;
maxError?: number | undefined;
/** Unsimplified answers are Ungraded, Accepted, or Wrong. */
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This comment could be better.

Comment on lines +2262 to +2271
/**
* A list of correct and incorrect answers. Each answer can have a
* message explaining why it is correct/incorrect. There may be
* multiple correct answers if multiple formats are accepted. For
* example, some questions might accept either a fraction or a
* decimal as correct.
*
* The first answer that matches (correct or incorrect) is the scoring
* result (so order of answers is very important).
*/
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This comment isn't really accurate since all input-number widgets will have exactly one answer. Maybe change this type to [PerseusInputNumberAnswer]. Then we could get rid of some optional chaining, and we wouldn't even need assertions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant