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

Expose a way to get user input from ServerItemRenderer #1910

Merged
merged 22 commits into from
Dec 3, 2024

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Nov 25, 2024

Summary:

This is a repeat of PR #1753 (which was reverted in #1905)

While this PR is essentially the same as the previous one, I added prop upgrading to the scoring logic and the empty widget logic (along with some tests).


I'm trying to tread lightly, maybe being overly cautious at the expense of keeping too much old code around. I tried to make everything we can get rid of after the move with @deprecated.

Basically this should expose everything we need to move the actual scoring process out of ServerItemRenderer and the React tree. We now have getUserInput on ServerItemRenderer and scorePerseusItem which is a non-React, pure function that returns a score.

Next step is to replace uses of scoreInput in Webapp with scorePerseusItem; then we can come back and delete a lot of this legacy code 🤞

Issue: LEMS-2665

Test plan:

After the swap in Webapp, we should be able to complete an exercise with scorePerseusItem and everything else will work the same.

@handeyeco handeyeco self-assigned this Nov 25, 2024
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Nov 25, 2024

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/honest-tables-impress.md, dev/flipbook.tsx, testing/renderer-with-debug-ui.tsx, packages/perseus/src/index.ts, packages/perseus/src/renderer-util.test.ts, packages/perseus/src/renderer-util.ts, packages/perseus/src/renderer.tsx, packages/perseus/src/server-item-renderer.tsx, packages/perseus/src/types.ts, packages/perseus/src/interactive2/objective_.ts, packages/perseus/src/components/__tests__/sorter.test.tsx, packages/perseus/src/widgets/categorizer/categorizer.test.ts, packages/perseus/src/widgets/definition/definition.test.ts, packages/perseus/src/widgets/expression/expression.test.tsx, packages/perseus/src/widgets/group/group.test.tsx, packages/perseus/src/widgets/group/group.tsx, packages/perseus/src/widgets/matcher/matcher.test.tsx, packages/perseus/src/widgets/matrix/matrix.test.ts, packages/perseus/src/widgets/deprecated-standin/__tests__/deprecated-standin.test.ts, packages/perseus/src/widgets/passage/__tests__/passage.test.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@khan-actions-bot khan-actions-bot requested a review from a team November 25, 2024 19:48
@handeyeco handeyeco changed the title add some comments after digging in more [WIP] Expose a way to get user input from ServerItemRenderer Nov 25, 2024
Copy link
Contributor

github-actions bot commented Nov 25, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1910

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

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

Copy link
Contributor

github-actions bot commented Nov 25, 2024

Size Change: +577 B (+0.04%)

Total Size: 1.29 MB

Filename Size Change
packages/perseus/dist/es/index.js 423 kB +577 B (+0.14%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/index.js 77.9 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus-editor/dist/es/index.js 697 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/strings.js 3.68 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@handeyeco handeyeco changed the title [WIP] Expose a way to get user input from ServerItemRenderer Expose a way to get user input from ServerItemRenderer Nov 26, 2024
@@ -39,7 +105,7 @@ describe("emptyWidgetsFunctional", () => {
it("properly identifies empty widgets", () => {
// Arrange
const widgets: PerseusWidgetsMap = {
"dropdown 1": testDropdownWidget,
"dropdown 1": getTestDropdownWidget(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did this need to become a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used a function for the new tests, so I changed the old one to be consistent with the new one.

IMO it's better to use a function because it ensures tests are as isolated as possible. Using the same object for multiple tests means one test can mutate the object that is then passed to another test.

@handeyeco handeyeco merged commit 0a44d46 into main Dec 3, 2024
10 checks passed
@handeyeco handeyeco deleted the sir-get-user-input branch December 3, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants