@khanacademy/perseus 52.0.0 → 52.0.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/index.js CHANGED
@@ -109,213 +109,6 @@ function _extends() {
109
109
  * The translated strings that are used to render Perseus.
110
110
  */
111
111
 
112
- /**
113
- * Untranslated strings used in Perseus. To be used by an external
114
- * translator to produce translated strings, passed in as `PerseusStrings`.
115
- * !! Note: Ensure that all escape sequences are double-escaped. (e.g. `\\text` -> `\\\\text`)
116
- */
117
- const strings = {
118
- closeKeypad: "close math keypad",
119
- openKeypad: "open math keypad",
120
- mathInputBox: "Math input box",
121
- removeHighlight: "Remove highlight",
122
- addHighlight: "Add highlight",
123
- hintPos: "Hint #%(pos)s",
124
- errorRendering: "Error rendering: %(error)s",
125
- APPROXIMATED_PI_ERROR: "Your answer is close, but you may " + "have approximated pi. Enter your " + "answer as a multiple of pi, like " + "12 pi or " + "2/3 pi",
126
- EXTRA_SYMBOLS_ERROR: "We could not understand your " + "answer. Please check your answer for extra " + "text or symbols.",
127
- NEEDS_TO_BE_SIMPLFIED_ERROR: "Your answer is almost correct, " + "but it needs to be simplified.",
128
- MISSING_PERCENT_ERROR: "Your answer is almost correct, " + "but it is missing a " + "<code>\\\\%</code> at the end.",
129
- MULTIPLICATION_SIGN_ERROR: "I'm a computer. I only understand " + "multiplication if you use an asterisk " + "(*) as the multiplication sign.",
130
- WRONG_CASE_ERROR: "Your answer includes use of a variable with the wrong case.",
131
- WRONG_LETTER_ERROR: "Your answer includes a wrong variable letter.",
132
- invalidSelection: "Make sure you select something for every row.",
133
- ERROR_TITLE: "Oops!",
134
- ERROR_MESSAGE: "Sorry, I don't understand that!",
135
- hints: "Hints",
136
- getAnotherHint: "Get another hint",
137
- deprecatedStandin: "Sorry, this part of the question is no longer available. 😅 Don't worry, you won't be graded on this part. Keep going!",
138
- keepTrying: "Keep trying",
139
- tryAgain: "Try again",
140
- check: "Check",
141
- correctExcited: "Correct!",
142
- nextQuestion: "Next question",
143
- skipToTitle: "Skip to %(title)s",
144
- current: "Current",
145
- correct: "Correct",
146
- correctSelected: "Correct (selected)",
147
- correctCrossedOut: "Correct (but you crossed it out)",
148
- incorrect: "Incorrect",
149
- incorrectSelected: "Incorrect (selected)",
150
- hideExplanation: "Hide explanation",
151
- explain: "Explain",
152
- INVALID_MESSAGE_PREFIX: "We couldn't grade your answer.",
153
- DEFAULT_INVALID_MESSAGE_1: "It looks like you left something blank or ",
154
- DEFAULT_INVALID_MESSAGE_2: "entered in an invalid answer.",
155
- integerExample: "an integer, like $6$",
156
- properExample: "a *proper* fraction, like $1/2$ or $6/10$",
157
- simplifiedProperExample: "a *simplified proper* fraction, like $3/5$",
158
- improperExample: "an *improper* fraction, like $10/7$ or $14/8$",
159
- simplifiedImproperExample: "a *simplified improper* fraction, like $7/4$",
160
- mixedExample: "a mixed number, like $1\\\\ 3/4$",
161
- decimalExample: "an *exact* decimal, like $0.75$",
162
- percentExample: "a percent, like $12.34\\\\%$",
163
- piExample: "a multiple of pi, like $12$ pi or $2/3$ pi",
164
- yourAnswer: "**Your answer should be** ",
165
- yourAnswerLabel: "Your answer:",
166
- addPoints: "Click to add points",
167
- addVertices: "Click to add vertices",
168
- tapMultiple: "Tap each dot on the image to select all answers that apply.",
169
- tapSingle: "Tap each dot on the image to select an answer.",
170
- clickMultiple: "Click each dot on the image to select all answers that apply.",
171
- clickSingle: "Click each dot on the image to select an answer.",
172
- choices: "Choices:",
173
- answers: {
174
- one: "%(num)s answer",
175
- other: "%(num)s answers"
176
- },
177
- hideAnswersToggleLabel: "Hide answer choices",
178
- moves: {
179
- one: "Moves: %(num)s",
180
- other: "Moves: %(num)s"
181
- },
182
- clickTiles: "Click on the tiles to change the lights.",
183
- turnOffLights: "You must turn on all of the lights to continue.",
184
- fillAllCells: "Make sure you fill in all cells in the matrix.",
185
- molecularDrawing: "A molecular structure drawing. SMILES notation: %(content)s",
186
- switchDirection: "Switch direction",
187
- circleOpen: "Make circle open",
188
- circleFilled: "Make circle filled",
189
- numDivisions: "Number of divisions:",
190
- divisions: "Please make sure the number of divisions is in the range %(divRangeString)s.",
191
- lineRange: "lines %(lineRange)s",
192
- lineNumber: "line %(lineNumber)s",
193
- symbolPassage: "The symbol %(questionSymbol)s indicates that question %(questionNumber)s references this portion of the passage.",
194
- symbolQuestion: " The symbol %(sentenceSymbol)s indicates that the following sentence is referenced in a question.",
195
- lineLabel: {
196
- context: "a label next to a reading passage to denote the line number",
197
- message: "Line"
198
- },
199
- beginningPassage: "Beginning of reading passage.",
200
- beginningFootnotes: "Beginning of reading passage footnotes.",
201
- endPassage: "End of reading passage.",
202
- questionMarker: "[Marker for question %(number)s]",
203
- circleMarker: "[Circle marker %(number)s]",
204
- sentenceMarker: "[Sentence %(number)s]",
205
- dragHandles: "Drag handles to make graph",
206
- tapAddPoints: "Tap to add points",
207
- false: "False",
208
- true: "True",
209
- no: "No",
210
- yes: "Yes",
211
- chooseCorrectNum: "Please choose the correct number of answers.",
212
- notNoneOfTheAbove: "'None of the above' may not be selected when other answers are selected.",
213
- noneOfTheAbove: "None of the above",
214
- chooseNumAnswers: "Choose %(numCorrect)s answers:",
215
- chooseAllAnswers: "Choose all answers that apply:",
216
- chooseOneAnswer: "Choose 1 answer:",
217
- choiceCheckedCorrect: "(Choice %(letter)s, Checked, Correct)",
218
- choiceCrossedOutCorrect: "(Choice %(letter)s, Crossed out, Correct)",
219
- choiceCorrect: "(Choice %(letter)s, Correct)",
220
- choiceCheckedIncorrect: "(Choice %(letter)s, Checked, Incorrect)",
221
- choiceCrossedOutIncorrect: "(Choice %(letter)s, Crossed out, Incorrect)",
222
- choiceIncorrect: "(Choice %(letter)s, Incorrect)",
223
- choiceChecked: "(Choice %(letter)s, Checked)",
224
- choiceCrossedOut: "(Choice %(letter)s, Crossed out)",
225
- choice: "(Choice %(letter)s)",
226
- crossOut: "Cross out",
227
- crossOutOption: "Cross out option",
228
- crossOutChoice: "Cross out Choice %(letter)s",
229
- bringBack: "Bring back",
230
- openMenuForChoice: "Open menu for Choice %(letter)s",
231
- letters: {
232
- context: "This is a list of single-character labels that will appear in front of multiple-choice options. For instance, a multiple-choice question with three options would display (A) first option (B) second option (C) third option. There must be spaces between each of the different characters. The characters will show up next to options in the order that they are listed here. Most multiple choice questions have 5 or fewer options.",
233
- message: "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
234
- },
235
- rightArrow: "Reaction arrow pointing to the right.",
236
- dontUnderstandUnits: "I couldn't understand those units.",
237
- checkSigFigs: "Check your significant figures.",
238
- answerNumericallyIncorrect: "That answer is numerically incorrect.",
239
- checkUnits: "Check your units.",
240
- dontUnderstand: "I don't understand that",
241
- loading: "Loading...",
242
- videoTranscript: "See video transcript",
243
- somethingWrong: "Something went wrong.",
244
- videoWrapper: "Khan Academy video wrapper",
245
- mathInputTitle: "mathematics keyboard",
246
- mathInputDescription: "Use keyboard/mouse to interact with math-based input fields",
247
- sin: "sin",
248
- cos: "cos",
249
- tan: "tan",
250
- simulationLoadFail: "Sorry, this simulation cannot load.",
251
- simulationLocaleWarning: "Sorry, this simulation isn't available in your language.",
252
- selectAnAnswer: "Select an answer",
253
- // The following strings are used for interactive graph SR descriptions.
254
- addPoint: "Add Point",
255
- removePoint: "Remove Point",
256
- graphKeyboardPrompt: "Press Shift + Enter to interact with the graph",
257
- closePolygon: "Close shape",
258
- openPolygon: "Re-open shape",
259
- srInteractiveElements: "Interactive elements: %(elements)s",
260
- srNoInteractiveElements: "No interactive elements",
261
- // TODO(LEMS-2660): The following strings are ones that will need
262
- // translation tickets after all interactive graph SR strings have
263
- // been finalized. Remove this comment after the tickets have been
264
- // created.
265
- srPointAtCoordinates: "Point %(num)s at %(x)s comma %(y)s",
266
- srCircleGraph: "A circle on a coordinate plane.",
267
- srCircleShape: "Circle. The center point is at %(centerX)s comma %(centerY)s.",
268
- srCircleRadiusPoint: "Radius point at %(radiusPointX)s comma %(radiusPointY)s.",
269
- srCircleRadius: "Circle radius is %(radius)s.",
270
- srCircleOuterPoints: "Points on the circle at %(point1X)s comma %(point1Y)s, %(point2X)s comma %(point2Y)s, %(point3X)s comma %(point3Y)s, %(point4X)s comma %(point4Y)s.",
271
- srLinearGraph: "A line on a coordinate plane.",
272
- srLinearGraphPoints: "The line has two points, point 1 at %(point1X)s comma %(point1Y)s and point 2 at %(point2X)s comma %(point2Y)s.",
273
- srLinearGraphSlopeIncreasing: "Its slope increases from left to right.",
274
- srLinearGraphSlopeDecreasing: "Its slope decreases from left to right.",
275
- srLinearGraphSlopeHorizontal: "Its slope is zero.",
276
- srLinearGraphSlopeVertical: "Its slope is undefined.",
277
- srLinearGraphXOnlyIntercept: "The line crosses the X-axis at %(xIntercept)s comma 0.",
278
- srLinearGraphYOnlyIntercept: "The line crosses the Y-axis at 0 comma %(yIntercept)s.",
279
- srLinearGraphBothIntercepts: "The line crosses the X-axis at %(xIntercept)s comma 0 and the Y-axis at 0 comma %(yIntercept)s.",
280
- srLinearGraphOriginIntercept: "The line crosses the x and y axes at the graph's origin.",
281
- srLinearGrabHandle: "Line from %(point1X)s comma %(point1Y)s to %(point2X)s comma %(point2Y)s.",
282
- srAngleSideAtCoordinates: "Point %(point)s, %(side)s at %(x)s comma %(y)s",
283
- srAngleVertexAtCoordinatesWithAngleMeasure: "Point 2, vertex at %(x)s comma %(y)s. Angle %(angleMeasure)s degrees",
284
- srAngleGraphAriaLabel: "An angle on a coordinate plane.",
285
- srAngleGraphAriaDescription: "The angle measure is %(angleMeasure)s degrees with a vertex at %(vertexX)s comma %(vertexY)s, a point on the starting side at %(startingSideX)s comma %(startingSideY)s and a point on the ending side at %(endingSideX)s comma %(endingSideY)s",
286
- srSingleSegmentGraphAriaLabel: "A line segment on a coordinate plane.",
287
- srMultipleSegmentGraphAriaLabel: "%(countOfSegments)s line segments on a coordinate plane.",
288
- srMultipleSegmentIndividualLabel: "Segment %(indexOfSegment)s: Endpoint 1 at %(point1X)s comma %(point1Y)s. Endpoint 2 %(point2X)s comma %(point2Y)s.",
289
- srSingleSegmentLabel: "Endpoint 1 at %(point1X)s comma %(point1Y)s. Endpoint 2 %(point2X)s comma %(point2Y)s.",
290
- srSegmentLength: "Segment length %(length)s units.",
291
- srSingleSegmentGraphEndpointAriaLabel: "Endpoint %(endpointNumber)s at %(x)s comma %(y)s.",
292
- srMultipleSegmentGraphEndpointAriaLabel: "Endpoint %(endpointNumber)s on segment %(indexOfSegment)s at %(x)s comma %(y)s.",
293
- srSegmentGrabHandle: "Segment from %(point1X)s comma %(point1Y)s to %(point2X)s comma %(point2Y)s.",
294
- srLinearSystemGraph: "Two lines on a coordinate plane.",
295
- srLinearSystemPoints: "Line %(lineNumber)s has two points, point 1 at %(point1X)s comma %(point1Y)s and point 2 at %(point2X)s comma %(point2Y)s.",
296
- srLinearSystemPoint: "Point %(pointSequence)s on line %(lineNumber)s at %(x)s comma %(y)s.",
297
- srRayGraph: "A ray on a coordinate plane.",
298
- srRayPoints: "The endpoint is at %(point1X)s comma %(point1Y)s and the ray goes through point %(point2X)s comma %(point2Y)s.",
299
- srRayGrabHandle: "Ray with endpoint %(point1X)s comma %(point1Y)s going through point %(point2X)s comma %(point2Y)s.",
300
- srRayEndpoint: "Endpoint at %(x)s comma %(y)s.",
301
- srRayTerminalPoint: "Through point at %(x)s comma %(y)s.",
302
- srQuadraticGraph: "A parabola on a 4-quadrant coordinate plane.",
303
- srQuadraticFaceUp: "The parabola opens upward.",
304
- srQuadraticFaceDown: "The parabola opens downward.",
305
- srQuadraticGraphVertexOrigin: "Vertex is at the origin.",
306
- srQuadraticGraphVertexXAxis: "Vertex is on the X-axis.",
307
- srQuadraticGraphVertexYAxis: "Vertex is on the Y-axis.",
308
- srQuadraticGraphVertexQuadrant: "Vertex is in quadrant %(quadrant)s.",
309
- srQuadraticTwoXIntercepts: "The X-intercepts are at %(intercept1)s comma 0 and %(intercept2)s comma 0.",
310
- srQuadraticOneXIntercept: "The X-intercept is at %(intercept)s comma 0.",
311
- srQuadraticYIntercept: "The Y-intercept is at 0 comma %(intercept)s.",
312
- srQuadraticPointOrigin: "Point %(pointNumber)s on parabola at the origin.",
313
- srQuadraticPointAxis: "Point %(pointNumber)s on parabola at %(x)s comma %(y)s.",
314
- srQuadraticPointQuadrant: "Point %(pointNumber)s on parabola in quadrant %(quadrant)s at %(x)s comma %(y)s.",
315
- srQuadraticInteractiveElements: "Parabola with points at %(point1X)s comma %(point1Y)s, %(point2X)s comma %(point2Y)s, and %(point3X)s comma %(point3Y)s."
316
- // The above strings are used for interactive graph SR descriptions.
317
- };
318
-
319
112
  /**
320
113
  * Mock strings for the Perseus package, to be used for tests and Storybook.
321
114
  */
@@ -883,24 +676,32 @@ const mockStrings = {
883
676
 
884
677
  // This type helps us make sure all error codes are mapped to strings
885
678
 
679
+ /**
680
+ * Map an error string to a PerseusStrings key
681
+ * that we can use to get the translated error message
682
+ */
886
683
  const errorToString = {
887
- MISSING_PERCENT_ERROR: strings.MISSING_PERCENT_ERROR,
888
- NEEDS_TO_BE_SIMPLIFIED_ERROR: strings.NEEDS_TO_BE_SIMPLFIED_ERROR,
889
- APPROXIMATED_PI_ERROR: strings.APPROXIMATED_PI_ERROR,
890
- EXTRA_SYMBOLS_ERROR: strings.EXTRA_SYMBOLS_ERROR,
891
- WRONG_CASE_ERROR: strings.WRONG_CASE_ERROR,
892
- WRONG_LETTER_ERROR: strings.WRONG_LETTER_ERROR,
893
- MULTIPLICATION_SIGN_ERROR: strings.MULTIPLICATION_SIGN_ERROR,
894
- INVALID_SELECTION_ERROR: strings.invalidSelection,
895
- CHOOSE_CORRECT_NUM_ERROR: strings.chooseCorrectNum,
896
- NOT_NONE_ABOVE_ERROR: strings.notNoneOfTheAbove,
897
- FILL_ALL_CELLS_ERROR: strings.fillAllCells
898
- };
899
- function mapErrorToString(err) {
684
+ MISSING_PERCENT_ERROR: "MISSING_PERCENT_ERROR",
685
+ NEEDS_TO_BE_SIMPLIFIED_ERROR: "NEEDS_TO_BE_SIMPLFIED_ERROR",
686
+ APPROXIMATED_PI_ERROR: "APPROXIMATED_PI_ERROR",
687
+ EXTRA_SYMBOLS_ERROR: "EXTRA_SYMBOLS_ERROR",
688
+ WRONG_CASE_ERROR: "WRONG_CASE_ERROR",
689
+ WRONG_LETTER_ERROR: "WRONG_LETTER_ERROR",
690
+ MULTIPLICATION_SIGN_ERROR: "MULTIPLICATION_SIGN_ERROR",
691
+ INVALID_SELECTION_ERROR: "invalidSelection",
692
+ CHOOSE_CORRECT_NUM_ERROR: "chooseCorrectNum",
693
+ NOT_NONE_ABOVE_ERROR: "notNoneOfTheAbove",
694
+ FILL_ALL_CELLS_ERROR: "fillAllCells"
695
+ };
696
+ function mapErrorToString(
697
+ // the string representing an error code
698
+ err,
699
+ // the translated Perseus strings
700
+ translatedStrings) {
900
701
  if (!err) {
901
702
  return err;
902
703
  }
903
- return errorToString[err] || err;
704
+ return translatedStrings[errorToString[err]] || err;
904
705
  }
905
706
 
906
707
  /**
@@ -26442,7 +26243,7 @@ class GradedGroup extends React__namespace.Component {
26442
26243
  DEFAULT_INVALID_MESSAGE_2
26443
26244
  } = this.context.strings;
26444
26245
  const status = score.type === "points" ? score.total === score.earned ? GRADING_STATUSES.correct : GRADING_STATUSES.incorrect : GRADING_STATUSES.invalid;
26445
- const message = score.type === "points" ? score.message || "" : score.message ? `${INVALID_MESSAGE_PREFIX} ${mapErrorToString(score.message)}` : `${INVALID_MESSAGE_PREFIX} ${DEFAULT_INVALID_MESSAGE_1}${DEFAULT_INVALID_MESSAGE_2}`;
26246
+ const message = score.type === "points" ? score.message || "" : score.message ? `${INVALID_MESSAGE_PREFIX} ${mapErrorToString(score.message, this.context.strings)}` : `${INVALID_MESSAGE_PREFIX} ${DEFAULT_INVALID_MESSAGE_1}${DEFAULT_INVALID_MESSAGE_2}`;
26446
26247
  this.setState({
26447
26248
  status: status,
26448
26249
  message: message,
@@ -43520,7 +43321,7 @@ const init = function () {
43520
43321
 
43521
43322
  // This file is processed by a Rollup plugin (replace) to inject the production
43522
43323
  const libName = "@khanacademy/perseus";
43523
- const libVersion = "52.0.0";
43324
+ const libVersion = "52.0.1";
43524
43325
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
43525
43326
 
43526
43327
  const apiVersion = {