@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/es/index.js CHANGED
@@ -21676,7 +21676,7 @@ const answerTypes = {
21676
21676
  forms: "pi"
21677
21677
  }
21678
21678
  };
21679
- function inputNumberValidator(state, rubric, strings) {
21679
+ function inputNumberValidator(userInput, rubric, strings) {
21680
21680
  if (rubric.answerType == null) {
21681
21681
  rubric.answerType = "number";
21682
21682
  }
@@ -21694,7 +21694,7 @@ function inputNumberValidator(state, rubric, strings) {
21694
21694
 
21695
21695
  // We may have received TeX; try to parse it before grading.
21696
21696
  // If `currentValue` is not TeX, this should be a no-op.
21697
- const currentValue = ParseTex$1(state.currentValue);
21697
+ const currentValue = ParseTex$1(userInput.currentValue);
21698
21698
  const result = val(currentValue);
21699
21699
 
21700
21700
  // TODO(eater): Seems silly to translate result to this invalid/points
@@ -38693,10 +38693,12 @@ function scoreMarker(marker) {
38693
38693
  }
38694
38694
  return score;
38695
38695
  }
38696
- function labelImageValidator(state, rubric) {
38696
+
38697
+ // TODO(LEMS-2440): May need to pull answers out of PerseusLabelImageWidgetOptions[markers] for the rubric
38698
+ function labelImageValidator(userInput, rubric) {
38697
38699
  let numAnswered = 0;
38698
38700
  let numCorrect = 0;
38699
- for (const marker of state.markers) {
38701
+ for (const marker of userInput.markers) {
38700
38702
  const score = scoreMarker(marker);
38701
38703
  if (score.hasAnswers) {
38702
38704
  numAnswered++;
@@ -38707,7 +38709,7 @@ function labelImageValidator(state, rubric) {
38707
38709
  }
38708
38710
 
38709
38711
  // We expect all question markers to be answered before grading.
38710
- if (numAnswered !== state.markers.length) {
38712
+ if (numAnswered !== userInput.markers.length) {
38711
38713
  return {
38712
38714
  type: "invalid",
38713
38715
  message: null
@@ -38717,7 +38719,7 @@ function labelImageValidator(state, rubric) {
38717
38719
  type: "points",
38718
38720
  // Markers with no expected answers are graded as correct if user
38719
38721
  // makes no answer selection.
38720
- earned: numCorrect === state.markers.length ? 1 : 0,
38722
+ earned: numCorrect === userInput.markers.length ? 1 : 0,
38721
38723
  total: 1,
38722
38724
  message: null
38723
38725
  };
@@ -39186,6 +39188,8 @@ class LabelImage extends React.Component {
39186
39188
  markers
39187
39189
  };
39188
39190
  }
39191
+
39192
+ // TODO(LEMS-2544): Investigate impact on scoring; possibly pull out &/or remove rubric parameter.
39189
39193
  showRationalesForCurrentlySelectedChoices(rubric) {
39190
39194
  const {
39191
39195
  markers
@@ -42101,10 +42105,12 @@ const TickMarks = Graphie.createSimpleClass((graphie, props) => {
42101
42105
  };
42102
42106
 
42103
42107
  // Generate an array of tick numbers:
42104
- // `Array(props.numDivisions)` makes an array of null values - one for every division marker
42108
+ // `Array(Math.round(numDivisions))` makes an array of null values - one for every division marker
42105
42109
  // `.keys()` gets the index values for each marker placeholder
42106
42110
  // `.map()` converts the index values into actual tick numbers
42107
- const initialTicks = [...Array(numDivisions).keys()].map(index => range[0] + index * tickStep);
42111
+ // NOTE: 'numDivisions' can sometimes be a non-integer (i.e. 7.000001).
42112
+ // Using Math.round() to ensure that an integer is used in the Array setup.
42113
+ const initialTicks = [...Array(Math.round(numDivisions)).keys()].map(index => range[0] + index * tickStep);
42108
42114
 
42109
42115
  // .sort() comparator
42110
42116
  const byNumericAscending = (a, b) => a - b;
@@ -44827,7 +44833,7 @@ const init = function init(options) {
44827
44833
 
44828
44834
  // This file is processed by a Rollup plugin (replace) to inject the production
44829
44835
  const libName = "@khanacademy/perseus";
44830
- const libVersion = "38.0.0";
44836
+ const libVersion = "38.0.1";
44831
44837
  addLibraryVersionToPerseusDebug(libName, libVersion);
44832
44838
 
44833
44839
  const apiVersion = {