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

BUGFIX - [Numeric Input] - Check for wrong answers when scoring #1743

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mark-fitzgerald
Copy link
Contributor

@mark-fitzgerald mark-fitzgerald commented Oct 11, 2024

Summary:

On occasion, answer options within the Numeric Input can overlap. In cases where the wrong/ungraded answer comes before the correct answer, it is important to honor this order when validating a learner's answer. Currently, the Numeric Input widget checks all correct answers for a match before looking at the remaining answer options. This means that an incorrect answer would be marked as correct. This bugfix changes the validation logic to look for the first match regardless of the correctness of the answer itself, and then reports the validation based upon the match.

Issue: LEMS-2238

Test plan:

No Storybook option exists for testing validation of a widget - must be tested in a ZND

  1. Open a Test Everything exercise (Numeric Input may be helpful)
    • Make sure to be logged in
  2. Edit the exercise
    Click to edit
  3. Add a new item to the exercise
    Click to add
  4. Add a Numeric Input widget to the item
    Add widget
  5. Enter an answer of "4" and mark it wrong by clicking on the green "correct" indicator
    Add wrong answer
  6. Add another answer
    Add new answer
  7. Enter an answer of "10 +/- 10"
    Add correct answer
  8. Test the widget in "Preview"
    Test widget
    • Enter the number "4" and click "Check" button - button text should change to "Try again"
    • Enter a different number (like "5") and click the "Check"/"Try again" button - confetti and button text changes to "Done"

@mark-fitzgerald mark-fitzgerald self-assigned this Oct 11, 2024
Copy link
Contributor

github-actions bot commented Oct 11, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1743

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

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

Copy link
Contributor

github-actions bot commented Oct 11, 2024

Size Change: -144 B (-0.02%)

Total Size: 867 kB

Filename Size Change
packages/perseus/dist/es/index.js 419 kB -144 B (-0.03%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38.8 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 78 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 280 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/strings.js 3.4 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.4 kB

compressed-size-action

@mark-fitzgerald mark-fitzgerald marked this pull request as ready for review October 17, 2024 18:32
@khan-actions-bot khan-actions-bot requested a review from a team October 17, 2024 18:32
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/spotty-numbers-arrive.md, packages/perseus/src/widgets/numeric-input/numeric-input-validator.test.ts, packages/perseus/src/widgets/numeric-input/numeric-input-validator.ts

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

Copy link
Contributor

@SonicScrewdriver SonicScrewdriver left a comment

Choose a reason for hiding this comment

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

Works well from my own testing on the ZND -- thank you for providing an easy link! The bug seems to be solved to me, great work!

I do wonder about how we can better explain / illustrate the importance of the "answer" orders for Content Creators, but that's a separate issue. :)

.every((answer) => Math.abs(answer.value) <= 1);

// The coefficient is an attribute of the widget
let localValue: string | number = currentValue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ignorable Nit: We could possibly explain a little more about the coefficient here, but perhaps that's best handled in the widget options.

.find((answer) => {
// NOTE: "answer.score.correct" indicates a match via the validate function.
// It does NOT indicate that the answer itself is correct.
return (
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very helpful comment, thank you! I suspect the validators were made before Expression/Numeric were updated to allow for the inclusion of "wrong" or "ungraded" answers.

correct: matchedAnswer?.status === "correct",
message: matchedAnswer?.message ?? null,
guess: localValue,
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for getting rid of all of these ts expect errors!

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