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 scoring out of general Util into scoring util file #1962

Merged
merged 6 commits into from
Dec 6, 2024

Conversation

jeremywiebe
Copy link
Collaborator

Summary:

Like #1948, I was working in utils.ts and found it annoying how there were so many different utils in one file (graphing support, scoring, word/text manipulation). So this just pulls scoring-related behaviour out into a new file. This means these symbols are no longer on the Utils object, but I checked and they aren't used in Perseus nor in consuming apps.

Issue: LEMS-2561

Test plan:

yarn test
yarn typecheck

@jeremywiebe jeremywiebe self-assigned this Dec 6, 2024
@jeremywiebe jeremywiebe marked this pull request as ready for review December 6, 2024 03:07
@khan-actions-bot khan-actions-bot requested a review from a team December 6, 2024 03:07
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Dec 6, 2024

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/clever-cars-eat.md, dev/flipbook.tsx, packages/perseus/src/index.ts, packages/perseus/src/renderer-util.ts, packages/perseus/src/renderer.tsx, packages/perseus/src/server-item-renderer.tsx, packages/perseus/src/util.ts, packages/perseus/src/__tests__/util.test.ts, packages/perseus/src/multi-items/multi-renderer.tsx, packages/perseus/src/util/scoring.test.ts, packages/perseus/src/util/scoring.ts, packages/perseus/src/widgets/group/score-group.ts

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

@jeremywiebe jeremywiebe requested review from benchristel, SonicScrewdriver, handeyeco and Myranae and removed request for a team December 6, 2024 03:07
@@ -1,21 +1,4 @@
import Util, {isCorrect} from "../util";

describe("isCorrect", () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All deleted tests here just moved to scoring.test.ts

@@ -47,7 +47,7 @@ import {DependenciesContext} from "../dependencies";
import HintsRenderer from "../hints-renderer";
import {Log} from "../logging/log";
import Renderer from "../renderer";
import Util from "../util";
import {combineScores, keScoreFromPerseusScore} from "../util/scoring";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also switched to ES6 exports in the new file.

Copy link
Contributor

github-actions bot commented Dec 6, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1962

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

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

Copy link
Contributor

github-actions bot commented Dec 6, 2024

Size Change: +6 B (0%)

Total Size: 1.29 MB

Filename Size Change
packages/perseus/dist/es/index.js 425 kB +6 B (0%)
ℹ️ 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.7 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@khan-actions-bot khan-actions-bot requested a review from a team December 6, 2024 03:10
Copy link
Contributor

@Myranae Myranae left a comment

Choose a reason for hiding this comment

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

Looks good! Just have to remove that unused import for the failing check :)

Copy link
Contributor

@handeyeco handeyeco left a comment

Choose a reason for hiding this comment

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

I think you'll need to make changes to index.ts to make sure the utils that are used in Webapp are still accessible. Otherwise a great change. 👍

@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": minor
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd argue this is a major change. Util is exported from index.ts:

export {default as Util} from "./util";

You'll see that this breaks Webapp because I used Util.keScoreFromPerseusScore in my recent change. So:

  1. Probably a major change
  2. I'd double check the utils that you moved to make sure they're not used in Webapp (and export the ones that are)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. I didn't catch the one usage of keScoreFromPerseusScore outside of Perseus. Fixing.

@jeremywiebe jeremywiebe merged commit 435280a into main Dec 6, 2024
9 checks passed
@jeremywiebe jeremywiebe deleted the jer/scoring-utils branch December 6, 2024 17:05
jeremywiebe pushed a commit that referenced this pull request Dec 6, 2024
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/perseus@46.0.0

### Major Changes

-   [#1962](#1962) [`435280ac4`](435280a) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Move scoring utility functions out of `Util` object into their own file and only export externally used function (`keScoreFromPerseusScore`)


-   [#1961](#1961) [`d93e3ecde`](d93e3ec) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Remove deprecated/unused `examples()` function from `Renderer`

## @khanacademy/perseus-editor@15.1.3

### Patch Changes

-   Updated dependencies \[[`435280ac4`](435280a), [`d93e3ecde`](d93e3ec)]:
    -   @khanacademy/perseus@46.0.0

Author: khan-actions-bot

Reviewers: jeremywiebe

Required Reviewers:

Approved By: jeremywiebe

Checks: ⏭️  Publish npm snapshot, ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (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), ✅ gerald

Pull Request URL: #1964
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.

4 participants