-
Notifications
You must be signed in to change notification settings - Fork 350
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
Ensure the new Mafs-based Angle Graphs score correctly #1432
Conversation
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (ffb1f03) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1432 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1432 |
Size Change: +353 B (+0.04%) Total Size: 852 kB
ℹ️ View Unchanged
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1432 +/- ##
==========================================
+ Coverage 69.93% 70.52% +0.58%
==========================================
Files 508 511 +3
Lines 105287 105346 +59
Branches 5364 11405 +6041
==========================================
+ Hits 73636 74297 +661
+ Misses 31534 31049 -485
+ Partials 117 0 -117
... and 122 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
]); | ||
const shouldReverseCoords = areClockwise && !state.allowReflexAngles; | ||
const coords: [Coord, Coord, Coord] = shouldReverseCoords | ||
? (state.coords.slice().reverse() as [Coord, Coord, Coord]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can get away without the as
if you use:
? (state.coords.slice().reverse() as [Coord, Coord, Coord]) | |
? ([...state.coords].reverse() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly no luck here :(
Reverse returns a generic array (Coord[]), and we're looking specifically for [Coord, Coord, Coord], so typescript becomes unhappy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right! It's reverse()
that's part of the problem!
return { | ||
...initialGraph, | ||
coords: state.coords, | ||
coords: coords, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
coords: coords, | |
coords, |
// we don't allow reflex angles. This is because the angle is largely defined | ||
// by the order of the points in the coords array, and we want to maintain | ||
// the same angle scoring with the legacy graph (which had a bug). | ||
// (LEMS-2190): When we remove the legacy graph, move this logic to the scoring function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for leaving such a great, explanatory comment. I was thinking about removing the old code and how we'd know about LEMS-2190 at that time. What do you think of also adding a reference to LEMS-2190 at the top of the legacy interactive-graph file? Or near some code that we know we'll be touching when we delete it.
// is reflexive in a clockwise direction in order to temporarily maintain the same angle scoring with the | ||
// legacy graph. This logic (& the tests) should be moved to the scoring function after removing the legacy graph. | ||
it("returns reversed coordinates if the angle graph is reflexive when not allowed", () => { | ||
const state: InteractiveGraphState = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about the builder work that Ben/Nisha have done... in these three tests, the only bits that change are the coords
and allowReflexAngles
right?
I wonder if it's worth building a InteractiveGraphState like this:
const defaultState: InteractiveGraphState = {
type: "angle",
coords: [
[-5, 0],
[0, 0],
[5, 5],
],
hasBeenInteractedWith: true,
range: [
[-10, 10],
[-10, 10],
],
snapStep: [1, 1],
showAngles: true,
allowReflexAngles: false,
};
And then in the tests:
const state = {
...defaultState,
coords: [[], [], []],
allowReflexAngles: true, // or false
}
That would distill the data to only the bits that area essential to the test. 🤔
a41768b
to
80d8769
Compare
"All these pieces, black and swift Are moving through themselves"
80d8769
to
ffb1f03
Compare
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/[email protected] ### Minor Changes - [#1468](#1468) [`af68a9e08`](af68a9e) Thanks [@nishasy](https://github.com/nishasy)! - [Hint Mode: Start Coords] Add start coords UI for sinusoid graphs - [#1469](#1469) [`6e1ec850c`](6e1ec85) Thanks [@nishasy](https://github.com/nishasy)! - [Hint Mode: Start Coords] Add start coords UI for quadratic graphs ### Patch Changes - [#1470](#1470) [`942b0a9a5`](942b0a9) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Locked Figures] Remove m2 flag from the code - [#1465](#1465) [`94ad04fee`](94ad04f) Thanks [@nishasy](https://github.com/nishasy)! - [Hint Mode: Start Coords] Add separate flags for graph types - [#1432](#1432) [`ed6737025`](ed67370) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Bug fix to ensure that new angle graphs are scored correctly. ## @khanacademy/[email protected] ### Minor Changes - [#1468](#1468) [`af68a9e08`](af68a9e) Thanks [@nishasy](https://github.com/nishasy)! - [Hint Mode: Start Coords] Add start coords UI for sinusoid graphs - [#1469](#1469) [`6e1ec850c`](6e1ec85) Thanks [@nishasy](https://github.com/nishasy)! - [Hint Mode: Start Coords] Add start coords UI for quadratic graphs ### Patch Changes - [#1470](#1470) [`942b0a9a5`](942b0a9) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Locked Figures] Remove m2 flag from the code - [#1465](#1465) [`94ad04fee`](94ad04f) Thanks [@nishasy](https://github.com/nishasy)! - [Hint Mode: Start Coords] Add separate flags for graph types - Updated dependencies \[[`af68a9e08`](af68a9e), [`942b0a9a5`](942b0a9), [`6e1ec850c`](6e1ec85), [`94ad04fee`](94ad04f), [`ed6737025`](ed67370)]: - @khanacademy/[email protected]
Summary:
The new Mafs-based Angle graphs were being marked as incorrect if the user moves the bottom point clockwise, which was not caught earlier as there was a bug in the implementation of the legacy Angle graphs that allowed users to create reflexive angles when they were not supposed to be able to.
The new Mafs-based Angle graph solves this issue, but it uncovered a bug in our scoring that fails to handle this particular state.
This ticket adds the logic necessary to reverse the coordinates (for scoring purposes) when they're clockwise and reflexive graphs are not allowed. This will be the approach used until we are able to remove/deprecate the legacy Angle graphs.
When the legacy Angle graph is removed, it's highly recommended that this logic be moved directly to the scoring function in
interactive-graph.tsx
, so that there's no future confusion about how the scoring is being calculated. Upgrading this graph was very difficult due to the previous logic being split across many different files, so this will save us a lot of headaches down the road. The ticket to house that work can be found here.Issue: LEMS-2165
Test plan:
Video:
Screen.Recording.2024-07-22.at.1.52.56.PM.mov