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

Matrix: Extract validation from scorer #1883

Merged
merged 4 commits into from
Nov 21, 2024
Merged

Conversation

jeremywiebe
Copy link
Collaborator

Summary:

This PR extracts validation from the matrix's scorer function. In reality, it's an empty function, but it follows our conventions for having the scorer call a validator first. I've created the standard tests to ensure that scorer calls the validator.

Issue: LEMS-2602

Test plan:

yarn test
yarn typecheck

@jeremywiebe jeremywiebe self-assigned this Nov 19, 2024
Copy link
Contributor

github-actions bot commented Nov 19, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1883

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

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

Copy link
Contributor

github-actions bot commented Nov 19, 2024

Size Change: +175 B (+0.01%)

Total Size: 1.29 MB

Filename Size Change
packages/perseus/dist/es/index.js 425 kB +175 B (+0.04%)
ℹ️ 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 698 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/strings.js 3.57 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@jeremywiebe jeremywiebe marked this pull request as ready for review November 19, 2024 01:39
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/giant-vans-notice.md, packages/perseus/src/validation.types.ts, packages/perseus/src/widgets/matrix/score-matrix.test.ts, packages/perseus/src/widgets/matrix/score-matrix.ts, packages/perseus/src/widgets/matrix/validate-matrix.test.ts, packages/perseus/src/widgets/matrix/validate-matrix.ts

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 19, 2024 01:39
@jeremywiebe jeremywiebe changed the title Extract validation from matrix scorer Matrix: Extract validation from scorer Nov 19, 2024
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 left some questions to consider :)

*
* @see `scoreMatrix()` for more details.
*/
function validateMatrix(
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Did you decide just to leave all the createValidator logic in the scoring function? Do you think this is something we might want to change in the future? Looks like some of it is for scoring, but some is for validation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's all left in the scoring function because there is no logic that can be moved into the validator that doesn't require the scoring data.

Copy link
Contributor

Choose a reason for hiding this comment

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

It kind of looked like the hasEmptyCell check could possibly be moved out, but then you'd duplicate a lot of that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch. I need the solution size for part of these check but the hasEmptyCell check can definitely be raised up!

@handeyeco
Copy link
Contributor

I'm confused between this and #1881

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 like this PR better than #1881 😅

};
} & PerseusMatrixValidationData;

export type PerseusMatrixValidationData = Empty;
Copy link
Contributor

Choose a reason for hiding this comment

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

I mentioned this in the other PRs, but just to be extra annoying: I'm not sure we really need a bunch of aliases for Empty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove it (and others that were Empty). I've added a doc comment to the top of this file in another PR.

@jeremywiebe jeremywiebe merged commit adad642 into main Nov 21, 2024
9 checks passed
@jeremywiebe jeremywiebe deleted the jer/validate-matrix branch November 21, 2024 23:19
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