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

Remove unused rubric type for iFrame #1996

Conversation

Myranae
Copy link
Contributor

@Myranae Myranae commented Dec 12, 2024

Summary:

The initial goal was to separate out answers from the userInput, but iFrame is a unique widget in that the answers aren't actually contained in what is sent to the scoring function. Scoring happens via the iFrame, and the scoring function is told if the user is correct, incorrect, and incomplete. Additionally, validation happens after both types of scoring, so it most likely will not be possible to have a validation function for this widget either.

Question:
Would it be useful to change what the scoreIframe parameter is called as it is not actually the user's input, but a summary of the results of checking the user's input? We could revert the argument back to state or maybe results, but then would we change the type name? I wonder if that would be confusing down the road, but we do have comments explaining it somewhat.

Issue: LEMS-2440

Test plan:

  • Confirm all checks pass
  • Confirm widget still works as expected via a ZND (iframe tends not to be testable locally)

@Myranae Myranae self-assigned this Dec 12, 2024
Copy link
Contributor

github-actions bot commented Dec 12, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1996

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

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

@@ -102,9 +102,6 @@ export type PerseusGrapherRubric = {

export type PerseusGrapherUserInput = PerseusGrapherRubric["correct"];

// TODO(LEMS-2440): Can possibly be removed during 2440; only userInput used
export type PerseusIFrameRubric = Empty;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could removing this now cause problems down the road? I think it's pretty easy to add it back in, but not sure if we need a rubric and userInput for every widget. I'm guessing it's okay, but wanted to double check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree to remove it now. We already have other widgets where there is no Rubric type.

Copy link
Contributor

github-actions bot commented Dec 12, 2024

Size Change: 0 B

Total Size: 1.27 MB

ℹ️ 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 688 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/index.js 416 kB
packages/perseus/dist/es/strings.js 4.12 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@Myranae Myranae marked this pull request as ready for review December 12, 2024 21:58
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to just be removing an unused type, so I put it as patch, but it does touch the UserInput type and the Props type, so wasn't sure if that meant it should be minor. Leaning towards patch, but wanted to confirm :)

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.

Would it be useful to change what the scoreIframe parameter is called as it is not actually the user's input, but a summary of the results of checking the user's input?

No, please don't change the scoring function parameter names. They should all conform to the WidgetScorerFunction type:

export type WidgetScorerFunction = (
    // The user data needed to score
    userInput: UserInput,
    // The scoring criteria to score against
    rubric: Rubric,
    // Strings, for error messages in invalid widgets
    string?: PerseusStrings,
    // Locale, for math evaluation
    // (1,000.00 === 1.000,00 in some countries)
    locale?: string,
) => PerseusScore;

We can omit parameters from the end of the list (all the up to having a scoring function that takes no parameters). Also, TypeScript doesn't care about the parameter names, but for consistency let's keep the argument list and argument names the same as in the WidgetScorerFunction. :)

"@khanacademy/perseus": patch
---

Remove unused iframe rubric type
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see any changes to our main package file (index.ts) which means that this type was not exported from Perseus, so a patch release sounds right to me.

@Myranae Myranae changed the base branch from main to feature/client-validation December 17, 2024 20:48
@Myranae Myranae merged commit b6623bb into feature/client-validation Dec 17, 2024
8 of 13 checks passed
@Myranae Myranae deleted the tb/LEMS-2440/iframe-separate-answers-from-user-input branch December 17, 2024 21:20
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