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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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: 875 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.7 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 31.9 kB
packages/perseus-editor/dist/es/index.js 276 kB
packages/perseus-linter/dist/es/index.js 22.8 kB
packages/perseus-score/dist/es/index.js 20.6 kB
packages/perseus/dist/es/index.js 369 kB
packages/perseus/dist/es/strings.js 6.73 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 (0f0848b) 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.

} 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? :)

@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.

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