-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LEMS-2852] Answerless Expression #2226
Conversation
Size Change: +205 B (+0.02%) Total Size: 875 kB
ℹ️ View Unchanged
|
"extraKeys": [ | ||
"PI", | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of having deriveExtraKeys
default to ["PI"]
it should just be empty and the props can default to ["PI"]
when rendering...
expect(score).toHaveBeenAnsweredCorrectly(); | ||
}); | ||
|
||
it("is interactive with answerless widget options", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the important one. Without answer data we:
- Render
- Answer
- Send the input off for scoring
* to be included as keys on the keypad. These are scraped from the answer | ||
* forms. | ||
*/ | ||
export const keypadConfigurationForProps = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this logic was for deriving extra keys, so I just transformed this into deriveExtraKeys
.
buttonsVisible: v0options.buttonsVisible, | ||
visibleLabel: v0options.visibleLabel, | ||
ariaLabel: v0options.ariaLabel, | ||
extraKeys: v0options.extraKeys, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
extraKeys: v1options.extraKeys || deriveExtraKeys(v1options), | ||
}; | ||
}, | ||
"1": (v0options: any): PerseusExpressionWidgetOptions => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably shouldn't return PerseusExpressionWidgetOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I believe long-term we won't be keeping this widget upgrade system (in favour of the new parsing system). I had a comment in the test file for this file that we could add a v1 widget options type. That's some extra work but keeps it explicit what these functions are accepting/returning. 🤷♂️
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (21a7155) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR2226 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR2226 |
40246a0
to
8e08204
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of thoughts and nits... but I think this makes sense as it is!
// What extra keys need to be displayed on the keypad so that the | ||
// question can be answerable without a keyboard (ie mobile) | ||
// TODO: this is really ReadonlyArray<Key> | ||
extraKeys?: ReadonlyArray<string>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be updated now that the types have been moved to perseus-core
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make the change, but I was still a little unsure because this would be the only import into data-schema
I think.
packages/perseus-core/src/widgets/expression/derive-extra-keys.test.ts
Outdated
Show resolved
Hide resolved
packages/perseus-core/src/widgets/expression/derive-extra-keys.test.ts
Outdated
Show resolved
Hide resolved
packages/perseus-core/src/widgets/expression/expression-upgrade.test.ts
Outdated
Show resolved
Hide resolved
packages/perseus-editor/src/widgets/__tests__/expression-editor.test.tsx
Show resolved
Hide resolved
}); | ||
|
||
// Assert | ||
expect(result.keypadConfiguration.extraKeys).toEqual(["x"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing this is existing logic, but I'm surprised it doesn't merge them.
…ion: Expression can render and is interactive with answerless data
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/math-input@23.0.0 ### Major Changes - [#2226](#2226) [`909148cdc`](909148c) Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless Expression: Expression can render and is interactive with answerless data ### Patch Changes - Updated dependencies \[[`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus-core@5.0.0 - @khanacademy/keypad-context@1.1.1 ## @khanacademy/perseus@56.0.0 ### Major Changes - [#2233](#2233) [`a0aee41b6`](a0aee41) Thanks [@handeyeco](https://github.com/handeyeco)! - RadioWidget v2 in support of answerless Radio ### Patch Changes - [#2279](#2279) [`e02cc4109`](e02cc41) Thanks [@nishasy](https://github.com/nishasy)! - [SR] Tweak strings for Segment and Angle graphs - [#2270](#2270) [`941343ee3`](941343e) Thanks [@catandthemachines](https://github.com/catandthemachines)! - Fixing side snapping within polygons to be keyboard accessible. - [#2226](#2226) [`909148cdc`](909148c) Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless Expression: Expression can render and is interactive with answerless data - Updated dependencies \[[`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus-core@5.0.0 - @khanacademy/math-input@23.0.0 - @khanacademy/keypad-context@1.1.1 - @khanacademy/kmath@0.4.1 - @khanacademy/perseus-linter@1.3.1 - @khanacademy/perseus-score@2.3.1 ## @khanacademy/perseus-core@5.0.0 ### Major Changes - [#2233](#2233) [`a0aee41b6`](a0aee41) Thanks [@handeyeco](https://github.com/handeyeco)! - RadioWidget v2 in support of answerless Radio - [#2226](#2226) [`909148cdc`](909148c) Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless Expression: Expression can render and is interactive with answerless data ## @khanacademy/perseus-editor@17.9.0 ### Minor Changes - [#2226](#2226) [`909148cdc`](909148c) Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless Expression: Expression can render and is interactive with answerless data ### Patch Changes - [#2233](#2233) [`a0aee41b6`](a0aee41) Thanks [@handeyeco](https://github.com/handeyeco)! - RadioWidget v2 in support of answerless Radio - Updated dependencies \[[`e02cc4109`](e02cc41), [`941343ee3`](941343e), [`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus@56.0.0 - @khanacademy/perseus-core@5.0.0 - @khanacademy/math-input@23.0.0 - @khanacademy/keypad-context@1.1.1 - @khanacademy/kmath@0.4.1 - @khanacademy/perseus-linter@1.3.1 - @khanacademy/perseus-score@2.3.1 ## @khanacademy/keypad-context@1.1.1 ### Patch Changes - Updated dependencies \[[`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus-core@5.0.0 ## @khanacademy/kmath@0.4.1 ### Patch Changes - Updated dependencies \[[`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus-core@5.0.0 ## @khanacademy/perseus-linter@1.3.1 ### Patch Changes - Updated dependencies \[[`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus-core@5.0.0 ## @khanacademy/perseus-score@2.3.1 ### Patch Changes - Updated dependencies \[[`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus-core@5.0.0 - @khanacademy/kmath@0.4.1 ## @khanacademy/perseus-dev-ui@5.3.1 ### Patch Changes - Updated dependencies \[[`a0aee41b6`](a0aee41), [`909148cdc`](909148c)]: - @khanacademy/perseus-core@5.0.0 - @khanacademy/math-input@23.0.0 - @khanacademy/kmath@0.4.1 - @khanacademy/perseus-linter@1.3.1 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Summary:
So the main thing with the Expression widget is that it was using answer data to determine which
extraKeys
to show in theMathInput
keypad. For instance if a possible answer was42i
, it would showi
in theExtra
tab on the keypad.This PR sets us up for removing answers by adding
extraKeys
to the data schema so it can be determined at publish time rather than read time. We simulate this by upgrading the widget to provideextraKeys
when not present on the data.Issue: LEMS-2852
Test plan: