-
Notifications
You must be signed in to change notification settings - Fork 350
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
Create helper to build public widget options for expression #2139
base: main
Are you sure you want to change the base?
Conversation
…lic widget options
…t option functions
… widget export function to filter out rubric data from widget options for the
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (c412751) and published it to npm. You Example: yarn add @khanacademy/perseus@PR2139 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR2139 |
Size Change: +170 B (+0.01%) Total Size: 1.47 MB
ℹ️ View Unchanged
|
/** | ||
* For details on the individual options, see the | ||
* PerseusOrdererWidgetOptions type | ||
*/ | ||
type ExpressionPublicWidgetOptions = { | ||
buttonSets: LegacyButtonSets; | ||
functions: ReadonlyArray<string>; | ||
times: boolean; | ||
visibleLabel?: string; | ||
ariaLabel?: string; | ||
buttonsVisible?: "always" | "never" | "focused"; | ||
}; |
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.
Left out answerFrom from the below widget options:
// The expression forms the answer may come in
answerForms: ReadonlyArray<PerseusExpressionAnswerForm>;
buttonSets: LegacyButtonSets;
// Variables that can be used as functions. Default: ["f", "g", "h"]
functions: ReadonlyArray<string>;
// Use x for rendering multiplication instead of a center dot.
times: boolean;
// visible label associated with the MathQuill field
visibleLabel?: string;
// aria label for screen readers attached to MathQuill field
ariaLabel?: string;
// Controls when buttons for special characters are visible when using a
// desktop browser. Defaults to "focused".
// NOTE: This isn't listed in perseus-format.js or perseus_data.go, but
// appears in item data in the datastore.
buttonsVisible?: "always" | "never" | "focused";
And here is PerseusExpressionAnswerForm. I don't think I need to pick out value from this, but if someone could confirm for me, that would be great.
value: string
form: boolean
simplify: boolean
considered: typeof PerseusExpressionAnswerFormConsidered[number]
key?: string
const options: PerseusExpressionWidgetOptions = | ||
expressionItem2.question.widgets["expression 1"].options; |
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.
It looks like visibleLabel
and ariaLabel
are not included in the test data? I'd prefer to define the input inline rather than relying on shared data from expression.testdata
.
Sharing data between tests makes them harder to understand (you have to look at multiple files to understand the test setup) and prone to false passes if the test data changes later.
const options: PerseusExpressionWidgetOptions = | |
expressionItem2.question.widgets["expression 1"].options; | |
const options: PerseusExpressionWidgetOptions = { | |
buttonSets: ["basic"], | |
functions: ["f", "g", "h"], | |
times: false, | |
visibleLabel: "the visible label", | |
ariaLabel: "the aria label", | |
buttonsVisible: "always", | |
}; |
Summary:
Adds a function that takes expression's full widget options and filters out answer data. It also adds this function to the widget's widget export and adds a test confirming the function does what is expected.
Issue: LEMS-2758
Test plan: