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

Move NumericInput and InputNumber scoring logic to perseus-score #2105

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Jan 14, 2025

Summary:

I ended up moving them at the same time because of their shared dependency on TexWrangler.

  • Move InputNumber and NumericInput scoring logic to perseus-score
  • Move TexWranger since it was only used by their scoring logic
  • Update imports
  • Consolidate and rename InputNumber's answerTypes

Issue: LEMS-2737

Test plan:

Nothing should change, just moving code

@handeyeco handeyeco self-assigned this Jan 14, 2025
@handeyeco handeyeco changed the title move numeric-input and input-number Move NumericInput and InputNumber scoring logic to perseus-score Jan 14, 2025
@handeyeco handeyeco requested review from a team January 14, 2025 20:41
Copy link
Contributor

github-actions bot commented Jan 14, 2025

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR2105

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

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

Copy link
Contributor

github-actions bot commented Jan 14, 2025

Size Change: -97 B (-0.01%)

Total Size: 1.47 MB

Filename Size Change
packages/kmath/dist/es/index.js 86.8 kB +3.71 kB (+4.47%)
packages/math-input/dist/es/index.js 77.6 kB -355 B (-0.46%)
packages/perseus-core/dist/es/index.js 27.1 kB +4.03 kB (+17.47%) ⚠️
packages/perseus-editor/dist/es/index.js 689 kB -268 B (-0.04%)
packages/perseus-score/dist/es/index.js 113 kB +9.67 kB (+9.39%) 🔍
packages/perseus/dist/es/index.js 394 kB -16.9 kB (-4.12%)
packages/perseus/dist/es/strings.js 4.87 kB +39 B (+0.81%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@@ -271,11 +270,7 @@ describe("invalid", function () {
});

it("should handle invalid answers with no error callback", function () {
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 move this test to perseus-score?

@@ -140,7 +140,7 @@ function walkTex(
* expression will have its innermost fractions stubbed out with \fracs
* (as opposed to \dfracs). All other content will remain untouched.
*/
function modifyTex(tex: string): string {
export function modifyTex(tex: string): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the primary reason we need to export this is so that we can attach it to the numeric-input's WidgetExports.

I'd really love it if when we're all done that the individual widget scoring functions are unexported. That will help to keep the surface area of perseus-score tighter and avoid applications from binding to it and making it harder to change if we need to.

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'd really love it if when we're all done that the individual widget scoring functions are unexported.

I think that's totally doable. It would just mean that the widget type-to-scorer map would be internal to perseus-score and not something set by the consumer.

@@ -9,41 +10,6 @@ import type {PerseusInputNumberWidgetOptions} from "@khanacademy/perseus-core";

const {InfoTip} = components;

const answerTypes = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for catching this duplication and cleaning it up!

* move radio scorer/validator

* lint errorToString better

* comment my unique type

* respond to Jeremy's feedback

* Move scoring logic: CSProgram, Iframe, and Dropdown (#2111)

* cs-program

* move dropdown

* move iframe

* Move scoring logic: Table, NumberLine, Matcher (#2112)

* move table

* number-line

* move matcher

* Move scorers: Plotter and Sorter (#2113)

* plotter

* sorter

* Move scorer: Orderer (#2114)

* orderer

* Move scorerer: LabelImage (#2115)

* move label-image

* rename labelImageScoreMarker

* Move scoring logic: Matrix (#2116)

* move matrix

* Move scoring logic: Expression (#2118)

* move expression scorer

* respond to Ben's feedback

* merge Grapher move

* fix conflict again

* Move scorer: Grapher (#2119)

* move matrix

* move expression scorer

* move grapher scorer

* respond to Ben's feedback

* Move scorer: Interactive Graph (#2120)

* STOPSHIP some type errors still

* add back duplicate declarations

* add back Line duplicate

* all tests passing

* Revert changes to underscore's isEqual (#2125)

## Summary:
[Original comment](#2113 (comment))

I made a separate PR because I made this mistake in a couple of PRs so I thought I'd knock them out all at once.

Issue: LEMS-2737

## Test plan:

Author: handeyeco

Reviewers: jeremywiebe, benchristel

Required Reviewers:

Approved By: 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), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2125

* respond to Jeremy's feedback
@handeyeco handeyeco merged commit 167afa0 into LEMS-2737/categorizer Jan 17, 2025
3 of 6 checks passed
@handeyeco handeyeco deleted the LEMS-2737/numeric-input branch January 17, 2025 21:22
handeyeco added a commit that referenced this pull request Jan 17, 2025
* move categorizer scoring logic

* Move NumericInput and InputNumber scoring logic to `perseus-score` (#2105)

* move numeric-input and input-number

* respond to Jeremy's feedback

* Move Radio scorer/validator (#2106)

* move radio scorer/validator

* lint errorToString better

* comment my unique type

* respond to Jeremy's feedback

* Move scoring logic: CSProgram, Iframe, and Dropdown (#2111)

* cs-program

* move dropdown

* move iframe

* Move scoring logic: Table, NumberLine, Matcher (#2112)

* move table

* number-line

* move matcher

* Move scorers: Plotter and Sorter (#2113)

* plotter

* sorter

* Move scorer: Orderer (#2114)

* orderer

* Move scorerer: LabelImage (#2115)

* move label-image

* rename labelImageScoreMarker

* Move scoring logic: Matrix (#2116)

* move matrix

* Move scoring logic: Expression (#2118)

* move expression scorer

* respond to Ben's feedback

* merge Grapher move

* fix conflict again

* Move scorer: Grapher (#2119)

* move matrix

* move expression scorer

* move grapher scorer

* respond to Ben's feedback

* Move scorer: Interactive Graph (#2120)

* STOPSHIP some type errors still

* add back duplicate declarations

* add back Line duplicate

* all tests passing

* Revert changes to underscore's isEqual (#2125)

## Summary:
[Original comment](#2113 (comment))

I made a separate PR because I made this mistake in a couple of PRs so I thought I'd knock them out all at once.

Issue: LEMS-2737

## Test plan:

Author: handeyeco

Reviewers: jeremywiebe, benchristel

Required Reviewers:

Approved By: 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), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2125

* respond to Jeremy's feedback
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.

2 participants