Skip to content
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-2868] Answerless ServerItemRendererWithDebugUI #2289

Merged
merged 6 commits into from
Mar 21, 2025

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Mar 7, 2025

Summary:

I wanted to be able to render/use widgets in Storybook, but have them rendered using answerless data rather than the full data.

Issue: LEMS-2868

@handeyeco handeyeco self-assigned this Mar 7, 2025
Copy link
Contributor

github-actions bot commented Mar 7, 2025

Size Change: 0 B

Total Size: 736 kB

ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39.7 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 11.1 kB
packages/math-input/dist/es/index.js 77.5 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 32.2 kB
packages/perseus-editor/dist/es/index.js 136 kB
packages/perseus-linter/dist/es/index.js 22.8 kB
packages/perseus-score/dist/es/index.js 20.7 kB
packages/perseus/dist/es/index.js 370 kB
packages/perseus/dist/es/strings.js 6.74 kB
packages/pure-markdown/dist/es/index.js 4.14 kB
packages/simple-markdown/dist/es/index.js 13.1 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Mar 7, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (25d3d1f) and published it to npm. You
can install it using the tag PR2289.

Example:

pnpm add @khanacademy/perseus@PR2289

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2289

@handeyeco handeyeco changed the title make ServerItemRendererWithDebugUI optionally render answerless data [LEMS-2868] Answerless ServerItemRendererWithDebugUI Mar 7, 2025
…ererWithDebugUI to optionally use answerless data for rendering
@handeyeco handeyeco marked this pull request as ready for review March 7, 2025 18:10
@handeyeco handeyeco requested review from a team March 7, 2025 18:10
@handeyeco handeyeco added the 🐍 project: sss Server-Side Scoring ('24-'25) label Mar 11, 2025
} from "@khanacademy/perseus-core";

const createItemJson = (
widgetOptions: PerseusExpressionWidgetOptions,
version: Version,
Copy link
Contributor

@Myranae Myranae Mar 17, 2025

Choose a reason for hiding this comment

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

It seems like changing version to widgetVersion, adding extra keys, and modifying item 3 below is all that was done here. Did you add an item without answers somewhere? I think the big red and green chunks were just moved code, but I might have missed something.

Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

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

This looks reasonable. One bit of feedback is that I'd suggest you revert the code moves unless there's a good reason as it'll make the PR clearer what's actually being changed.

@@ -122,6 +125,16 @@ export const ExpressionItem3 = (args: StoryArgs): React.ReactElement => {
);
};

export const AnswerlessExpression = (args: StoryArgs): React.ReactElement => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this used? I don't see it referenced in this PR at all.

Copy link
Contributor Author

@handeyeco handeyeco Mar 21, 2025

Choose a reason for hiding this comment

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

This is how Storybook works, by exporting the function in a .stories.tsx file it shows up in SB.

Screenshot 2025-03-21 at 9 23 17 AM

Copy link
Collaborator

Choose a reason for hiding this comment

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

🤦‍♂️ I didn't take note this was in a .stories.tsx file!

} from "@khanacademy/perseus-core";

const createItemJson = (
widgetOptions: PerseusExpressionWidgetOptions,
version: Version,
widgetVersion: Version = expressionLogic.version as Version,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use satisfies instead of as here? Also, why do we need the cast at all? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expressionLogic is of type WidgetLogic and not all widgets have versions so version?: Version

You're right thought, it was overkill. It works with widgetVersion = expressionLogic.version

@Myranae
Copy link
Contributor

Myranae commented Mar 19, 2025

I'm not sure this is working as we think it is. I could be missing something, but should the Perseus JSON section reflect the result of splitPerseusItem? In other words, should the answerful data be missing from the Perseus JSON area? In my testing, so far that's not the case. I assumed that was because we only need the render data to be missing the answers, but how do we confirm what data it's rendering with? I'm still testing since I'm working on this too, but curious if you have ideas or I missed something in regards to this.

UPDATE:
Okay, I think if the results of splitPerseusItem and this.props.widgets in the render method of renderer are the same, then we can confirm what is being rendered is what we want. Probably didn't need to dig in this far, but 🤷‍♀️ . Hopefully that's enough confirmation.

@handeyeco handeyeco merged commit 87420d7 into main Mar 21, 2025
8 checks passed
@handeyeco handeyeco deleted the LEMS-2868/answerless-stories branch March 21, 2025 14:47
handeyeco pushed a commit that referenced this pull request Mar 25, 2025
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/[email protected]

### Patch Changes

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- [#2289](#2289)
[`87420d7d3`](87420d7)
Thanks [@handeyeco](https://github.com/handeyeco)! - Update
ServerItemRendererWithDebugUI to optionally use answerless data for
rendering


- [#2313](#2313)
[`3b0b1c700`](3b0b1c7)
Thanks [@nishasy](https://github.com/nishasy)! - [LX] Stop locked
functions from memory leaking

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`c170c1d3c`](c170c1d),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- [#2308](#2308)
[`1b5f51415`](1b5f514)
Thanks [@benchristel](https://github.com/benchristel)! - Fix a bug in
numeric input scoring where `simplify` value of `false` led to incorrect
scoring logic being applied


- [#2319](#2319)
[`4c0b317c3`](4c0b317)
Thanks [@benchristel](https://github.com/benchristel)! - Internal:
unskip regression tests for Perseus JSON parser and update snapshots


- [#2272](#2272)
[`335940746`](3359407)
Thanks [@handeyeco](https://github.com/handeyeco)! - Add comments to
external-facing functions

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`c170c1d3c`](c170c1d),
[`87420d7d3`](87420d7),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407),
[`3b0b1c700`](3b0b1c7)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- [#2278](#2278)
[`c170c1d3c`](c170c1d)
Thanks [@handeyeco](https://github.com/handeyeco)! - Remove jQuery as a
dependency of perseus-score


- [#2272](#2272)
[`335940746`](3359407)
Thanks [@handeyeco](https://github.com/handeyeco)! - Add comments to
external-facing functions

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`1b5f51415`](1b5f514),
[`4c0b317c3`](4c0b317),
[`335940746`](3359407)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐍 project: sss Server-Side Scoring ('24-'25)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants