@khanacademy/perseus 38.0.0 → 38.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
@@ -21900,7 +21900,7 @@ const answerTypes = {
21900
21900
  forms: "pi"
21901
21901
  }
21902
21902
  };
21903
- function inputNumberValidator(state, rubric, strings) {
21903
+ function inputNumberValidator(userInput, rubric, strings) {
21904
21904
  if (rubric.answerType == null) {
21905
21905
  rubric.answerType = "number";
21906
21906
  }
@@ -21918,7 +21918,7 @@ function inputNumberValidator(state, rubric, strings) {
21918
21918
 
21919
21919
  // We may have received TeX; try to parse it before grading.
21920
21920
  // If `currentValue` is not TeX, this should be a no-op.
21921
- const currentValue = ParseTex$1(state.currentValue);
21921
+ const currentValue = ParseTex$1(userInput.currentValue);
21922
21922
  const result = val(currentValue);
21923
21923
 
21924
21924
  // TODO(eater): Seems silly to translate result to this invalid/points
@@ -39035,10 +39035,12 @@ function scoreMarker(marker) {
39035
39035
  }
39036
39036
  return score;
39037
39037
  }
39038
- function labelImageValidator(state, rubric) {
39038
+
39039
+ // TODO(LEMS-2440): May need to pull answers out of PerseusLabelImageWidgetOptions[markers] for the rubric
39040
+ function labelImageValidator(userInput, rubric) {
39039
39041
  let numAnswered = 0;
39040
39042
  let numCorrect = 0;
39041
- for (const marker of state.markers) {
39043
+ for (const marker of userInput.markers) {
39042
39044
  const score = scoreMarker(marker);
39043
39045
  if (score.hasAnswers) {
39044
39046
  numAnswered++;
@@ -39049,7 +39051,7 @@ function labelImageValidator(state, rubric) {
39049
39051
  }
39050
39052
 
39051
39053
  // We expect all question markers to be answered before grading.
39052
- if (numAnswered !== state.markers.length) {
39054
+ if (numAnswered !== userInput.markers.length) {
39053
39055
  return {
39054
39056
  type: "invalid",
39055
39057
  message: null
@@ -39059,7 +39061,7 @@ function labelImageValidator(state, rubric) {
39059
39061
  type: "points",
39060
39062
  // Markers with no expected answers are graded as correct if user
39061
39063
  // makes no answer selection.
39062
- earned: numCorrect === state.markers.length ? 1 : 0,
39064
+ earned: numCorrect === userInput.markers.length ? 1 : 0,
39063
39065
  total: 1,
39064
39066
  message: null
39065
39067
  };
@@ -39532,6 +39534,8 @@ class LabelImage extends React__namespace.Component {
39532
39534
  markers
39533
39535
  };
39534
39536
  }
39537
+
39538
+ // TODO(LEMS-2544): Investigate impact on scoring; possibly pull out &/or remove rubric parameter.
39535
39539
  showRationalesForCurrentlySelectedChoices(rubric) {
39536
39540
  const {
39537
39541
  markers
@@ -42450,10 +42454,12 @@ const TickMarks = Graphie.createSimpleClass((graphie, props) => {
42450
42454
  };
42451
42455
 
42452
42456
  // Generate an array of tick numbers:
42453
- // `Array(props.numDivisions)` makes an array of null values - one for every division marker
42457
+ // `Array(Math.round(numDivisions))` makes an array of null values - one for every division marker
42454
42458
  // `.keys()` gets the index values for each marker placeholder
42455
42459
  // `.map()` converts the index values into actual tick numbers
42456
- const initialTicks = [...Array(numDivisions).keys()].map(index => range[0] + index * tickStep);
42460
+ // NOTE: 'numDivisions' can sometimes be a non-integer (i.e. 7.000001).
42461
+ // Using Math.round() to ensure that an integer is used in the Array setup.
42462
+ const initialTicks = [...Array(Math.round(numDivisions)).keys()].map(index => range[0] + index * tickStep);
42457
42463
 
42458
42464
  // .sort() comparator
42459
42465
  const byNumericAscending = (a, b) => a - b;
@@ -45179,7 +45185,7 @@ const init = function (options) {
45179
45185
 
45180
45186
  // This file is processed by a Rollup plugin (replace) to inject the production
45181
45187
  const libName = "@khanacademy/perseus";
45182
- const libVersion = "38.0.0";
45188
+ const libVersion = "38.0.1";
45183
45189
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
45184
45190
 
45185
45191
  const apiVersion = {