@khanacademy/perseus 11.5.1 → 11.6.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 +15 -0
- package/dist/es/index.css +6 -6
- package/dist/es/index.js +17 -5
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +6 -6
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/widgets/numeric-input.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap +3 -3
- package/src/__tests__/item-renderer.test.tsx +24 -18
- package/src/hint-renderer.tsx +1 -0
- package/src/multi-items/__tests__/__snapshots__/multi-renderer.test.tsx.snap +1 -1
- package/src/perseus-types.ts +2 -1
- package/src/styles/khan-exercise.css +6 -4
- package/src/styles/perseus-renderer.less +0 -1
- package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +7 -21
- package/src/widgets/__tests__/expression-mobile.test.tsx +7 -20
- package/src/widgets/__tests__/numeric-input.test.ts +35 -0
- package/src/widgets/numeric-input.tsx +22 -10
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @khanacademy/perseus
|
|
2
2
|
|
|
3
|
+
## 11.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0761377a: Ensured we're still validating against pi when strict is set to false and pi is in the answerforms.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 14138bb0: Move StatefulKeypadContextProvider into math-input
|
|
12
|
+
- 14138bb0: Hoist keypad active state into keypad context
|
|
13
|
+
- 332d5d6d: Fix list item rendering in exercises and HintRenderer (LC-1022 & LC-1225)
|
|
14
|
+
- Updated dependencies [14138bb0]
|
|
15
|
+
- Updated dependencies [14138bb0]
|
|
16
|
+
- @khanacademy/math-input@14.0.0
|
|
17
|
+
|
|
3
18
|
## 11.5.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/es/index.css
CHANGED
|
@@ -10,6 +10,12 @@ var {
|
|
|
10
10
|
font-style: normal;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.hint.last-hint {
|
|
14
|
+
.paragraph {
|
|
15
|
+
font-weight: bold;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
.hint_blue {
|
|
14
20
|
color: #6495ed;
|
|
15
21
|
}
|
|
@@ -32,10 +38,6 @@ var {
|
|
|
32
38
|
color: #9d38bd;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
.last-hint {
|
|
36
|
-
font-weight: bold;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
41
|
div.subhint {
|
|
40
42
|
border: 1px solid #aaaaaa;
|
|
41
43
|
background: #f9f9f9;
|
|
@@ -2393,8 +2395,6 @@ img.zoom-img {
|
|
|
2393
2395
|
margin: -11px 0px 22px 0px;
|
|
2394
2396
|
}
|
|
2395
2397
|
.framework-perseus .paragraph ul:not(.perseus-widget-radio) {
|
|
2396
|
-
font-size: 14px;
|
|
2397
|
-
line-height: 19.6px;
|
|
2398
2398
|
padding-left: 35px;
|
|
2399
2399
|
list-style-type: disc;
|
|
2400
2400
|
}
|
package/dist/es/index.js
CHANGED
|
@@ -21554,27 +21554,39 @@ class NumericInput extends React.Component {
|
|
|
21554
21554
|
}
|
|
21555
21555
|
return answerStrings[0];
|
|
21556
21556
|
}
|
|
21557
|
-
static validate(
|
|
21558
|
-
const
|
|
21557
|
+
static validate(userInput, rubric) {
|
|
21558
|
+
const defaultAnswerForms = answerFormButtons.map(e => e["value"])
|
|
21559
21559
|
// Don't default to validating the answer as a pi answer
|
|
21560
21560
|
// if answerForm isn't set on the answer
|
|
21561
21561
|
// https://khanacademy.atlassian.net/browse/LC-691
|
|
21562
21562
|
.filter(e => e !== "pi");
|
|
21563
21563
|
const createValidator = answer => {
|
|
21564
|
+
var _answer$answerForms;
|
|
21564
21565
|
const stringAnswer = `${answer.value}`;
|
|
21566
|
+
|
|
21567
|
+
// Always validate against the provided answer forms (pi, decimal, etc.)
|
|
21568
|
+
const validatorForms = [...((_answer$answerForms = answer.answerForms) != null ? _answer$answerForms : [])];
|
|
21569
|
+
|
|
21570
|
+
// When an answer is set to strict, we validate using ONLY
|
|
21571
|
+
// the provided answerForms. If strict is false, or if there
|
|
21572
|
+
// were no provided answer forms, we will include all
|
|
21573
|
+
// of the default answer forms in our validator.
|
|
21574
|
+
if (!answer.strict || validatorForms.length === 0) {
|
|
21575
|
+
validatorForms.push(...defaultAnswerForms);
|
|
21576
|
+
}
|
|
21565
21577
|
return KhanAnswerTypes.number.createValidatorFunctional(stringAnswer, {
|
|
21566
21578
|
message: answer.message,
|
|
21567
21579
|
simplify: answer.status === "correct" ? answer.simplify : "optional",
|
|
21568
21580
|
inexact: true,
|
|
21569
21581
|
// TODO(merlob) backfill / delete
|
|
21570
21582
|
maxError: answer.maxError,
|
|
21571
|
-
forms:
|
|
21583
|
+
forms: validatorForms
|
|
21572
21584
|
});
|
|
21573
21585
|
};
|
|
21574
21586
|
|
|
21575
21587
|
// We may have received TeX; try to parse it before grading.
|
|
21576
21588
|
// If `currentValue` is not TeX, this should be a no-op.
|
|
21577
|
-
const currentValue = ParseTex(
|
|
21589
|
+
const currentValue = ParseTex(userInput.currentValue);
|
|
21578
21590
|
const correctAnswers = rubric.answers.filter(answer => answer.status === "correct");
|
|
21579
21591
|
const normalizedAnswerExpected = correctAnswers.every(answer => Math.abs(answer.value) <= 1);
|
|
21580
21592
|
|
|
@@ -44059,7 +44071,7 @@ class HintRenderer extends React.Component {
|
|
|
44059
44071
|
const {
|
|
44060
44072
|
isMobile
|
|
44061
44073
|
} = apiOptions;
|
|
44062
|
-
const classNames$1 = classNames(!isMobile && "perseus-hint-renderer", isMobile && css(styles$5.newHint), isMobile && lastRendered && css(styles$5.lastRenderedNewHint), lastHint && "last-hint", lastRendered && "last-rendered", className);
|
|
44074
|
+
const classNames$1 = classNames("hint", !isMobile && "perseus-hint-renderer", isMobile && css(styles$5.newHint), isMobile && lastRendered && css(styles$5.lastRenderedNewHint), lastHint && "last-hint", lastRendered && "last-rendered", className);
|
|
44063
44075
|
|
|
44064
44076
|
// TODO(charlie): Allowing `customKeypad` would require that we
|
|
44065
44077
|
// extend `ItemRenderer` to support nested inputs in the `HintsRenderer`.
|