@khanacademy/perseus-score 2.3.7 → 4.0.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/dist/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _extends from '@babel/runtime/helpers/extends';
2
2
  import * as KAS from '@khanacademy/kas';
3
- import { KhanMath, number, geometry, angles, coefficients } from '@khanacademy/kmath';
3
+ import { KhanMath, geometry, angles, coefficients, number } from '@khanacademy/kmath';
4
4
  import { PerseusError, Errors, getDecimalSeparator, GrapherUtil, approximateDeepEqual, approximateEqual, deepClone, getMatrixSize, getWidgetIdsFromContent, getUpgradedWidgetOptions } from '@khanacademy/perseus-core';
5
5
  import _ from 'underscore';
6
6
 
@@ -858,8 +858,10 @@ function scoreExpression(userInput, rubric, locale) {
858
858
  let matchMessage;
859
859
  let allEmpty = true;
860
860
  let firstUngradedResult;
861
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
861
862
  for (const answerForm of rubric.answerForms || []) {
862
863
  const validator = createValidator(answerForm);
864
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
863
865
  if (!validator) {
864
866
  continue;
865
867
  }
@@ -1220,6 +1222,7 @@ function scoreInteractiveGraph(userInput, rubric) {
1220
1222
  let match;
1221
1223
  if (rubric.correct.match === "congruent") {
1222
1224
  const angles = _.map([guess, correct], function (coords) {
1225
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
1223
1226
  if (!coords) {
1224
1227
  return false;
1225
1228
  }
@@ -1382,7 +1385,9 @@ function scoreNumberLine(userInput, rubric) {
1382
1385
  const start = rubric.initialX != null ? rubric.initialX : range[0];
1383
1386
  const startRel = rubric.isInequality ? "ge" : "eq";
1384
1387
  const correctRel = rubric.correctRel || "eq";
1385
- const correctPos = number.equal(userInput.numLinePosition, rubric.correctX || 0);
1388
+ const correctPos = number.equal(userInput.numLinePosition,
1389
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
1390
+ rubric.correctX || 0);
1386
1391
  if (correctPos && correctRel === userInput.rel) {
1387
1392
  return {
1388
1393
  type: "points",
@@ -1530,6 +1535,7 @@ function walkTex(tex, handler) {
1530
1535
  currentIndex = secondParsedExpression.endpoint + 1;
1531
1536
 
1532
1537
  // Add expressions to running total of parsed expressions
1538
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
1533
1539
  if (parsedString.length) {
1534
1540
  parsedString += " ";
1535
1541
  }
@@ -1682,9 +1688,7 @@ function scoreNumericInput(userInput, rubric) {
1682
1688
  const result = (matchedAnswer == null ? void 0 : matchedAnswer.status) === "correct" ? matchedAnswer.score : {
1683
1689
  empty: (matchedAnswer == null ? void 0 : matchedAnswer.status) === "ungraded",
1684
1690
  correct: (matchedAnswer == null ? void 0 : matchedAnswer.status) === "correct",
1685
- message: (_matchedAnswer$messag = matchedAnswer == null ? void 0 : matchedAnswer.message) != null ? _matchedAnswer$messag : null,
1686
- guess: localValue
1687
- };
1691
+ message: (_matchedAnswer$messag = matchedAnswer == null ? void 0 : matchedAnswer.message) != null ? _matchedAnswer$messag : null};
1688
1692
  if (result.empty) {
1689
1693
  return {
1690
1694
  type: "invalid",
@@ -1864,6 +1868,8 @@ function validateTable(userInput) {
1864
1868
  return cell === "";
1865
1869
  });
1866
1870
  });
1871
+
1872
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
1867
1873
  if (hasEmptyCell || !supplied.length) {
1868
1874
  return {
1869
1875
  type: "invalid",
@@ -2005,6 +2011,7 @@ function scoreNoop(points = 0) {
2005
2011
  }
2006
2012
 
2007
2013
  // The `group` widget is basically a widget hosting a full Perseus system in
2014
+
2008
2015
  // it. As such, scoring a group means scoring all widgets it contains.
2009
2016
  function scoreGroup(userInput, rubric, locale) {
2010
2017
  const scores = scoreWidgetsFunctional(rubric.widgets, Object.keys(rubric.widgets), userInput, locale);