@khanacademy/perseus 6.3.1 → 6.4.0
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/CHANGELOG.md +25 -0
- package/dist/es/index.js +109 -11
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +109 -10
- package/dist/index.js.flow +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interactive2/movable-polygon-options.d.ts +1 -1
- package/dist/interactive2/movable.d.ts +1 -1
- package/dist/perseus-types.d.ts +2 -1
- package/dist/perseus-types.js.flow +9 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js.flow +2 -0
- package/package.json +3 -2
- package/src/__tests__/renderer.test.tsx +0 -1
- package/src/index.ts +1 -0
- package/src/interactive2/__tests__/movable-mock.ts +0 -1
- package/src/interactive2/movable-polygon-options.ts +1 -2
- package/src/interactive2/movable.ts +1 -2
- package/src/interactive2.ts +0 -3
- package/src/perseus-types.ts +7 -1
- package/src/renderer.tsx +1 -1
- package/src/types.ts +14 -0
- package/src/widgets/__testdata__/expression.testdata.ts +1 -1
- package/src/widgets/__tests__/expression.test.ts +36 -10
- package/src/widgets/__tests__/renderQuestion.tsx +0 -1
- package/src/widgets/expression.tsx +25 -0
- package/src/widgets/matrix.tsx +2 -4
- package/tsconfig-build.json +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export { default as KhanMath } from "./util/math";
|
|
|
60
60
|
export { default as LoadingContext } from "./loading-context";
|
|
61
61
|
export { default as mediaQueries } from "./styles/media-queries";
|
|
62
62
|
export { default as PerseusMarkdown } from "./perseus-markdown";
|
|
63
|
+
export { PerseusExpressionAnswerFormConsidered } from "./perseus-types";
|
|
63
64
|
export { traverse } from "./traversal";
|
|
64
65
|
export { isItemRenderableByVersion } from "./renderability";
|
|
65
66
|
export { violatingWidgets } from "./a11y";
|
package/dist/index.js
CHANGED
|
@@ -2484,6 +2484,16 @@ const KhanAnswerTypes = {
|
|
|
2484
2484
|
}
|
|
2485
2485
|
};
|
|
2486
2486
|
|
|
2487
|
+
const sendExpressionEvaluatedEvent = result => {
|
|
2488
|
+
getDependencies().analytics({
|
|
2489
|
+
type: "perseus:expression-evaluated",
|
|
2490
|
+
payload: {
|
|
2491
|
+
virtualKeypadVersion: "PERSEUS_MATH_INPUT",
|
|
2492
|
+
// STOPSHIP: Or do we push that onto host application?
|
|
2493
|
+
result
|
|
2494
|
+
}
|
|
2495
|
+
});
|
|
2496
|
+
};
|
|
2487
2497
|
const ERROR_MESSAGE = i18n__namespace._("Sorry, I don't understand that!");
|
|
2488
2498
|
const insertBraces = value => {
|
|
2489
2499
|
// HACK(alex): Make sure that all LaTeX super/subscripts are wrapped
|
|
@@ -2720,6 +2730,8 @@ class Expression extends React__namespace.Component {
|
|
|
2720
2730
|
// we did, whether it's considered correct, incorrect, or ungraded
|
|
2721
2731
|
if (!matchingAnswerForm) {
|
|
2722
2732
|
if (firstUngradedResult) {
|
|
2733
|
+
sendExpressionEvaluatedEvent("invalid");
|
|
2734
|
+
|
|
2723
2735
|
// While we didn't directly match with any answer form, we
|
|
2724
2736
|
// did at some point get an "ungraded" validation result,
|
|
2725
2737
|
// which might indicate e.g. a mismatch in variable casing.
|
|
@@ -2733,6 +2745,8 @@ class Expression extends React__namespace.Component {
|
|
|
2733
2745
|
};
|
|
2734
2746
|
}
|
|
2735
2747
|
if (allEmpty) {
|
|
2748
|
+
sendExpressionEvaluatedEvent("invalid");
|
|
2749
|
+
|
|
2736
2750
|
// If everything graded as empty, it's invalid.
|
|
2737
2751
|
return {
|
|
2738
2752
|
type: "invalid",
|
|
@@ -2741,6 +2755,7 @@ class Expression extends React__namespace.Component {
|
|
|
2741
2755
|
}
|
|
2742
2756
|
// We fell through all the possibilities and we're not empty,
|
|
2743
2757
|
// so the answer is considered incorrect.
|
|
2758
|
+
sendExpressionEvaluatedEvent("incorrect");
|
|
2744
2759
|
return {
|
|
2745
2760
|
type: "points",
|
|
2746
2761
|
earned: 0,
|
|
@@ -2753,6 +2768,7 @@ class Expression extends React__namespace.Component {
|
|
|
2753
2768
|
const apiResult = onInputError(null,
|
|
2754
2769
|
// Reserved for some widget identifier
|
|
2755
2770
|
userInput, matchMessage);
|
|
2771
|
+
sendExpressionEvaluatedEvent("invalid");
|
|
2756
2772
|
return {
|
|
2757
2773
|
type: "invalid",
|
|
2758
2774
|
message: apiResult === false ? null : matchMessage
|
|
@@ -2764,6 +2780,7 @@ class Expression extends React__namespace.Component {
|
|
|
2764
2780
|
// TODO(eater): Seems silly to translate result to this
|
|
2765
2781
|
// invalid/points thing and immediately translate it back in
|
|
2766
2782
|
// ItemRenderer.scoreInput()
|
|
2783
|
+
sendExpressionEvaluatedEvent(matchingAnswerForm.considered === "correct" ? "correct" : "incorrect");
|
|
2767
2784
|
return {
|
|
2768
2785
|
type: "points",
|
|
2769
2786
|
earned: matchingAnswerForm.considered === "correct" ? 1 : 0,
|
|
@@ -14206,8 +14223,6 @@ const DEFAULT_STATE$3 = {
|
|
|
14206
14223
|
isDragging: false,
|
|
14207
14224
|
mouseTarget: null
|
|
14208
14225
|
};
|
|
14209
|
-
|
|
14210
|
-
// @ts-expect-error [FEI-5003] - TS2355 - A function whose declared type is neither 'void' nor 'any' must return a value.
|
|
14211
14226
|
const Movable = function (graphie, options) {
|
|
14212
14227
|
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
14213
14228
|
___default["default"].extend(this, {
|
|
@@ -15819,7 +15834,6 @@ const constraints = {
|
|
|
15819
15834
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'standard' does not exist on type '{ readonly fixed: () => () => boolean; readonly snap: (snap: any) => (arg1: Coord) => unknown; readonly bound: (range: any, snap: any, paddingPx: number) => (arg1: Coord, arg2: Coord) => Coord; }'.
|
|
15820
15835
|
constraints.standard = null;
|
|
15821
15836
|
const onMove = {
|
|
15822
|
-
// @ts-expect-error [FEI-5003] - TS2355 - A function whose declared type is neither 'void' nor 'any' must return a value.
|
|
15823
15837
|
updatePoints: function (coord, prevCoord) {
|
|
15824
15838
|
const actualDelta = kmath.vector.subtract(coord, prevCoord);
|
|
15825
15839
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'state' does not exist on type '{ readonly updatePoints: (coord: Coord, prevCoord: Coord) => undefined; }'.
|
|
@@ -16127,19 +16141,16 @@ ___default["default"].extend(MovablePolygon.prototype, {
|
|
|
16127
16141
|
const Interactive2 = {
|
|
16128
16142
|
MovablePoint: MovablePoint$5,
|
|
16129
16143
|
addMovablePoint: function (graphie, options) {
|
|
16130
|
-
// @ts-expect-error [FEI-5003] - TS2350 - Only a void function can be called with the 'new' keyword.
|
|
16131
16144
|
const movable = new Movable(graphie, {});
|
|
16132
16145
|
return new MovablePoint$5(graphie, movable, options);
|
|
16133
16146
|
},
|
|
16134
16147
|
MovableLine: MovableLine$4,
|
|
16135
16148
|
addMovableLine: function (graphie, options) {
|
|
16136
|
-
// @ts-expect-error [FEI-5003] - TS2350 - Only a void function can be called with the 'new' keyword.
|
|
16137
16149
|
const movable = new Movable(graphie, {});
|
|
16138
16150
|
return new MovableLine$4(graphie, movable, options);
|
|
16139
16151
|
},
|
|
16140
16152
|
MovablePolygon: MovablePolygon,
|
|
16141
16153
|
addMovablePolygon: function (graphie, options) {
|
|
16142
|
-
// @ts-expect-error [FEI-5003] - TS2350 - Only a void function can be called with the 'new' keyword.
|
|
16143
16154
|
const movable = new Movable(graphie, {});
|
|
16144
16155
|
return new MovablePolygon(graphie, movable, options);
|
|
16145
16156
|
},
|
|
@@ -33573,15 +33584,13 @@ class Matrix extends React__namespace.Component {
|
|
|
33573
33584
|
}
|
|
33574
33585
|
});
|
|
33575
33586
|
_defineProperty(this, "onValueChange", (row, column, value, cb) => {
|
|
33576
|
-
const answers =
|
|
33587
|
+
const answers = this.props.answers.map(answer => [...answer]);
|
|
33577
33588
|
if (!answers[row]) {
|
|
33578
33589
|
answers[row] = [];
|
|
33579
33590
|
}
|
|
33580
|
-
// @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
|
|
33581
33591
|
answers[row][column] = value;
|
|
33582
|
-
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
33583
33592
|
this.props.onChange({
|
|
33584
|
-
answers
|
|
33593
|
+
answers
|
|
33585
33594
|
}, cb);
|
|
33586
33595
|
this.props.trackInteraction();
|
|
33587
33596
|
});
|
|
@@ -45966,6 +45975,95 @@ const context = /*#__PURE__*/React__namespace.createContext({
|
|
|
45966
45975
|
scrollableElement: null
|
|
45967
45976
|
});
|
|
45968
45977
|
|
|
45978
|
+
// TODO(FEI-4010): Remove `Perseus` prefix for all types here
|
|
45979
|
+
// TODO(FEI-4011): Use types generated by https://github.com/jaredly/generate-perseus-flowtypes
|
|
45980
|
+
|
|
45981
|
+
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
45982
|
+
|
|
45983
|
+
// prettier-ignore
|
|
45984
|
+
|
|
45985
|
+
// prettier-ignore
|
|
45986
|
+
|
|
45987
|
+
// prettier-ignore
|
|
45988
|
+
|
|
45989
|
+
// prettier-ignore
|
|
45990
|
+
|
|
45991
|
+
// prettier-ignore
|
|
45992
|
+
|
|
45993
|
+
// prettier-ignore
|
|
45994
|
+
|
|
45995
|
+
// prettier-ignore
|
|
45996
|
+
|
|
45997
|
+
// prettier-ignore
|
|
45998
|
+
|
|
45999
|
+
// prettier-ignore
|
|
46000
|
+
|
|
46001
|
+
// prettier-ignore
|
|
46002
|
+
|
|
46003
|
+
// prettier-ignore
|
|
46004
|
+
|
|
46005
|
+
// prettier-ignore
|
|
46006
|
+
|
|
46007
|
+
// prettier-ignore
|
|
46008
|
+
|
|
46009
|
+
// prettier-ignore
|
|
46010
|
+
|
|
46011
|
+
// prettier-ignore
|
|
46012
|
+
|
|
46013
|
+
// prettier-ignore
|
|
46014
|
+
|
|
46015
|
+
// prettier-ignore
|
|
46016
|
+
|
|
46017
|
+
// prettier-ignore
|
|
46018
|
+
|
|
46019
|
+
// prettier-ignore
|
|
46020
|
+
|
|
46021
|
+
// prettier-ignore
|
|
46022
|
+
|
|
46023
|
+
// prettier-ignore
|
|
46024
|
+
|
|
46025
|
+
// prettier-ignore
|
|
46026
|
+
|
|
46027
|
+
// prettier-ignore
|
|
46028
|
+
|
|
46029
|
+
// prettier-ignore
|
|
46030
|
+
|
|
46031
|
+
// prettier-ignore
|
|
46032
|
+
|
|
46033
|
+
// prettier-ignore
|
|
46034
|
+
|
|
46035
|
+
// prettier-ignore
|
|
46036
|
+
|
|
46037
|
+
// prettier-ignore
|
|
46038
|
+
|
|
46039
|
+
// prettier-ignore
|
|
46040
|
+
|
|
46041
|
+
// prettier-ignore
|
|
46042
|
+
|
|
46043
|
+
// prettier-ignore
|
|
46044
|
+
|
|
46045
|
+
// prettier-ignore
|
|
46046
|
+
|
|
46047
|
+
// prettier-ignore
|
|
46048
|
+
|
|
46049
|
+
// prettier-ignore
|
|
46050
|
+
|
|
46051
|
+
// prettier-ignore
|
|
46052
|
+
|
|
46053
|
+
// prettier-ignore
|
|
46054
|
+
|
|
46055
|
+
// prettier-ignore
|
|
46056
|
+
|
|
46057
|
+
// prettier-ignore
|
|
46058
|
+
|
|
46059
|
+
// prettier-ignore
|
|
46060
|
+
|
|
46061
|
+
// prettier-ignore
|
|
46062
|
+
|
|
46063
|
+
// A background image applied to various widgets.
|
|
46064
|
+
|
|
46065
|
+
const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
|
|
46066
|
+
|
|
45969
46067
|
/**
|
|
45970
46068
|
* Traverses a {content, widgets, images} renderer props object,
|
|
45971
46069
|
* such as `itemData.question`
|
|
@@ -47028,6 +47126,7 @@ exports.MatrixWidget = Matrix$1;
|
|
|
47028
47126
|
exports.MultiItems = MultiItems;
|
|
47029
47127
|
exports.NumericInput = NumericInput$1;
|
|
47030
47128
|
exports.PerseusError = PerseusError;
|
|
47129
|
+
exports.PerseusExpressionAnswerFormConsidered = PerseusExpressionAnswerFormConsidered;
|
|
47031
47130
|
exports.PerseusMarkdown = PerseusMarkdown;
|
|
47032
47131
|
exports.PlotterWidget = Plotter$1;
|
|
47033
47132
|
exports.Radio = Radio;
|
package/dist/index.js.flow
CHANGED
|
@@ -54,6 +54,7 @@ declare export { default as KhanMath } from "./util/math";
|
|
|
54
54
|
declare export { default as LoadingContext } from "./loading-context";
|
|
55
55
|
declare export { default as mediaQueries } from "./styles/media-queries";
|
|
56
56
|
declare export { default as PerseusMarkdown } from "./perseus-markdown";
|
|
57
|
+
declare export { PerseusExpressionAnswerFormConsidered } from "./perseus-types";
|
|
57
58
|
declare export { traverse } from "./traversal";
|
|
58
59
|
declare export { isItemRenderableByVersion } from "./renderability";
|
|
59
60
|
declare export { violatingWidgets } from "./a11y";
|