@khanacademy/perseus-score 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +22 -9
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/score.d.ts +0 -7
- package/package.json +4 -4
package/dist/es/index.js
CHANGED
|
@@ -12847,7 +12847,8 @@ function scoreIframe(userInput) {
|
|
|
12847
12847
|
const {
|
|
12848
12848
|
collinear,
|
|
12849
12849
|
canonicalSineCoefficients,
|
|
12850
|
-
similar
|
|
12850
|
+
similar,
|
|
12851
|
+
clockwise
|
|
12851
12852
|
} = geometry;
|
|
12852
12853
|
const {
|
|
12853
12854
|
getClockwiseAngle
|
|
@@ -13007,9 +13008,27 @@ function scoreInteractiveGraph(userInput, rubric) {
|
|
|
13007
13008
|
};
|
|
13008
13009
|
}
|
|
13009
13010
|
} else if (userInput.type === "angle" && rubric.correct.type === "angle") {
|
|
13010
|
-
const
|
|
13011
|
+
const coords = userInput.coords;
|
|
13011
13012
|
const correct = rubric.correct.coords;
|
|
13012
13013
|
const allowReflexAngles = rubric.correct.allowReflexAngles;
|
|
13014
|
+
|
|
13015
|
+
// While the angle graph should always have 3 points, our types
|
|
13016
|
+
// technically allow for null values. We'll check for that here.
|
|
13017
|
+
// TODO: (LEMS-2857) We would like to update the type of coords
|
|
13018
|
+
// to be non-nullable, as the graph should always have 3 points.
|
|
13019
|
+
if (!coords) {
|
|
13020
|
+
return {
|
|
13021
|
+
type: "invalid",
|
|
13022
|
+
message: null
|
|
13023
|
+
};
|
|
13024
|
+
}
|
|
13025
|
+
|
|
13026
|
+
// We need to check both the direction of the angle and the
|
|
13027
|
+
// whether the graph allows for reflexive angles in order to
|
|
13028
|
+
// to determine if we need to reverse the coords for scoring.
|
|
13029
|
+
const areClockwise = clockwise([coords[0], coords[2], coords[1]]);
|
|
13030
|
+
const shouldReverseCoords = areClockwise && !allowReflexAngles;
|
|
13031
|
+
const guess = shouldReverseCoords ? coords.slice().reverse() : coords;
|
|
13013
13032
|
let match;
|
|
13014
13033
|
if (rubric.correct.match === "congruent") {
|
|
13015
13034
|
const angles = _.map([guess, correct], function (coords) {
|
|
@@ -13023,13 +13042,7 @@ function scoreInteractiveGraph(userInput, rubric) {
|
|
|
13023
13042
|
match = approximateEqual(...angles);
|
|
13024
13043
|
} else {
|
|
13025
13044
|
/* exact */
|
|
13026
|
-
match =
|
|
13027
|
-
// @ts-expect-error - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
13028
|
-
approximateDeepEqual(guess[1], correct[1]) &&
|
|
13029
|
-
// @ts-expect-error - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
13030
|
-
collinear(correct[1], correct[0], guess[0]) &&
|
|
13031
|
-
// @ts-expect-error - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
13032
|
-
collinear(correct[1], correct[2], guess[2]);
|
|
13045
|
+
match = approximateDeepEqual(guess[1], correct[1]) && collinear(correct[1], correct[0], guess[0]) && collinear(correct[1], correct[2], guess[2]);
|
|
13033
13046
|
}
|
|
13034
13047
|
if (match) {
|
|
13035
13048
|
return {
|