-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create helper to build public widget options for orderer (#2137)
## Summary: Adds a function that takes orderer'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 as expected. Issue: LEMS-2763 ## Test plan: - Confirm all checks pass - Confirm orderer still works as expected Author: Myranae Reviewers: Myranae, benchristel, jeremywiebe, handeyeco Required Reviewers: Approved By: benchristel, jeremywiebe Checks: ✅ Publish npm snapshot (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), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2137
- Loading branch information
Showing
7 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus-core": patch | ||
--- | ||
|
||
Move util files out of widget folder in perseus package to utils folder in perseus-core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
--- | ||
|
||
Implement a widget export function to filter out rubric data from widget options for the orderer widget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import getOrdererPublicWidgetOptions from "./orderer-util"; | ||
|
||
import type {PerseusOrdererWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
describe("getOrdererPublicWidgetOptions", () => { | ||
it("should return the correct public options without any answer data", () => { | ||
// Arrange | ||
const options: PerseusOrdererWidgetOptions = { | ||
otherOptions: [], | ||
layout: "horizontal", | ||
options: [ | ||
{content: "$10.9$", images: {}, widgets: {}}, | ||
{content: "$11$", images: {}, widgets: {}}, | ||
{content: "$\\sqrt{120}$", images: {}, widgets: {}}, | ||
], | ||
correctOptions: [ | ||
{content: "$10.9$", images: {}, widgets: {}}, | ||
{content: "$\\sqrt{120}$", images: {}, widgets: {}}, | ||
{content: "$11$", images: {}, widgets: {}}, | ||
], | ||
height: "normal", | ||
}; | ||
|
||
// Act | ||
const publicWidgetOptions = getOrdererPublicWidgetOptions(options); | ||
|
||
// Assert | ||
expect(publicWidgetOptions).toEqual({ | ||
layout: "horizontal", | ||
options: [ | ||
{content: "$10.9$", images: {}, widgets: {}}, | ||
{content: "$11$", images: {}, widgets: {}}, | ||
{content: "$\\sqrt{120}$", images: {}, widgets: {}}, | ||
], | ||
height: "normal", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type {PerseusOrdererWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
/** | ||
* For details on the individual options, see the | ||
* PerseusOrdererWidgetOptions type | ||
*/ | ||
type OrdererPublicWidgetOptions = { | ||
options: PerseusOrdererWidgetOptions["options"]; | ||
height: PerseusOrdererWidgetOptions["height"]; | ||
layout: PerseusOrdererWidgetOptions["layout"]; | ||
}; | ||
|
||
/** | ||
* Given a PerseusOrdererWidgetOptions object, return a new object with only | ||
* the public options that should be exposed to the client. | ||
*/ | ||
function getOrdererPublicWidgetOptions( | ||
options: PerseusOrdererWidgetOptions, | ||
): OrdererPublicWidgetOptions { | ||
return { | ||
options: options.options, | ||
height: options.height, | ||
layout: options.layout, | ||
}; | ||
} | ||
|
||
export default getOrdererPublicWidgetOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters