-
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
[LEMS-2190] Move coord reverse logic into scoring logic #2217
Conversation
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (a10810b) and published it to npm. You Example: yarn add @khanacademy/perseus@PR2217 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR2217 |
Size Change: -14 B (0%) Total Size: 1.48 MB
ℹ️ View Unchanged
|
@@ -1017,7 +1017,7 @@ export type PerseusGraphTypeRay = { | |||
type AngleGraphCorrect = { | |||
type: "angle"; | |||
allowReflexAngles: boolean; | |||
match: "congruent"; | |||
match?: "congruent"; |
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 this might have been an oversight, but do please let me know if we are intentionally commandeering the match setting for all Angle graphs to "congruent".
If we look at PerseusGraphTypeAngle
, the match property is optional, and indicates that if it is not provided then we default to exact matching. There's some logic for handling this in score-interactive-graph.ts
. It is possible that we may have introduced a bug for some Angle Graphs by hardcoding all answer checking to the "congruent" path.
PerseusGraphTypeAngle
// How to match the answer. If missing, defaults to exact matching.
match?: "congruent";
Scoring Logic
if (rubric.correct.match === "congruent") {
const angles = _.map([guess, correct], function (coords) {
if (!coords) {
return false;
}
const angle = getClockwiseAngle(coords, allowReflexAngles);
return angle;
});
// @ts-expect-error - TS2556 - A spread argument must either have a tuple type or be passed to a rest parameter.
match = approximateEqual(...angles);
} else {
/* exact */
match =
approximateDeepEqual(guess[1], correct[1]) &&
collinear(correct[1], correct[0], guess[0]) &&
collinear(correct[1], correct[2], guess[2]);
}
If we do want to only match for "congruent", then we might want to remove this property altogether along with the additional logic for handling these two cases.
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 match: "congruent"
is pretty odd and confusing. If there's a match at all, it's always "congruent"? I feel like this should be a boolean...
In any case, I think making it optional to match the schema makes sense here. Also it doesn't make sense for it to not be optional, because then match is always there, and it's always "congruent."
const correct = rubric.correct.coords; | ||
const allowReflexAngles = rubric.correct.allowReflexAngles; | ||
|
||
// While the angle graph should always have 3 points, our types | ||
// technically allow for null values. We'll check for that here. | ||
if (!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.
There's really no possible way for coords to ever be less than 3 coordinates, due to how the graphs are set up.
I will make another ticket for setting a stricter type for the Angle Graph Coords, as it will require updating several tests that have only partially mocked data.
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.
Could you make the ticket now and update this comment to start with a TODO(LEMS-XXXX)?
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 like it!
@@ -1017,7 +1017,7 @@ export type PerseusGraphTypeRay = { | |||
type AngleGraphCorrect = { | |||
type: "angle"; | |||
allowReflexAngles: boolean; | |||
match: "congruent"; | |||
match?: "congruent"; |
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 match: "congruent"
is pretty odd and confusing. If there's a match at all, it's always "congruent"? I feel like this should be a boolean...
In any case, I think making it optional to match the schema makes sense here. Also it doesn't make sense for it to not be optional, because then match is always there, and it's always "congruent."
const correct = rubric.correct.coords; | ||
const allowReflexAngles = rubric.correct.allowReflexAngles; | ||
|
||
// While the angle graph should always have 3 points, our types | ||
// technically allow for null values. We'll check for that here. | ||
if (!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.
Could you make the ticket now and update this comment to start with a TODO(LEMS-XXXX)?
@@ -264,11 +283,9 @@ function scoreInteractiveGraph( | |||
match = approximateEqual(...angles); | |||
} else { | |||
/* exact */ | |||
match = // @ts-expect-error - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'. |
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.
🎉
@@ -358,3 +358,131 @@ describe("InteractiveGraph scoring on a point question", () => { | |||
expect(rubric).toEqual(rubricClone); | |||
}); | |||
}); | |||
|
|||
describe("InteractiveGraph scoring on an angle question", () => { | |||
it("marks the answer invalid if guess.coords is missing", () => { |
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.
Thank you for adding this test!
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 - [#2194](#2194) [`fd606f43d`](fd606f4) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for an interactive graph widget - [#2189](#2189) [`3ba74d173`](3ba74d1) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for a Table widget - [#2200](#2200) [`47cebd20f`](47cebd2) Thanks [@nishasy](https://github.com/nishasy)! - [Mafs] Remove mafs flag from Interactive Graph code - [#2207](#2207) [`097176a26`](097176a) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for a Matrix widget - [#2216](#2216) [`b3c562ac2`](b3c562a) Thanks [@Myranae](https://github.com/Myranae)! - Implement a widget export function to filter out rubric data from widget options for the Plotter widget - [#2198](#2198) [`649e6b16a`](649e6b1) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for a Grapher widget - [#2217](#2217) [`07779783a`](0777978) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Move coord reverse logic for Angle graphs into scoring logic - [#2183](#2183) [`cac39013b`](cac3901) Thanks [@Myranae](https://github.com/Myranae)! - Implement a widget export function to filter out rubric data from widget options for the Radio widget - [#2188](#2188) [`163dd67d2`](163dd67) Thanks [@Myranae](https://github.com/Myranae)! - Implement a widget export function to retrieve public widget options for the IFrame widget ### Patch Changes - [#2107](#2107) [`b44c8cb0a`](b44c8cb) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Storybook] Configure Aphrodite to Not Append !important to Styles [Radio] Bugfix - Incorrect choice showing as blue instead of red - [#2191](#2191) [`55317d65e`](55317d6) Thanks [@nishasy](https://github.com/nishasy)! - [SR] Polygon (unlimited) - Add screen reader experience - [#2220](#2220) [`6b8185885`](6b81858) Thanks [@nishasy](https://github.com/nishasy)! - [SR] Stop graph from exposing random empty image to screen readers - [#2185](#2185) [`f83a1fb03`](f83a1fb) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Bugfix] Zoomable content within a collapsed parent not showing when expanded (Mobile only) - [#2222](#2222) [`55be8a775`](55be8a7) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating wonderblocks package versions. - [#2173](#2173) [`10ee67a9c`](10ee67a) Thanks [@nishasy](https://github.com/nishasy)! - [SR] Polygon - Add screen reader experience - [#2196](#2196) [`b07f2936f`](b07f293) Thanks [@nishasy](https://github.com/nishasy)! - [SR] Segment - fix 2 strings with typos - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`7ec6c2fbc`](7ec6c2f), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`55be8a775`](55be8a7), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Minor Changes - [#2194](#2194) [`fd606f43d`](fd606f4) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for an interactive graph widget - [#2189](#2189) [`3ba74d173`](3ba74d1) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for a Table widget - [#2207](#2207) [`097176a26`](097176a) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for a Matrix widget - [#2216](#2216) [`b3c562ac2`](b3c562a) Thanks [@Myranae](https://github.com/Myranae)! - Implement a widget export function to filter out rubric data from widget options for the Plotter widget - [#2198](#2198) [`649e6b16a`](649e6b1) Thanks [@benchristel](https://github.com/benchristel)! - Create a function to get the public options for a Grapher widget - [#2217](#2217) [`07779783a`](0777978) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Move coord reverse logic for Angle graphs into scoring logic - [#2183](#2183) [`cac39013b`](cac3901) Thanks [@Myranae](https://github.com/Myranae)! - Implement a widget export function to filter out rubric data from widget options for the Radio widget - [#2188](#2188) [`163dd67d2`](163dd67) Thanks [@Myranae](https://github.com/Myranae)! - Implement a widget export function to retrieve public widget options for the IFrame widget ## @khanacademy/[email protected] ### Minor Changes - [#2200](#2200) [`47cebd20f`](47cebd2) Thanks [@nishasy](https://github.com/nishasy)! - [Mafs] Remove mafs flag from Interactive Graph code ### Patch Changes - [#2190](#2190) [`7ec6c2fbc`](7ec6c2f) Thanks [@nishasy](https://github.com/nishasy)! - Add convertRadiansToDegrees function to kmath - [#2222](#2222) [`55be8a775`](55be8a7) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating wonderblocks package versions. - [#2208](#2208) [`6a0bf7a52`](6a0bf7a) Thanks [@nishasy](https://github.com/nishasy)! - [SR Tree] Handle SR Tree when multiple editors are on the page - [#2193](#2193) [`8d569b74c`](8d569b7) Thanks [@beaesguerra](https://github.com/beaesguerra)! - Update internal addStyle variable name to address aphrodite-add-style-variable-name linting rule - Updated dependencies \[[`fd606f43d`](fd606f4), [`b44c8cb0a`](b44c8cb), [`3ba74d173`](3ba74d1), [`55317d65e`](55317d6), [`47cebd20f`](47cebd2), [`7ec6c2fbc`](7ec6c2f), [`6b8185885`](6b81858), [`f83a1fb03`](f83a1fb), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`55be8a775`](55be8a7), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`10ee67a9c`](10ee67a), [`163dd67d2`](163dd67), [`b07f2936f`](b07f293)]: - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Minor Changes - [#2217](#2217) [`07779783a`](0777978) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Move coord reverse logic for Angle graphs into scoring logic ### Patch Changes - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`7ec6c2fbc`](7ec6c2f), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Patch Changes - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Patch Changes - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Patch Changes - [#2190](#2190) [`7ec6c2fbc`](7ec6c2f) Thanks [@nishasy](https://github.com/nishasy)! - Add convertRadiansToDegrees function to kmath - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Patch Changes - [#2222](#2222) [`55be8a775`](55be8a7) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating wonderblocks package versions. - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Patch Changes - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Patch Changes - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Patch Changes - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] ## @khanacademy/[email protected] ### Minor Changes - [#2200](#2200) [`47cebd20f`](47cebd2) Thanks [@nishasy](https://github.com/nishasy)! - [Mafs] Remove mafs flag from Interactive Graph code ### Patch Changes - [#2107](#2107) [`b44c8cb0a`](b44c8cb) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Storybook] Configure Aphrodite to Not Append !important to Styles [Radio] Bugfix - Incorrect choice showing as blue instead of red - [#2222](#2222) [`55be8a775`](55be8a7) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating wonderblocks package versions. - Updated dependencies \[[`fd606f43d`](fd606f4), [`3ba74d173`](3ba74d1), [`7ec6c2fbc`](7ec6c2f), [`097176a26`](097176a), [`b3c562ac2`](b3c562a), [`55be8a775`](55be8a7), [`649e6b16a`](649e6b1), [`07779783a`](0777978), [`cac39013b`](cac3901), [`163dd67d2`](163dd67)]: - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] - @khanacademy/[email protected] Author: khan-actions-bot Reviewers: benchristel Required Reviewers: Approved By: benchristel Checks: ⏭️ Publish npm snapshot, ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x) Pull Request URL: #2186
Summary:
This PR is part of the Interactive Graph project.
It contains the work required to move the coordinate reversal logic from the
getGradeableGraph
function and move it directly into our scoring logic. This logic was initially left ingetGradeableGraph
while we waited for the legacy Angle graph to no longer be in use.The reason for this was that there were 2 conflicting bugs in the Angle graph previously:
allowReflexiveAngles
was false.Unfortunately, the combination of these bugs meant that we we needed to keep the scoring logic unchanged until the feature flags for the new Angle graph were removed.
Issue: LEMS-2190
Test plan: