@khanacademy/perseus-score 7.0.0 → 7.0.2

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.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/error-codes.ts","../src/util/answer-types.ts","../src/widgets/categorizer/score-categorizer.ts","../src/widgets/categorizer/validate-categorizer.ts","../src/widgets/cs-program/score-cs-program.ts","../src/widgets/dropdown/score-dropdown.ts","../src/widgets/dropdown/validate-dropdown.ts","../src/widgets/expression/score-expression.ts","../src/widgets/expression/validate-expression.ts","../src/widgets/grapher/score-grapher.ts","../src/widgets/iframe/score-iframe.ts","../src/widgets/interactive-graph/score-interactive-graph.ts","../src/widgets/label-image/score-label-image.ts","../src/widgets/matcher/score-matcher.ts","../src/widgets/matrix/score-matrix.ts","../src/widgets/matrix/validate-matrix.ts","../src/widgets/number-line/score-number-line.ts","../src/widgets/number-line/validate-number-line.ts","../src/util/tex-wrangler.ts","../src/widgets/numeric-input/score-numeric-input.ts","../src/widgets/orderer/score-orderer.ts","../src/widgets/orderer/validate-orderer.ts","../src/widgets/plotter/score-plotter.ts","../src/widgets/plotter/validate-plotter.ts","../src/widgets/radio/score-radio.ts","../src/widgets/radio/validate-radio.ts","../src/widgets/sorter/score-sorter.ts","../src/widgets/sorter/validate-sorter.ts","../src/widgets/table/utils.ts","../src/widgets/table/validate-table.ts","../src/widgets/table/score-table.ts","../src/widgets/input-number/score-input-number.ts","../src/util/score-noop.ts","../src/widgets/free-response/score-free-response.ts","../src/widgets/free-response/validate-free-response.ts","../src/widgets/group/score-group.ts","../src/validate.ts","../src/widgets/group/validate-group.ts","../src/widgets/label-image/validate-label-image.ts","../src/widgets/mock-widget/validate-mock-widget.ts","../src/widgets/mock-widget/score-mock-widget.ts","../src/widgets/widget-registry.ts","../src/score.ts","../src/has-empty-diner-widgets.ts"],"sourcesContent":["const APPROXIMATED_PI_ERROR = \"APPROXIMATED_PI_ERROR\";\nconst CHOOSE_CORRECT_NUM_ERROR = \"CHOOSE_CORRECT_NUM_ERROR\";\nconst EXTRA_SYMBOLS_ERROR = \"EXTRA_SYMBOLS_ERROR\";\nconst FILL_ALL_CELLS_ERROR = \"FILL_ALL_CELLS_ERROR\";\nconst INVALID_SELECTION_ERROR = \"INVALID_SELECTION_ERROR\";\nconst MISSING_PERCENT_ERROR = \"MISSING_PERCENT_ERROR\";\nconst MULTIPLICATION_SIGN_ERROR = \"MULTIPLICATION_SIGN_ERROR\";\nconst NEEDS_TO_BE_SIMPLIFIED_ERROR = \"NEEDS_TO_BE_SIMPLIFIED_ERROR\";\nconst NOT_NONE_ABOVE_ERROR = \"NOT_NONE_ABOVE_ERROR\";\nconst USER_INPUT_EMPTY = \"USER_INPUT_EMPTY\";\nconst WRONG_CASE_ERROR = \"WRONG_CASE_ERROR\";\nconst WRONG_LETTER_ERROR = \"WRONG_LETTER_ERROR\";\n\nconst ErrorCodes = {\n APPROXIMATED_PI_ERROR,\n CHOOSE_CORRECT_NUM_ERROR,\n EXTRA_SYMBOLS_ERROR,\n FILL_ALL_CELLS_ERROR,\n INVALID_SELECTION_ERROR,\n MISSING_PERCENT_ERROR,\n MULTIPLICATION_SIGN_ERROR,\n NEEDS_TO_BE_SIMPLIFIED_ERROR,\n NOT_NONE_ABOVE_ERROR,\n USER_INPUT_EMPTY,\n WRONG_CASE_ERROR,\n WRONG_LETTER_ERROR,\n};\n\nexport default ErrorCodes;\n","/* eslint-disable no-useless-escape */\nimport * as KAS from \"@khanacademy/kas\";\nimport {KhanMath} from \"@khanacademy/kmath\";\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport ErrorCodes from \"../error-codes\";\n\nconst MAXERROR_EPSILON = Math.pow(2, -42);\n\ntype Guess = any;\ntype Predicate = (guess: number, maxError: number) => boolean;\ntype TransformedFraction = {\n value: number;\n exact: boolean;\n};\n\n// TOOD(kevinb): Figure out how this relates to KEScore in\n// perseus-all-package/types.js and see if there's a way to\n// unify these types.\nexport type Score = {\n empty: boolean;\n correct: boolean;\n message: string | null | undefined;\n suppressAlmostThere?: boolean | null | undefined;\n guess: Guess;\n // It would be nice if we could ungraded required\n ungraded?: boolean;\n};\n\n/**\n * Answer types\n *\n * Utility for creating answerable questions displayed in exercises\n *\n * Different answer types produce different kinds of input displays, and do\n * different kinds of checking on the solutions.\n *\n * Each of the objects contain two functions, setup and createValidator.\n *\n * The setup function takes a solutionarea and solution, and performs setup\n * within the solutionarea, and then returns an object which contains:\n *\n * answer: a function which, when called, will retrieve the current answer from\n * the solutionarea, which can then be validated using the validator\n * function\n * validator: a function returned from the createValidator function (defined\n * below)\n * solution: the correct answer to the problem\n * showGuess: a function which, when given a guess, shows the guess within the\n * provided solutionarea\n * showGuessCustom: a function which displays parts of a guess that are not\n * within the solutionarea; currently only used for custom\n * answers\n *\n * The createValidator function only takes a solution, and it returns a\n * function which can be used to validate an answer.\n *\n * The resulting validator function returns:\n * - true: if the answer is fully correct\n * - false: if the answer is incorrect\n * - \"\" (the empty string): if no answer has been provided (e.g. the answer box\n * is left unfilled)\n * - a string: if there is some slight error\n *\n * In most cases, setup and createValidator don't really need the solution DOM\n * element so we have setupFunctional and createValidatorFunctional for them\n * which take only $solution.text() and $solution.data(). This makes it easier\n * to reuse specific answer types.\n *\n * TODO(alpert): Think of a less-absurd name for createValidatorFunctional.\n *\n */\nconst KhanAnswerTypes = {\n /*\n * predicate answer type\n *\n * performs simple predicate-based checking of a numeric solution, with\n * different kinds of number formats\n *\n * Uses the data-forms option on the solution to choose which number formats\n * are acceptable. Available data-forms:\n *\n * - integer: 3\n * - proper: 3/5\n * - improper: 5/3\n * - pi: 3 pi\n * - log: log(5)\n * - percent: 15%\n * - mixed: 1 1/3\n * - decimal: 1.7\n *\n * The solution should be a predicate of the form:\n *\n * function(guess, maxError) {\n * return abs(guess - 3) < maxError;\n * }\n *\n */\n predicate: {\n defaultForms: \"integer, proper, improper, mixed, decimal\",\n createValidatorFunctional: function (\n predicate: Predicate,\n options: any,\n ): (arg1: Guess) => Score {\n // Extract the options from the given solution object\n options = _.extend(\n {\n simplify: \"required\",\n ratio: false,\n forms: KhanAnswerTypes.predicate.defaultForms,\n },\n options,\n );\n let acceptableForms;\n // this is maintaining backwards compatibility\n // TODO(merlob) fix all places that depend on this, then delete\n if (!_.isArray(options.forms)) {\n acceptableForms = options.forms.split(/\\s*,\\s*/);\n } else {\n acceptableForms = options.forms;\n }\n\n // TODO(jack): remove options.inexact in favor of options.maxError\n if (options.inexact === undefined) {\n // If we aren't allowing inexact, ensure that we don't have a\n // large maxError as well.\n options.maxError = 0;\n }\n // Allow a small tolerance on maxError, to avoid numerical\n // representation issues (2.3 should be correct for a solution of\n // 2.45 with maxError=0.15).\n options.maxError = +options.maxError + MAXERROR_EPSILON;\n\n // If percent is an acceptable form, make sure it's the last one\n // in the list so we don't prematurely complain about not having\n // a percent sign when the user entered the correct answer in a\n // different form (such as a decimal or fraction)\n if (_.contains(acceptableForms, \"percent\")) {\n acceptableForms = _.without(acceptableForms, \"percent\");\n acceptableForms.push(\"percent\");\n }\n\n // Take text looking like a fraction, and turn it into a number\n const fractionTransformer = function (\n text,\n ): ReadonlyArray<TransformedFraction> {\n text = text\n // Replace unicode minus sign with hyphen\n .replace(/\\u2212/, \"-\")\n // Remove space after +, -\n .replace(/([+-])\\s+/g, \"$1\")\n // Remove leading/trailing whitespace\n .replace(/(^\\s*)|(\\s*$)/gi, \"\");\n\n // Extract numerator and denominator\n const match = text.match(/^([+-]?\\d+)\\s*\\/\\s*([+-]?\\d+)$/);\n // Fractions are represented as \"-\\frac{numerator}{denominator}\"\n // in Mobile device input instead of \"numerator/denominator\" as\n // in web-browser.\n const mobileDeviceMatch = text.match(\n /^([+-]?)\\\\frac\\{([+-]?\\d+)\\}\\{([+-]?\\d+)\\}$/,\n );\n const parsedInt = parseInt(text, 10);\n if (match || mobileDeviceMatch) {\n let num;\n let denom;\n let simplified = true;\n if (match) {\n num = parseFloat(match[1]);\n denom = parseFloat(match[2]);\n } else {\n num = parseFloat(mobileDeviceMatch[2]);\n if (mobileDeviceMatch[1] === \"-\") {\n if (num < 0) {\n simplified = false;\n }\n num = -num;\n }\n denom = parseFloat(mobileDeviceMatch[3]);\n }\n\n simplified =\n simplified &&\n denom > 0 &&\n (options.ratio || denom !== 1) &&\n KhanMath.getGCD(num, denom) === 1;\n return [\n {\n value: num / denom,\n exact: simplified,\n },\n ];\n }\n if (!isNaN(parsedInt) && \"\" + parsedInt === text) {\n return [\n {\n value: parsedInt,\n exact: true,\n },\n ];\n }\n\n return [];\n };\n\n /*\n * Different forms of numbers\n *\n * Each function returns a list of objects of the form:\n *\n * {\n * value: numerical value,\n * exact: true/false\n * }\n */\n const forms = {\n // integer, which is encompassed by decimal\n integer: function (text) {\n // Compare the decimal form to the decimal form rounded to\n // an integer. Only accept if the user actually entered an\n // integer.\n const decimal = forms.decimal(text);\n const rounded = forms.decimal(text, 1);\n if (\n (decimal[0].value != null &&\n decimal[0].value === rounded[0].value) ||\n (decimal[1].value != null &&\n decimal[1].value === rounded[1].value)\n ) {\n return decimal;\n }\n return [];\n },\n\n // A proper fraction\n proper: function (text) {\n const transformed = fractionTransformer(text);\n return transformed.flatMap((o: TransformedFraction) => {\n // All fractions that are less than 1\n if (Math.abs(o.value) < 1) {\n return [o];\n }\n return [];\n });\n },\n\n // an improper fraction\n improper: function (text) {\n // As our answer keys are always in simplest form, we need\n // to check for the existence of a fraction in the input before\n // validating the answer. If no fraction is found, we consider\n // the answer to be incorrect.\n const fractionExists: boolean =\n text.includes(\"/\") || text.match(/\\\\(d?frac)/);\n\n if (!fractionExists) {\n return [];\n }\n\n const transformed = fractionTransformer(text);\n return transformed.flatMap((o: TransformedFraction) => {\n // All fractions that are greater than 1\n if (Math.abs(o.value) >= 1) {\n return [o];\n }\n return [];\n });\n },\n\n // pi-like numbers\n pi: function (text) {\n let match;\n let possibilities: ReadonlyArray<any> = [];\n\n // Replace unicode minus sign with hyphen\n text = text.replace(/\\u2212/, \"-\");\n\n // - pi\n // (Note: we also support \\pi (for TeX), p, tau (and \\tau,\n // and t), pau.)\n if (\n (match = text.match(\n /^([+-]?)\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n possibilities = [\n {\n value: parseFloat(match[1] + \"1\"),\n exact: true,\n },\n ];\n\n // 5 / 6 pi\n } else if (\n (match = text.match(\n /^([+-]?\\s*\\d+\\s*(?:\\/\\s*[+-]?\\s*\\d+)?)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n possibilities = fractionTransformer(match[1]);\n\n // 4 5 / 6 pi\n } else if (\n (match = text.match(\n /^([+-]?)\\s*(\\d+)\\s*([+-]?\\d+)\\s*\\/\\s*([+-]?\\d+)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n const sign = parseFloat(match[1] + \"1\");\n const integ = parseFloat(match[2]);\n const num = parseFloat(match[3]);\n const denom = parseFloat(match[4]);\n const simplified =\n num < denom && KhanMath.getGCD(num, denom) === 1;\n\n possibilities = [\n {\n value: sign * (integ + num / denom),\n exact: simplified,\n },\n ];\n\n // 5 pi / 6\n } else if (\n (match = text.match(\n /^([+-]?\\s*\\d+)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)\\s*(?:\\/\\s*([+-]?\\s*\\d+))?$/i,\n ))\n ) {\n possibilities = fractionTransformer(\n match[1] + \"/\" + match[3],\n );\n\n // - pi / 4\n } else if (\n (match = text.match(\n /^([+-]?)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)\\s*(?:\\/\\s*([+-]?\\d+))?$/i,\n ))\n ) {\n possibilities = fractionTransformer(\n match[1] + \"1/\" + match[3],\n );\n\n // 0\n } else if (text === \"0\") {\n possibilities = [{value: 0, exact: true}];\n\n // 0.5 pi (fallback)\n } else if (\n (match = text.match(\n /^(.+)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n possibilities = forms.decimal(match[1]);\n } else {\n possibilities = _.reduce(\n KhanAnswerTypes.predicate.defaultForms.split(\n /\\s*,\\s*/,\n ),\n function (memo, form) {\n return memo.concat(forms[form](text));\n },\n [],\n );\n\n // If the answer is a floating point number that's\n // near a multiple of pi, mark is as being possibly\n // an approximation of pi. We actually check if\n // it's a plausible approximation of pi/12, since\n // sometimes the correct answer is like pi/3 or pi/4.\n // We also say it's a pi-approximation if it involves\n // x/7 (since 22/7 is an approximation of pi.)\n // Never mark an integer as being an approximation\n // of pi.\n let approximatesPi = false;\n const number = parseFloat(text);\n if (!isNaN(number) && number !== parseInt(text)) {\n const piMult = Math.PI / 12;\n const roundedNumber =\n piMult * Math.round(number / piMult);\n if (Math.abs(number - roundedNumber) < 0.01) {\n approximatesPi = true;\n }\n } else if (text.match(/\\/\\s*7/)) {\n approximatesPi = true;\n }\n if (approximatesPi) {\n _.each(possibilities, function (possibility) {\n possibility.piApprox = true;\n });\n }\n return possibilities;\n }\n\n let multiplier = Math.PI;\n if (text.match(/\\\\?tau|t|\\u03c4/)) {\n multiplier = Math.PI * 2;\n }\n\n // We're taking an early stand along side xkcd in the\n // inevitable ti vs. pau debate... http://xkcd.com/1292\n if (text.match(/pau/)) {\n multiplier = Math.PI * 1.5;\n }\n\n possibilities.forEach((possibility) => {\n possibility.value *= multiplier;\n });\n return possibilities;\n },\n\n // Converts '' to 1 and '-' to -1 so you can write \"[___] x\"\n // and accept sane things\n coefficient: function (text) {\n let possibilities:\n | Array<never>\n | Array<{\n exact: boolean;\n value: number;\n }> = [];\n\n // Replace unicode minus sign with hyphen\n text = text.replace(/\\u2212/, \"-\");\n\n if (text === \"\") {\n possibilities = [{value: 1, exact: true}];\n } else if (text === \"-\") {\n possibilities = [{value: -1, exact: true}];\n }\n return possibilities;\n },\n\n // simple log(c) form\n log: function (text) {\n let match;\n let possibilities = [];\n\n // Replace unicode minus sign with hyphen\n text = text.replace(/\\u2212/, \"-\");\n text = text.replace(/[ \\(\\)]/g, \"\");\n\n if ((match = text.match(/^log\\s*(\\S+)\\s*$/i))) {\n // @ts-expect-error - TS2322 - Type '{ value: number | undefined; exact: boolean; }[]' is not assignable to type 'never[]'.\n possibilities = forms.decimal(match[1]);\n } else if (text === \"0\") {\n // @ts-expect-error - TS2322 - Type 'number' is not assignable to type 'never'. | TS2322 - Type 'boolean' is not assignable to type 'never'.\n possibilities = [{value: 0, exact: true}];\n }\n return possibilities;\n },\n\n // Numbers with percent signs\n percent: function (text) {\n text = String(text).trim();\n // store whether or not there is a percent sign\n let hasPercentSign = false;\n\n if (text.indexOf(\"%\") === text.length - 1) {\n text = text.substring(0, text.length - 1).trim();\n hasPercentSign = true;\n }\n\n const transformed = forms.decimal(text);\n transformed.forEach((t) => {\n t.exact = hasPercentSign;\n // @ts-expect-error - TS2532 - Object is possibly 'undefined'.\n t.value = t.value / 100;\n });\n return transformed;\n },\n\n // Mixed numbers, like 1 3/4\n mixed: function (text) {\n const match = text\n // Replace unicode minus sign with hyphen\n .replace(/\\u2212/, \"-\")\n // Remove space after +, -\n .replace(/([+-])\\s+/g, \"$1\")\n // Extract integer, numerator and denominator\n .match(/^([+-]?)(\\d+)\\s+(\\d+)\\s*\\/\\s*(\\d+)$/);\n\n if (match) {\n const sign = parseFloat(match[1] + \"1\");\n const integ = parseFloat(match[2]);\n const num = parseFloat(match[3]);\n const denom = parseFloat(match[4]);\n const simplified =\n num < denom && KhanMath.getGCD(num, denom) === 1;\n\n return [\n {\n value: sign * (integ + num / denom),\n exact: simplified,\n },\n ];\n }\n\n return [];\n },\n\n // Decimal numbers -- compare entered text rounded to\n // 'precision' Reciprical of the precision against the correct\n // answer. We round to 1/1e10 by default, which is healthily\n // less than machine epsilon but should be more than any real\n // decimal answer would use. (The 'integer' answer type uses\n // precision == 1.)\n decimal: function (text: string, precision = 1e10) {\n const normal = function (text) {\n text = String(text).trim();\n\n const match = text\n // Replace unicode minus sign with hyphen\n .replace(/\\u2212/, \"-\")\n // Remove space after +, -\n .replace(/([+-])\\s+/g, \"$1\")\n // Extract integer, numerator and denominator. If\n // commas or spaces are used, they must be in the\n // \"correct\" places\n .match(\n /^([+-]?(?:\\d{1,3}(?:[, ]?\\d{3})*\\.?|\\d{0,3}(?:[, ]?\\d{3})*\\.(?:\\d{3}[, ]?)*\\d{1,3}))$/,\n );\n\n // You can't start a number with `0,`, to prevent us\n // interpeting '0.342' as correct for '342'\n const badLeadingZero = text.match(/^0[0,]*,/);\n\n if (match && !badLeadingZero) {\n let x = parseFloat(match[1].replace(/[, ]/g, \"\"));\n\n if (options.inexact === undefined) {\n x = Math.round(x * precision) / precision;\n }\n\n return x;\n }\n };\n\n const commas = function (text: string) {\n text = text.replace(/([\\.,])/g, function (_, c) {\n return c === \".\" ? \",\" : \".\";\n });\n return normal(text);\n };\n\n return [\n {value: normal(text), exact: true},\n {value: commas(text), exact: true},\n ];\n },\n } as const;\n\n // validator function\n return function (guess: Guess): Score {\n // The fallback variable is used in place of the answer, if no\n // answer is provided (i.e. the field is left blank)\n const fallback =\n options.fallback != null ? \"\" + options.fallback : \"\";\n\n guess = String(guess).trim() || fallback;\n\n const score: Score = {\n empty: guess === \"\",\n correct: false,\n message: null as string | null | undefined,\n guess: guess,\n };\n\n // Iterate over all the acceptable forms\n // and exit if one of the answers is correct.\n //\n // HACK: This function is a bug fix from LEMS-2962;\n // after a transition from jQuery's `each` to JS's `forEach`\n // we realized this code was banking on the ability to:\n // 1. exit early from nested loops (can be tricky outside of functions)\n // 2. mutate external variables (score)\n // Could probably be refactored to be a pure function that\n // returns a score, but this code is poorly tested and prone to break.\n const findCorrectAnswer = () => {\n // WARNING: Don't use `forEach` without additional refactoring\n // because code needs to be able to exit early\n for (const form of acceptableForms) {\n const transformed = forms[form](guess);\n for (let j = 0, l = transformed.length; j < l; j++) {\n const val = transformed[j].value;\n const exact = transformed[j].exact;\n const piApprox = transformed[j].piApprox;\n // If a string was returned, and it exactly matches,\n // return true\n if (predicate(val, options.maxError)) {\n // If the exact correct number was returned,\n // return true\n if (exact || options.simplify === \"optional\") {\n score.correct = true;\n score.message = options.message || null;\n // If the answer is correct, don't say it's\n // empty. This happens, for example, with the\n // coefficient type where guess === \"\" but is\n // interpreted as \"1\" which is correct.\n score.empty = false;\n } else if (form === \"percent\") {\n // Otherwise, an error was returned\n score.empty = true;\n score.message =\n ErrorCodes.MISSING_PERCENT_ERROR;\n } else {\n if (options.simplify !== \"enforced\") {\n score.empty = true;\n }\n score.message =\n ErrorCodes.NEEDS_TO_BE_SIMPLIFIED_ERROR;\n }\n // HACK: The return false below stops the looping of the\n // callback since predicate check succeeded.\n // No more forms to look to verify the user guess.\n return false;\n }\n if (\n piApprox &&\n predicate(val, Math.abs(val * 0.001))\n ) {\n score.empty = true;\n score.message =\n ErrorCodes.APPROXIMATED_PI_ERROR;\n }\n }\n }\n };\n\n // mutates `score`\n findCorrectAnswer();\n\n if (score.correct === false) {\n let interpretedGuess = false;\n _.each(forms, function (form) {\n const anyAreNaN = _.any(form(guess), function (t) {\n return t.value != null && !_.isNaN(t.value);\n });\n\n if (anyAreNaN) {\n interpretedGuess = true;\n }\n });\n if (!interpretedGuess) {\n score.empty = true;\n score.message = ErrorCodes.EXTRA_SYMBOLS_ERROR;\n return score;\n }\n }\n\n return score;\n };\n },\n },\n\n /*\n * number answer type\n *\n * wraps the predicate answer type to performs simple number-based checking\n * of a solution\n */\n number: {\n convertToPredicate: function (\n correctAnswer: string,\n options: any,\n ): [predicate: Predicate, options: any] {\n const correctFloat = parseFloat(correctAnswer);\n\n return [\n function (guess, maxError) {\n return Math.abs(guess - correctFloat) < maxError;\n },\n {\n ...options,\n type: \"predicate\",\n },\n ];\n },\n createValidatorFunctional: function (\n correctAnswer: string,\n options: any,\n ): (arg1: Guess) => Score {\n return KhanAnswerTypes.predicate.createValidatorFunctional(\n ...KhanAnswerTypes.number.convertToPredicate(\n correctAnswer,\n options,\n ),\n );\n },\n },\n\n /*\n * The expression answer type parses a given expression or equation\n * and semantically compares it to the solution. In addition, instant\n * feedback is provided by rendering the last answer that fully parsed.\n *\n * Parsing options:\n * functions (e.g. data-functions=\"f g h\")\n * A space or comma separated list of single-letter variables that\n * should be interpreted as functions. Case sensitive. \"e\" and \"i\"\n * are reserved.\n *\n * no functions specified: f(x+y) == fx + fy\n * with \"f\" as a function: f(x+y) != fx + fy\n *\n * Comparison options:\n * same-form (e.g. data-same-form)\n * If present, the answer must match the solution's structure in\n * addition to evaluating the same. Commutativity and excess negation\n * are ignored, but all other changes will trigger a rejection. Useful\n * for requiring a particular form of an equation, or if the answer\n * must be factored.\n *\n * example question: Factor x^2 + x - 2\n * example solution: (x-1)(x+2)\n * accepted answers: (x-1)(x+2), (x+2)(x-1), ---(-x-2)(-1+x), etc.\n * rejected answers: x^2+x-2, x*x+x-2, x(x+1)-2, (x-1)(x+2)^1, etc.\n * rejection message: Your answer is not in the correct form\n *\n * simplify (e.g. data-simplify)\n * If present, the answer must be fully expanded and simplified. Use\n * carefully - simplification is hard and there may be bugs, or you\n * might not agree on the definition of \"simplified\" used. You will\n * get an error if the provided solution is not itself fully expanded\n * and simplified.\n *\n * example question: Simplify ((n*x^5)^5) / (n^(-2)*x^2)^-3\n * example solution: x^31 / n\n * accepted answers: x^31 / n, x^31 / n^1, x^31 * n^(-1), etc.\n * rejected answers: (x^25 * n^5) / (x^(-6) * n^6), etc.\n * rejection message: Your answer is not fully expanded and simplified\n *\n * Rendering options:\n * times (e.g. data-times)\n * If present, explicit multiplication (such as between numbers) will\n * be rendered with a cross/x symbol (TeX: \\times) instead of the usual\n * center dot (TeX: \\cdot).\n *\n * normal rendering: 2 * 3^x -> 2 \\cdot 3^{x}\n * but with \"times\": 2 * 3^x -> 2 \\times 3^{x}\n */\n expression: {\n parseSolution: function (solutionString: string, options: any): any {\n let solution = KAS.parse(solutionString, options);\n if (!solution.parsed) {\n throw new PerseusError(\n \"The provided solution (\" +\n solutionString +\n \") didn't parse.\",\n Errors.InvalidInput,\n );\n } else if (options.simplified && !solution.expr.isSimplified()) {\n throw new PerseusError(\n \"The provided solution (\" +\n solutionString +\n \") isn't fully expanded and simplified.\",\n Errors.InvalidInput,\n );\n } else {\n solution = solution.expr;\n }\n return solution;\n },\n\n createValidatorFunctional: function (\n solution: any,\n options: any,\n ): (arg1: Guess) => Score {\n return function (guess: Guess): Score {\n const score = {\n empty: false,\n correct: false,\n message: null as string | null | undefined,\n guess: guess,\n // Setting `ungraded` to true indicates that if the\n // guess doesn't match any of the solutions, the guess\n // shouldn't be marked as incorrect; instead, `message`\n // should be shown to the user. This is different from\n // setting `empty` to true, since the behavior of `empty`\n // is that `message` only will be shown if the guess is\n // graded as empty for every solution.\n ungraded: false,\n } as const;\n\n // Don't bother parsing an empty input\n if (!guess) {\n // @ts-expect-error - TS2540 - Cannot assign to 'empty' because it is a read-only property.\n score.empty = true;\n return score;\n }\n\n const answer = KAS.parse(guess, options);\n\n // An unsuccessful parse doesn't count as wrong\n if (!answer.parsed) {\n // @ts-expect-error - TS2540 - Cannot assign to 'empty' because it is a read-only property.\n score.empty = true;\n return score;\n }\n\n // Solution will need to be parsed again if we're creating\n // this from a multiple question type\n if (typeof solution === \"string\") {\n solution = KhanAnswerTypes.expression.parseSolution(\n solution,\n options,\n );\n }\n\n const result = KAS.compare(answer.expr, solution, options);\n\n if (result.equal) {\n // Correct answer\n // @ts-expect-error - TS2540 - Cannot assign to 'correct' because it is a read-only property.\n score.correct = true;\n } else if (\n result.wrongVariableNames ||\n result.wrongVariableCase\n ) {\n // We don't want to give people an error for getting the\n // variable names or the variable case wrong.\n // TODO(aasmund): This should ideally have been handled\n // under the `result.message` condition, but the\n // KAS messages currently aren't translatable.\n // @ts-expect-error - TS2540 - Cannot assign to 'ungraded' because it is a read-only property.\n score.ungraded = true;\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message = result.wrongVariableCase\n ? ErrorCodes.WRONG_CASE_ERROR\n : ErrorCodes.WRONG_LETTER_ERROR;\n // Don't tell the use they're \"almost there\" in this case, that may not be true and isn't helpful.\n // @ts-expect-error - TS2339 - Property 'suppressAlmostThere' does not exist on type '{ readonly empty: false; readonly correct: false; readonly message: string | null | undefined; readonly guess: any; readonly ungraded: false; }'.\n score.suppressAlmostThere = true;\n } else if (result.message) {\n // Nearly correct answer\n // TODO(aasmund): This message also isn't translatable;\n // need to fix that in KAS\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message = result.message;\n } else {\n // Replace x with * and see if it would have been correct\n // TODO(aasmund): I think this branch is effectively dead,\n // because the replacement will only work in situations\n // where the variables are wrong (except if the variable\n // is x, in which case the replacement won't work either),\n // which is handled by another branch. When we implement a\n // more sophisticated variable check, revive this or\n // remove it completely if it will never come into play.\n const answerX = KAS.parse(\n guess.replace(/[xX]/g, \"*\"),\n options,\n );\n if (answerX.parsed) {\n const resultX = KAS.compare(\n answerX.expr,\n solution,\n options,\n );\n if (resultX.equal) {\n // @ts-expect-error - TS2540 - Cannot assign to 'ungraded' because it is a read-only property.\n score.ungraded = true;\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message =\n ErrorCodes.MULTIPLICATION_SIGN_ERROR;\n } else if (resultX.message) {\n // TODO(aasmund): I18nize `score.message`\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message =\n resultX.message +\n \" Also, I'm a computer. I only understand \" +\n \"multiplication if you use an \" +\n \"asterisk (*) as the multiplication \" +\n \"sign.\";\n }\n }\n }\n return score;\n };\n },\n },\n} as const;\n\nexport default KhanAnswerTypes;\n","import type {\n PerseusCategorizerRubric,\n PerseusCategorizerUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreCategorizer(\n userInput: PerseusCategorizerUserInput,\n rubric: PerseusCategorizerRubric,\n): PerseusScore {\n let allCorrect = true;\n rubric.values.forEach((value, i) => {\n if (userInput.values[i] !== value) {\n allCorrect = false;\n }\n });\n return {\n type: \"points\",\n earned: allCorrect ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreCategorizer;\n","import ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusCategorizerUserInput,\n PerseusCategorizerValidationData,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks userInput from the categorizer widget to see if the user has selected\n * a category for each item.\n * @param userInput - The user's input corresponding to an array of indices that\n * represent the selected category for each row/item.\n * @param validationData - An array of strings corresponding to each row/item\n * @param strings - Used to provide a validation message\n */\nfunction validateCategorizer(\n userInput: PerseusCategorizerUserInput,\n validationData: PerseusCategorizerValidationData,\n): ValidationResult {\n const incomplete = validationData.items.some(\n (_, i) => userInput.values[i] == null,\n );\n\n if (incomplete) {\n return {\n type: \"invalid\",\n message: ErrorCodes.INVALID_SELECTION_ERROR,\n };\n }\n return null;\n}\n\nexport default validateCategorizer;\n","import type {\n PerseusCSProgramUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreCSProgram(userInput: PerseusCSProgramUserInput): PerseusScore {\n // The CS program can tell us whether it's correct or incorrect,\n // and pass an optional message\n if (userInput.status === \"correct\") {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: userInput.message || null,\n };\n }\n if (userInput.status === \"incorrect\") {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: userInput.message || null,\n };\n }\n return {\n type: \"invalid\",\n message: \"Keep going, you're not there yet!\",\n };\n}\n\nexport default scoreCSProgram;\n","import type {\n PerseusDropdownRubric,\n PerseusDropdownUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreDropdown(\n userInput: PerseusDropdownUserInput,\n rubric: PerseusDropdownRubric,\n): PerseusScore {\n const correct = rubric.choices[userInput.value - 1].correct;\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreDropdown;\n","import type {\n PerseusDropdownUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks if the user has selected an item from the dropdown before scoring.\n * This is shown with a userInput value / index other than 0.\n */\nfunction validateDropdown(\n userInput: PerseusDropdownUserInput,\n): ValidationResult {\n if (userInput.value === 0) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return null;\n}\n\nexport default validateDropdown;\n","import * as KAS from \"@khanacademy/kas\";\nimport {\n Errors,\n getDecimalSeparator,\n PerseusError,\n} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport KhanAnswerTypes from \"../../util/answer-types\";\n\nimport type {Score} from \"../../util/answer-types\";\nimport type {\n PerseusExpressionRubric,\n PerseusExpressionUserInput,\n PerseusScore,\n PerseusExpressionAnswerForm,\n} from \"@khanacademy/perseus-core\";\n\n/* Content creators input a list of answers which are matched from top to\n * bottom. The intent is that they can include spcific solutions which should\n * be graded as correct or incorrect (or ungraded!) first, then get more\n * general.\n *\n * We iterate through each answer, trying to match it with the user's input\n * using the following angorithm:\n * - Try to parse the user's input. If it doesn't parse then return \"not\n * graded\".\n * - For each answer:\n * ~ Try to validate the user's input against the answer. The answer is\n * expected to parse.\n * ~ If the user's input validates (the validator judges it \"correct\"), we've\n * matched and can stop considering answers.\n * - If there were no matches or the matching answer is considered \"ungraded\",\n * show the user an error. TODO(joel) - what error?\n * - Otherwise, pass through the resulting points and message.\n */\nfunction scoreExpression(\n userInput: PerseusExpressionUserInput,\n rubric: PerseusExpressionRubric,\n locale: string,\n): PerseusScore {\n const options = _.clone(rubric);\n _.extend(options, {\n decimal_separator: getDecimalSeparator(locale),\n });\n\n const createValidator = (answer: PerseusExpressionAnswerForm) => {\n // We give options to KAS.parse here because it is parsing the\n // solution answer, not the student answer, and we don't want a\n // solution to work if the student is using a different language\n // (different from the content creation language, ie. English).\n const expression = KAS.parse(answer.value, rubric);\n // An answer may not be parsed if the expression was defined\n // incorrectly. For example if the answer is using a symbol defined\n // in the function variables list for the expression.\n if (!expression.parsed) {\n /* c8 ignore next */\n throw new PerseusError(\n \"Unable to parse solution answer for expression\",\n Errors.InvalidInput,\n {metadata: {rubric: JSON.stringify(rubric)}},\n );\n }\n\n return KhanAnswerTypes.expression.createValidatorFunctional(\n expression.expr,\n _({}).extend(options, {\n simplify: answer.simplify,\n form: answer.form,\n }),\n );\n };\n\n // Find the first answer form that matches the user's input and that\n // is considered correct. Also, track whether the input is\n // considered \"empty\" for all answer forms, and keep the validation\n // result for the first answer form for which the user's input was\n // considered \"ungraded\".\n // (Terminology reminder: the answer forms are provided by the\n // assessment items; they are not the user's input. Each one might\n // represent a correct answer, an incorrect one (if the exercise\n // creator has predicted certain common wrong answers and wants to\n // provide guidance via a message), or an ungraded one (same idea,\n // but without giving the user an incorrect mark for the question).\n let matchingAnswerForm: PerseusExpressionAnswerForm | undefined;\n let matchMessage: string | undefined;\n let allEmpty = true;\n let firstUngradedResult: Score | undefined;\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n for (const answerForm of rubric.answerForms || []) {\n const validator = createValidator(answerForm);\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!validator) {\n continue;\n }\n\n const result = validator(userInput);\n\n // Short-circuit as soon as the user's input matches some answer\n // (independently of whether the answer is correct)\n if (result.correct) {\n matchingAnswerForm = answerForm;\n matchMessage = result.message || \"\";\n break;\n }\n\n allEmpty = allEmpty && result.empty;\n // If this answer form is correct and the user's input is considered\n // \"ungraded\" for it, we'll want to keep the evaluation result for\n // later. If the user's input doesn't match any answer forms, we'll\n // show the message from this validation.\n if (\n answerForm.considered === \"correct\" &&\n result.ungraded &&\n !firstUngradedResult\n ) {\n firstUngradedResult = result;\n }\n }\n\n // Now check to see if we matched any answer form at all, and if\n // we did, whether it's considered correct, incorrect, or ungraded\n if (!matchingAnswerForm) {\n if (firstUngradedResult) {\n // While we didn't directly match with any answer form, we\n // did at some point get an \"ungraded\" validation result,\n // which might indicate e.g. a mismatch in variable casing.\n // We'll return \"invalid\", which will let the user try again\n // with no penalty, and the hopefully helpful validation\n // message.\n return {\n type: \"invalid\",\n message: firstUngradedResult.message,\n suppressAlmostThere: firstUngradedResult.suppressAlmostThere,\n };\n }\n if (allEmpty) {\n // If everything graded as empty, it's invalid.\n return {\n type: \"invalid\",\n message: null,\n };\n }\n // We fell through all the possibilities and we're not empty,\n // so the answer is considered incorrect.\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n };\n }\n if (matchingAnswerForm.considered === \"ungraded\") {\n return {\n type: \"invalid\",\n message: matchMessage,\n };\n }\n // We matched a graded answer form, so we can now tell the user\n // whether their input was correct or incorrect, and hand out\n // points accordingly\n return {\n type: \"points\",\n earned: matchingAnswerForm.considered === \"correct\" ? 1 : 0,\n total: 1,\n message: matchMessage,\n };\n}\n\nexport default scoreExpression;\n","import type {\n PerseusExpressionUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the expression widget to see if it is scorable.\n *\n * Note: Most of the expression widget's validation requires the Rubric because\n * of its use of KhanAnswerTypes as a core part of scoring.\n *\n * @see `scoreExpression()` for more details.\n */\nfunction validateExpression(\n userInput: PerseusExpressionUserInput,\n): ValidationResult {\n if (userInput === \"\") {\n return {type: \"invalid\", message: null};\n }\n\n return null;\n}\n\nexport default validateExpression;\n","import {Errors, PerseusError, GrapherUtil} from \"@khanacademy/perseus-core\";\n\nimport type {\n PerseusGrapherRubric,\n PerseusGrapherUserInput,\n PerseusScore,\n GrapherAnswerTypes,\n} from \"@khanacademy/perseus-core\";\n\nfunction getCoefficientsByType(\n data: GrapherAnswerTypes,\n): ReadonlyArray<number> | undefined {\n if (data.coords == null) {\n return undefined;\n }\n if (data.type === \"exponential\" || data.type === \"logarithm\") {\n const grader = GrapherUtil.functionForType(data.type);\n return grader.getCoefficients(data.coords, data.asymptote);\n } else if (\n data.type === \"linear\" ||\n data.type === \"quadratic\" ||\n data.type === \"absolute_value\" ||\n data.type === \"sinusoid\" ||\n data.type === \"tangent\"\n ) {\n const grader = GrapherUtil.functionForType(data.type);\n return grader.getCoefficients(data.coords);\n } else {\n throw new PerseusError(\"Invalid grapher type\", Errors.InvalidInput);\n }\n}\n\nfunction scoreGrapher(\n userInput: PerseusGrapherUserInput,\n rubric: PerseusGrapherRubric,\n): PerseusScore {\n if (userInput.type !== rubric.correct.type) {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n }\n\n // We haven't moved the coords\n if (userInput.coords == null) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n // Get new function handler for grading\n const grader = GrapherUtil.functionForType(userInput.type);\n const guessCoeffs = getCoefficientsByType(userInput);\n const correctCoeffs = getCoefficientsByType(rubric.correct);\n\n if (guessCoeffs == null || correctCoeffs == null) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n if (grader.areEqual(guessCoeffs, correctCoeffs)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreGrapher;\n","import type {\n PerseusIFrameUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n// TODO: merge this with scoreCSProgram, it's the same code\nfunction scoreIframe(userInput: PerseusIFrameUserInput): PerseusScore {\n // The iframe can tell us whether it's correct or incorrect,\n // and pass an optional message\n if (userInput.status === \"correct\") {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: userInput.message || null,\n };\n }\n if (userInput.status === \"incorrect\") {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: userInput.message || null,\n };\n }\n return {\n type: \"invalid\",\n message: \"Keep going, you're not there yet!\",\n };\n}\n\nexport default scoreIframe;\n","import {\n number as knumber,\n geometry,\n angles,\n coefficients,\n} from \"@khanacademy/kmath\";\nimport {\n approximateDeepEqual,\n approximateEqual,\n deepClone,\n} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusInteractiveGraphUserInput,\n PerseusInteractiveGraphRubric,\n PerseusScore,\n Coord,\n} from \"@khanacademy/perseus-core\";\n\nconst {collinear, canonicalSineCoefficients, similar, clockwise} = geometry;\nconst {getClockwiseAngle} = angles;\nconst {getSinusoidCoefficients, getQuadraticCoefficients} = coefficients;\n\nfunction scoreInteractiveGraph(\n userInput: PerseusInteractiveGraphUserInput,\n rubric: PerseusInteractiveGraphRubric,\n): PerseusScore {\n // None-type graphs are not graded\n if (userInput.type === \"none\" && rubric.correct.type === \"none\") {\n return {\n type: \"points\",\n earned: 0,\n total: 0,\n message: null,\n };\n }\n\n // When nothing has moved, there will neither be coords nor the\n // circle's center/radius fields. When those fields are absent, skip\n // all these checks; just go mark the answer as empty.\n const hasValue = Boolean(\n // @ts-expect-error - TS2339 - Property 'coords' does not exist on type 'PerseusGraphType'.\n userInput.coords ||\n // @ts-expect-error - TS2339 - Property 'center' does not exist on type 'PerseusGraphType'. | TS2339 - Property 'radius' does not exist on type 'PerseusGraphType'.\n (userInput.center && userInput.radius),\n );\n\n if (userInput.type === rubric.correct.type && hasValue) {\n if (\n userInput.type === \"linear\" &&\n rubric.correct.type === \"linear\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords;\n const correct = rubric.correct.coords;\n\n // If both of the guess points are on the correct line, it's\n // correct.\n if (\n collinear(correct[0], correct[1], guess[0]) &&\n collinear(correct[0], correct[1], guess[1])\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"linear-system\" &&\n rubric.correct.type === \"linear-system\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords;\n const correct = rubric.correct.coords;\n\n if (\n (collinear(correct[0][0], correct[0][1], guess[0][0]) &&\n collinear(correct[0][0], correct[0][1], guess[0][1]) &&\n collinear(correct[1][0], correct[1][1], guess[1][0]) &&\n collinear(correct[1][0], correct[1][1], guess[1][1])) ||\n (collinear(correct[0][0], correct[0][1], guess[1][0]) &&\n collinear(correct[0][0], correct[0][1], guess[1][1]) &&\n collinear(correct[1][0], correct[1][1], guess[0][0]) &&\n collinear(correct[1][0], correct[1][1], guess[0][1]))\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"quadratic\" &&\n rubric.correct.type === \"quadratic\" &&\n userInput.coords != null\n ) {\n // If the parabola coefficients match, it's correct.\n const guessCoeffs = getQuadraticCoefficients(userInput.coords);\n const correctCoeffs = getQuadraticCoefficients(\n rubric.correct.coords,\n );\n if (approximateDeepEqual(guessCoeffs, correctCoeffs)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"sinusoid\" &&\n rubric.correct.type === \"sinusoid\" &&\n userInput.coords != null\n ) {\n const guessCoeffs = getSinusoidCoefficients(userInput.coords);\n const correctCoeffs = getSinusoidCoefficients(\n rubric.correct.coords,\n );\n\n const canonicalGuessCoeffs = canonicalSineCoefficients(guessCoeffs);\n const canonicalCorrectCoeffs =\n canonicalSineCoefficients(correctCoeffs);\n // If the canonical coefficients match, it's correct.\n if (\n approximateDeepEqual(\n canonicalGuessCoeffs,\n canonicalCorrectCoeffs,\n )\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"circle\" &&\n rubric.correct.type === \"circle\"\n ) {\n if (\n approximateDeepEqual(userInput.center, rubric.correct.center) &&\n approximateEqual(userInput.radius, rubric.correct.radius)\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"point\" &&\n rubric.correct.type === \"point\" &&\n userInput.coords != null\n ) {\n let correct = rubric.correct.coords;\n if (correct == null) {\n throw new Error(\"Point graph rubric has null coords\");\n }\n const guess = userInput.coords.slice();\n correct = correct.slice();\n // Everything's already rounded so we shouldn't need to do an\n // eq() comparison but _.isEqual(0, -0) is false, so we'll use\n // eq() anyway. The sort should be fine because it'll stringify\n // it and -0 converted to a string is \"0\"\n // TODO(benchristel): once we drop support for Safari 15, use\n // toSorted here to avoid mutating the input arrays!\n guess?.sort();\n correct.sort();\n if (approximateDeepEqual(guess, correct)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"polygon\" &&\n rubric.correct.type === \"polygon\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords.slice();\n const correct = rubric.correct.coords.slice();\n\n let match;\n if (rubric.correct.match === \"similar\") {\n match = similar(guess, correct, Number.POSITIVE_INFINITY);\n } else if (rubric.correct.match === \"congruent\") {\n match = similar(guess, correct, knumber.DEFAULT_TOLERANCE);\n } else if (rubric.correct.match === \"approx\") {\n match = similar(guess, correct, 0.1);\n } else {\n /* exact */\n guess.sort();\n correct.sort();\n match = approximateDeepEqual(guess, correct);\n }\n\n if (match) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"segment\" &&\n rubric.correct.type === \"segment\" &&\n userInput.coords != null\n ) {\n let guess = deepClone(userInput.coords);\n let correct = deepClone(rubric.correct.coords);\n guess = _.invoke(guess, \"sort\").sort();\n correct = _.invoke(correct, \"sort\").sort();\n if (approximateDeepEqual(guess, correct)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"ray\" &&\n rubric.correct.type === \"ray\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords;\n const correct = rubric.correct.coords;\n if (\n approximateDeepEqual(guess[0], correct[0]) &&\n collinear(correct[0], correct[1], guess[1])\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"angle\" &&\n rubric.correct.type === \"angle\"\n ) {\n const coords = userInput.coords;\n const correct = rubric.correct.coords;\n const allowReflexAngles = rubric.correct.allowReflexAngles;\n\n // While the angle graph should always have 3 points, our types\n // technically allow for null values. We'll check for that here.\n // TODO: (LEMS-2857) We would like to update the type of coords\n // to be non-nullable, as the graph should always have 3 points.\n if (!coords) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n // We need to check both the direction of the angle and the\n // whether the graph allows for reflexive angles in order to\n // to determine if we need to reverse the coords for scoring.\n const areClockwise = clockwise([coords[0], coords[2], coords[1]]);\n const shouldReverseCoords = areClockwise && !allowReflexAngles;\n const guess = shouldReverseCoords\n ? (coords.slice().reverse() as [Coord, Coord, Coord])\n : coords;\n\n let match;\n if (rubric.correct.match === \"congruent\") {\n const angles = _.map([guess, correct], function (coords) {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!coords) {\n return false;\n }\n const angle = getClockwiseAngle(coords, allowReflexAngles);\n return angle;\n });\n // @ts-expect-error - TS2556 - A spread argument must either have a tuple type or be passed to a rest parameter.\n match = approximateEqual(...angles);\n } else {\n /* exact */\n match =\n approximateDeepEqual(guess[1], correct[1]) &&\n collinear(correct[1], correct[0], guess[0]) &&\n collinear(correct[1], correct[2], guess[2]);\n }\n\n if (match) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n }\n }\n\n // The input wasn't correct, so check if it's a blank input or if it's\n // actually just wrong\n if (!hasValue || _.isEqual(userInput, rubric.graph)) {\n // We're where we started.\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreInteractiveGraph;\n","import type {\n PerseusLabelImageUserInput,\n PerseusLabelImageRubric,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n// Question state for marker as result of user selected answers.\ntype InteractiveMarkerScore = {\n // Whether user selected answers for the marker.\n hasAnswers: boolean;\n // Whether user (answer) selection answered the question correctly.\n isCorrect: boolean;\n};\n\nexport function scoreLabelImageMarker(\n userInput: PerseusLabelImageUserInput[\"markers\"][number][\"selected\"],\n rubric: PerseusLabelImageRubric[\"markers\"][number][\"answers\"],\n): InteractiveMarkerScore {\n const score = {\n hasAnswers: false,\n isCorrect: false,\n };\n\n if (userInput && userInput.length > 0) {\n score.hasAnswers = true;\n }\n\n if (rubric.length > 0) {\n if (userInput && userInput.length === rubric.length) {\n // All correct answers are selected by the user.\n score.isCorrect = userInput.every((choice) =>\n rubric.includes(choice),\n );\n }\n } else if (!userInput || userInput.length === 0) {\n // Correct as no answers should be selected by the user.\n score.isCorrect = true;\n }\n\n return score;\n}\n\nfunction scoreLabelImage(\n userInput: PerseusLabelImageUserInput,\n rubric: PerseusLabelImageRubric,\n): PerseusScore {\n let numCorrect = 0;\n\n for (let i = 0; i < userInput.markers.length; i++) {\n const score = scoreLabelImageMarker(\n userInput.markers[i].selected,\n rubric.markers[i].answers,\n );\n\n if (score.isCorrect) {\n numCorrect++;\n }\n }\n\n return {\n type: \"points\",\n // Markers with no expected answers are graded as correct if user\n // makes no answer selection.\n earned: numCorrect === userInput.markers.length ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreLabelImage;\n","import _ from \"underscore\";\n\nimport type {\n PerseusMatcherRubric,\n PerseusMatcherUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreMatcher(\n userInput: PerseusMatcherUserInput,\n rubric: PerseusMatcherRubric,\n): PerseusScore {\n const correct =\n _.isEqual(userInput.left, rubric.left) &&\n _.isEqual(userInput.right, rubric.right);\n\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreMatcher;\n","import {getMatrixSize} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport KhanAnswerTypes from \"../../util/answer-types\";\n\nimport type {\n PerseusMatrixRubric,\n PerseusMatrixUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreMatrix(\n userInput: PerseusMatrixUserInput,\n rubric: PerseusMatrixRubric,\n): PerseusScore {\n const solution = rubric.answers;\n const supplied = userInput.answers;\n const solutionSize = getMatrixSize(solution);\n const suppliedSize = getMatrixSize(supplied);\n\n const incorrectSize =\n solutionSize[0] !== suppliedSize[0] ||\n solutionSize[1] !== suppliedSize[1];\n\n const createValidator = KhanAnswerTypes.number.createValidatorFunctional;\n let message = null;\n let incorrect = false;\n _(suppliedSize[0]).times((row) => {\n _(suppliedSize[1]).times((col) => {\n if (!incorrectSize) {\n const validator = createValidator(\n // @ts-expect-error - TS2345 - Argument of type 'number' is not assignable to parameter of type 'string'.\n solution[row][col],\n {\n simplify: true,\n },\n );\n const result = validator(supplied[row][col]);\n if (result.message) {\n // @ts-expect-error - TS2322 - Type 'string' is not assignable to type 'null'.\n message = result.message;\n }\n if (!result.correct) {\n incorrect = true;\n }\n }\n });\n });\n\n if (incorrectSize) {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n }\n\n return {\n type: \"points\",\n earned: incorrect ? 0 : 1,\n total: 1,\n message: message,\n };\n}\n\nexport default scoreMatrix;\n","import {getMatrixSize} from \"@khanacademy/perseus-core\";\n\nimport ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusMatrixUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the matrix widget to see if it is scorable.\n *\n * Note: The matrix widget cannot do much validation without the Scoring\n * Data because of its use of KhanAnswerTypes as a core part of scoring.\n *\n * @see `scoreMatrix()` for more details.\n */\nfunction validateMatrix(userInput: PerseusMatrixUserInput): ValidationResult {\n const supplied = userInput.answers;\n const suppliedSize = getMatrixSize(supplied);\n\n for (let row = 0; row < suppliedSize[0]; row++) {\n for (let col = 0; col < suppliedSize[1]; col++) {\n if (\n supplied[row][col] == null ||\n supplied[row][col].toString().length === 0\n ) {\n return {\n type: \"invalid\",\n message: ErrorCodes.FILL_ALL_CELLS_ERROR,\n };\n }\n }\n }\n\n return null;\n}\n\nexport default validateMatrix;\n","import {number as knumber} from \"@khanacademy/kmath\";\n\nimport type {\n PerseusNumberLineRubric,\n PerseusNumberLineUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreNumberLine(\n userInput: PerseusNumberLineUserInput,\n rubric: PerseusNumberLineRubric,\n): PerseusScore {\n const range = rubric.range;\n const start = rubric.initialX != null ? rubric.initialX : range[0];\n const startRel = rubric.isInequality ? \"ge\" : \"eq\";\n const correctRel = rubric.correctRel || \"eq\";\n const correctPos = knumber.equal(\n userInput.numLinePosition,\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n rubric.correctX || 0,\n );\n\n if (correctPos && correctRel === userInput.rel) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n if (userInput.numLinePosition === start && userInput.rel === startRel) {\n // We're where we started.\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreNumberLine;\n","import type {\n PerseusNumberLineUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input is within the allowed range and not the same as the initial\n * state.\n * @param userInput\n * @see 'scoreNumberLine' for the scoring logic.\n */\nfunction validateNumberLine(\n userInput: PerseusNumberLineUserInput,\n): Extract<PerseusScore, {type: \"invalid\"}> | null {\n const divisionRange = userInput.divisionRange;\n const outsideAllowedRange =\n userInput.numDivisions > divisionRange[1] ||\n userInput.numDivisions < divisionRange[0];\n\n // TODO: I don't think isTickCrtl is a thing anymore\n if (userInput.isTickCrtl && outsideAllowedRange) {\n return {\n type: \"invalid\",\n message: \"Number of divisions is outside the allowed range.\",\n };\n }\n return null;\n}\n\nexport default validateNumberLine;\n","/*\n * In this file, an `expression` is some portion of valid TeX enclosed in\n * curly brackets.\n */\n\n/*\n * Find the index at which an expression ends, i.e., has an unmatched\n * closing curly bracket. This method assumes that we start with a non-open\n * bracket character and end when we've seen more left than right brackets\n * (rather than assuming that we start with a bracket character and wait for\n * bracket equality).\n */\nfunction findEndpoint(tex, currentIndex: number) {\n let bracketDepth = 0;\n\n for (let i = currentIndex, len = tex.length; i < len; i++) {\n const c = tex[i];\n\n if (c === \"{\") {\n bracketDepth++;\n } else if (c === \"}\") {\n bracketDepth--;\n }\n\n if (bracketDepth < 0) {\n return i;\n }\n }\n // If we never see unbalanced curly brackets, default to the\n // entire string\n return tex.length;\n}\n\n/*\n * Parses an individual set of curly brackets into TeX.\n */\nfunction parseNextExpression(\n tex: string,\n currentIndex: number,\n handler: (exp1: string, exp2: string) => string,\n) {\n // Find the first '{' and grab subsequent TeX\n // Ex) tex: '{3}{7}', and we want the '3'\n const openBracketIndex = tex.indexOf(\"{\", currentIndex);\n\n // If there is no open bracket, set the endpoint to the end of the string\n // and the expression to an empty string. This helps ensure we don't\n // get stuck in an infinite loop when users handtype TeX.\n if (openBracketIndex === -1) {\n return {\n endpoint: tex.length,\n expression: \"\",\n };\n }\n\n const nextExpIndex = openBracketIndex + 1;\n\n // Truncate to only contain remaining TeX\n const endpoint = findEndpoint(tex, nextExpIndex);\n const expressionTeX = tex.substring(nextExpIndex, endpoint);\n\n const parsedExp = walkTex(expressionTeX, handler);\n\n return {\n endpoint: endpoint,\n expression: parsedExp,\n };\n}\n\nfunction getNextFracIndex(tex: string, currentIndex: number) {\n const dfrac = \"\\\\dfrac\";\n const frac = \"\\\\frac\";\n\n const nextFrac = tex.indexOf(frac, currentIndex);\n const nextDFrac = tex.indexOf(dfrac, currentIndex);\n\n if (nextFrac > -1 && nextDFrac > -1) {\n return Math.min(nextFrac, nextDFrac);\n }\n if (nextFrac > -1) {\n return nextFrac;\n }\n if (nextDFrac > -1) {\n return nextDFrac;\n }\n return -1;\n}\n\nfunction walkTex(\n tex: string,\n handler: (exp1: string, exp2: string) => string,\n): string {\n if (!tex) {\n return \"\";\n }\n\n // Ex) tex: '2 \\dfrac {3}{7}'\n let parsedString = \"\";\n let currentIndex = 0;\n let nextFrac = getNextFracIndex(tex, currentIndex);\n\n // For each \\dfrac, find the two expressions (wrapped in {}) and recur\n while (nextFrac > -1) {\n // Gather first fragment, preceding \\dfrac\n // Ex) parsedString: '2 '\n parsedString += tex.substring(currentIndex, nextFrac);\n\n // Remove everything preceding \\dfrac, which has been parsed\n currentIndex = nextFrac;\n\n // Parse first expression and move index past it\n // Ex) firstParsedExpression.expression: '3'\n const firstParsedExpression = parseNextExpression(\n tex,\n currentIndex,\n handler,\n );\n currentIndex = firstParsedExpression.endpoint + 1;\n\n // Parse second expression\n // Ex) secondParsedExpression.expression: '7'\n const secondParsedExpression = parseNextExpression(\n tex,\n currentIndex,\n handler,\n );\n currentIndex = secondParsedExpression.endpoint + 1;\n\n // Add expressions to running total of parsed expressions\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (parsedString.length) {\n parsedString += \" \";\n }\n\n // Apply a custom handler based on the parsed subexpressions\n parsedString += handler(\n firstParsedExpression.expression,\n secondParsedExpression.expression,\n );\n\n // Find next DFrac, relative to currentIndex\n nextFrac = getNextFracIndex(tex, currentIndex);\n }\n\n // Add remaining TeX, which is \\dfrac-free\n parsedString += tex.slice(currentIndex);\n\n return parsedString;\n}\n\n/*\n * Modify a TeX expression, returning another TeX expression. The resulting\n * expression will have its innermost fractions stubbed out with \\fracs\n * (as opposed to \\dfracs). All other content will remain untouched.\n */\nexport function modifyTex(tex: string): string {\n function isNestedFraction(tex: string) {\n return tex.indexOf(\"\\\\frac\") > -1 || tex.indexOf(\"\\\\dfrac\") > -1;\n }\n const handler = function (exp1: string, exp2: string) {\n let prefix;\n if (isNestedFraction(exp1) || isNestedFraction(exp2)) {\n prefix = \"\\\\dfrac\";\n } else {\n prefix = \"\\\\frac\";\n }\n return prefix + \" {\" + exp1 + \"}{\" + exp2 + \"}\";\n };\n return walkTex(tex, handler);\n}\n\n/*\n * Parse a TeX expression into something interpretable by input-number.\n * The process is concerned with: (1) parsing fractions, i.e., \\dfracs; and\n * (2) removing backslash-escaping from certain characters (right now, only\n * percent signs).\n *\n * The basic algorithm for handling \\dfracs splits on \\dfracs and then recurs\n * on the subsequent \"expressions\", i.e., the {} pairs that follow \\dfrac. The\n * recursion is to allow for nested \\dfrac elements.\n *\n * Backslash-escapes are removed with a simple search-and-replace.\n */\nexport function parseTex(tex: string): string {\n const handler = function (exp1: string, exp2: string) {\n return exp1 + \"/\" + exp2;\n };\n const texWithoutFracs = walkTex(tex, handler);\n return texWithoutFracs.replace(\"\\\\%\", \"%\");\n}\n","import KhanAnswerTypes from \"../../util/answer-types\";\nimport {parseTex} from \"../../util/tex-wrangler\";\n\nimport type {Score} from \"../../util/answer-types\";\nimport type {\n PerseusNumericInputRubric,\n PerseusNumericInputUserInput,\n PerseusScore,\n MathFormat,\n PerseusNumericInputAnswer,\n} from \"@khanacademy/perseus-core\";\n\nconst answerFormButtons: ReadonlyArray<{\n title: string;\n value: MathFormat;\n content: string;\n}> = [\n {title: \"Integers\", value: \"integer\", content: \"6\"},\n {title: \"Decimals\", value: \"decimal\", content: \"0.75\"},\n {title: \"Proper fractions\", value: \"proper\", content: \"\\u2157\"},\n {\n title: \"Improper fractions\",\n value: \"improper\",\n content: \"\\u2077\\u2044\\u2084\",\n },\n {title: \"Mixed numbers\", value: \"mixed\", content: \"1\\u00BE\"},\n {title: \"Numbers with \\u03C0\", value: \"pi\", content: \"\\u03C0\"},\n];\n\n// This function checks if the user inputted a percent value, parsing\n// it as a number (and maybe scaling) so that it can be graded.\n// NOTE(michaelpolyak): Unlike `KhanAnswerTypes.number.percent()` which\n// can accept several input forms with or without \"%\", the decision\n// to parse based on the presence of \"%\" in the input, is so that we\n// don't accidently scale the user typed value before grading, CP-930.\nexport function maybeParsePercentInput(\n inputValue: string | number,\n normalizedAnswerExpected: boolean,\n): string | number {\n // If the input value is not a string ending with \"%\", then there's\n // nothing more to do. The value will be graded as inputted by user.\n if (!(typeof inputValue === \"string\" && inputValue.endsWith(\"%\"))) {\n return inputValue;\n }\n\n const value = parseFloat(inputValue.slice(0, -1));\n // If the input value stripped of the \"%\" cannot be parsed as a\n // number (the slice is not really necessary for parseFloat to work\n // if the string starts with a number) then return the original\n // input for grading.\n if (isNaN(value)) {\n return inputValue;\n }\n\n // Next, if all correct answers are in the range of |0,1| then we\n // scale the user typed value. We assume this is the correct thing\n // to do since the input value ends with \"%\".\n if (normalizedAnswerExpected) {\n return value / 100;\n }\n\n // Otherwise, we return input value (number) stripped of the \"%\".\n return value;\n}\n\nfunction scoreNumericInput(\n userInput: PerseusNumericInputUserInput,\n rubric: PerseusNumericInputRubric,\n): PerseusScore {\n const defaultAnswerForms = answerFormButtons\n .map((e) => e[\"value\"])\n // Don't default to validating the answer as a pi answer\n // if answerForm isn't set on the answer\n // https://khanacademy.atlassian.net/browse/LC-691\n .filter((e) => e !== \"pi\");\n\n const createValidator = (answer: PerseusNumericInputAnswer) => {\n const stringAnswer = `${answer.value}`;\n\n // Always validate against the provided answer forms (pi, decimal, etc.)\n const validatorForms = [...(answer.answerForms ?? [])];\n\n // When an answer is set to strict, we validate using ONLY\n // the provided answerForms. If strict is false, or if there\n // were no provided answer forms, we will include all\n // of the default answer forms in our validator.\n if (!answer.strict || validatorForms.length === 0) {\n validatorForms.push(...defaultAnswerForms);\n }\n\n return KhanAnswerTypes.number.createValidatorFunctional(stringAnswer, {\n message: answer.message,\n simplify:\n answer.status === \"correct\" ? answer.simplify : \"optional\",\n inexact: true, // TODO(merlob) backfill / delete\n maxError: answer.maxError,\n forms: validatorForms,\n });\n };\n\n // We may have received TeX; try to parse it before grading.\n // If `currentValue` is not TeX, this should be a no-op.\n const currentValue = parseTex(userInput.currentValue);\n\n const normalizedAnswerExpected = rubric.answers\n .filter((answer) => answer.status === \"correct\")\n .every((answer) => answer.value != null && Math.abs(answer.value) <= 1);\n\n // The coefficient is an attribute of the widget\n let localValue: string | number = currentValue;\n if (rubric.coefficient) {\n if (!localValue) {\n localValue = 1;\n } else if (localValue === \"-\") {\n localValue = -1;\n }\n }\n const matchedAnswer:\n | (PerseusNumericInputAnswer & {score: Score})\n | undefined = rubric.answers\n .map((answer) => {\n const validateFn = createValidator(answer);\n const score = validateFn(\n maybeParsePercentInput(localValue, normalizedAnswerExpected),\n );\n return {...answer, score};\n })\n .find((answer) => {\n // NOTE: \"answer.score.correct\" indicates a match via the validate function.\n // It does NOT indicate that the answer itself is correct.\n return (\n answer.score.correct ||\n (answer.status === \"correct\" && answer.score.empty)\n );\n });\n\n const result: Score =\n matchedAnswer?.status === \"correct\"\n ? matchedAnswer.score\n : {\n empty: matchedAnswer?.status === \"ungraded\",\n correct: matchedAnswer?.status === \"correct\",\n message: matchedAnswer?.message ?? null,\n guess: localValue,\n };\n\n if (result.empty) {\n return {\n type: \"invalid\",\n message: result.message,\n };\n }\n return {\n type: \"points\",\n earned: result.correct ? 1 : 0,\n total: 1,\n message: result.message,\n };\n}\n\nexport default scoreNumericInput;\n","import _ from \"underscore\";\n\nimport type {\n PerseusOrdererRubric,\n PerseusOrdererUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreOrderer(\n userInput: PerseusOrdererUserInput,\n rubric: PerseusOrdererRubric,\n): PerseusScore {\n const correct = _.isEqual(\n userInput.current,\n rubric.correctOptions.map((option) => option.content),\n );\n\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreOrderer;\n","import type {\n PerseusOrdererUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the orderer widget to see if the user has started\n * ordering the options, making the widget scorable.\n * @param userInput\n * @see `scoreOrderer` for more details.\n */\nfunction validateOrderer(userInput: PerseusOrdererUserInput): ValidationResult {\n if (userInput.current.length === 0) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateOrderer;\n","import {approximateDeepEqual} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusPlotterUserInput,\n PerseusPlotterRubric,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scorePlotter(\n userInput: PerseusPlotterUserInput,\n rubric: PerseusPlotterRubric,\n): PerseusScore {\n return {\n type: \"points\",\n earned: approximateDeepEqual(userInput, rubric.correct) ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scorePlotter;\n","import {approximateDeepEqual} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusPlotterUserInput,\n PerseusPlotterValidationData,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input to confirm it is not the same as the starting values for the graph.\n * This means the user has modified the graph, and the question can be scored.\n *\n * @see 'scorePlotter' for more details on scoring.\n */\nfunction validatePlotter(\n userInput: PerseusPlotterUserInput,\n validationData: PerseusPlotterValidationData,\n): ValidationResult {\n if (approximateDeepEqual(userInput, validationData.starting)) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return null;\n}\n\nexport default validatePlotter;\n","import ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusRadioRubric,\n PerseusRadioUserInput,\n PerseusScore,\n RecursiveReadonly,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreRadio(\n userInput: RecursiveReadonly<PerseusRadioUserInput>,\n rubric: RecursiveReadonly<PerseusRadioRubric>,\n): PerseusScore {\n const numSelected = userInput.choicesSelected.reduce((sum, selected) => {\n return sum + (selected ? 1 : 0);\n }, 0);\n\n const numCorrect: number = rubric.choices.reduce((sum, currentChoice) => {\n return currentChoice.correct ? sum + 1 : sum;\n }, 0);\n\n if (numCorrect > 1 && numSelected !== numCorrect) {\n return {\n type: \"invalid\",\n message: ErrorCodes.CHOOSE_CORRECT_NUM_ERROR,\n };\n // If NOTA and some other answer are checked, ...\n }\n\n const noneOfTheAboveSelected = rubric.choices.some(\n (choice, index) =>\n choice.isNoneOfTheAbove && userInput.choicesSelected[index],\n );\n\n if (noneOfTheAboveSelected && numSelected > 1) {\n return {\n type: \"invalid\",\n message: ErrorCodes.NOT_NONE_ABOVE_ERROR,\n };\n }\n\n const correct = userInput.choicesSelected.every((selected, i) => {\n let isCorrect: boolean;\n if (rubric.choices[i].isNoneOfTheAbove) {\n isCorrect = rubric.choices.every((choice, j) => {\n return i === j || !choice.correct;\n });\n } else {\n isCorrect = !!rubric.choices[i].correct;\n }\n return isCorrect === selected;\n });\n\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreRadio;\n","import type {\n PerseusRadioUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks if the user has selected at least one option. Additional validation\n * is done in scoreRadio to check if the number of selected options is correct\n * and if the user has selected both a correct option and the \"none of the above\"\n * option.\n * @param userInput\n * @see `scoreRadio` for the additional validation logic and the scoring logic.\n */\nfunction validateRadio(userInput: PerseusRadioUserInput): ValidationResult {\n if (!userInput.choicesSelected.includes(true)) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateRadio;\n","import {approximateDeepEqual} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusSorterRubric,\n PerseusSorterUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreSorter(\n userInput: PerseusSorterUserInput,\n rubric: PerseusSorterRubric,\n): PerseusScore {\n const correct = approximateDeepEqual(userInput.options, rubric.correct);\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreSorter;\n","import type {\n PerseusSorterUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input for the sorter widget to ensure that the user has made\n * changes before attempting to score the widget.\n * @param userInput\n * @see 'scoreSorter' in 'packages/perseus/src/widgets/sorter/score-sorter.ts'\n * for more details on how the sorter widget is scored.\n */\nfunction validateSorter(userInput: PerseusSorterUserInput): ValidationResult {\n // If the sorter widget hasn't been changed yet, we treat it as \"empty\" which\n // prevents the \"Check\" button from becoming active. We want the user\n // to make a change before trying to move forward. This makes an\n // assumption that the initial order isn't the correct order! However,\n // this should be rare if it happens, and interacting with the list\n // will enable the button, so they won't be locked out of progressing.\n if (!userInput.changed) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return null;\n}\n\nexport default validateSorter;\n","/**\n * Filters the given table (modelled as a 2D array) to remove any rows that are\n * completely empty.\n *\n * @returns A new table with only non-empty rows.\n */\nexport const filterNonEmpty = function (\n table: ReadonlyArray<ReadonlyArray<string>>,\n) {\n return table.filter(function (row) {\n // Return only rows that are non-empty.\n return row.some((cell) => cell);\n });\n};\n","import {filterNonEmpty} from \"./utils\";\n\nimport type {\n PerseusTableUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\nfunction validateTable(userInput: PerseusTableUserInput): ValidationResult {\n const supplied = filterNonEmpty(userInput);\n\n const hasEmptyCell = supplied.some(function (row) {\n return row.some(function (cell) {\n return cell === \"\";\n });\n });\n\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (hasEmptyCell || !supplied.length) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateTable;\n","import KhanAnswerTypes from \"../../util/answer-types\";\n\nimport {filterNonEmpty} from \"./utils\";\nimport validateTable from \"./validate-table\";\n\nimport type {\n PerseusTableRubric,\n PerseusScore,\n PerseusTableUserInput,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreTable(\n userInput: PerseusTableUserInput,\n rubric: PerseusTableRubric,\n): PerseusScore {\n const validationResult = validateTable(userInput);\n if (validationResult != null) {\n return validationResult;\n }\n\n const supplied = filterNonEmpty(userInput);\n const solution = filterNonEmpty(rubric.answers);\n if (supplied.length !== solution.length) {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n }\n\n const createValidator = KhanAnswerTypes.number.createValidatorFunctional;\n let message: string | null = null;\n const allCorrect = solution.every(function (rowSolution) {\n for (let i = 0; i < supplied.length; i++) {\n const rowSupplied = supplied[i];\n const correct = rowSupplied.every(function (cellSupplied, i) {\n const cellSolution = rowSolution[i];\n const validator = createValidator(cellSolution, {\n simplify: true,\n });\n const result = validator(cellSupplied);\n if (result.message) {\n message = result.message;\n }\n return result.correct;\n });\n if (correct) {\n supplied.splice(i, 1);\n return true;\n }\n }\n return false;\n });\n return {\n type: \"points\",\n earned: allCorrect ? 1 : 0,\n total: 1,\n message,\n };\n}\n\nexport default scoreTable;\n","import KhanAnswerTypes from \"../../util/answer-types\";\nimport {parseTex} from \"../../util/tex-wrangler\";\n\nimport type {\n PerseusInputNumberRubric,\n PerseusInputNumberUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nexport const inputNumberAnswerTypes = {\n number: {\n name: \"Numbers\",\n forms: \"integer, decimal, proper, improper, mixed\",\n },\n decimal: {\n name: \"Decimals\",\n forms: \"decimal\",\n },\n integer: {\n name: \"Integers\",\n forms: \"integer\",\n },\n rational: {\n name: \"Fractions and mixed numbers\",\n forms: \"integer, proper, improper, mixed\",\n },\n improper: {\n name: \"Improper numbers (no mixed)\",\n forms: \"integer, proper, improper\",\n },\n mixed: {\n name: \"Mixed numbers (no improper)\",\n forms: \"integer, proper, mixed\",\n },\n percent: {\n name: \"Numbers or percents\",\n forms: \"integer, decimal, proper, improper, mixed, percent\",\n },\n pi: {\n name: \"Numbers with pi\",\n forms: \"pi\",\n },\n} as const;\n\nfunction scoreInputNumber(\n userInput: PerseusInputNumberUserInput,\n rubric: PerseusInputNumberRubric,\n): PerseusScore {\n if (rubric.answerType == null) {\n rubric.answerType = \"number\";\n }\n\n // note(matthewc): this will get immediately parsed again by\n // `KhanAnswerTypes.number.convertToPredicate`, but a string is\n // expected here\n const stringValue = `${rubric.value}`;\n const val = KhanAnswerTypes.number.createValidatorFunctional(stringValue, {\n simplify: rubric.simplify,\n inexact: rubric.inexact || undefined,\n maxError: rubric.maxError,\n forms: inputNumberAnswerTypes[rubric.answerType].forms,\n });\n\n // We may have received TeX; try to parse it before grading.\n // If `currentValue` is not TeX, this should be a no-op.\n const currentValue = parseTex(userInput.currentValue);\n\n const result = val(currentValue);\n\n if (result.empty) {\n return {\n type: \"invalid\",\n message: result.message,\n };\n }\n return {\n type: \"points\",\n earned: result.correct ? 1 : 0,\n total: 1,\n message: result.message,\n };\n}\n\nexport default scoreInputNumber;\n","import type {PerseusScore} from \"@khanacademy/perseus-core\";\n\n/**\n * Several widgets don't have \"right\"/\"wrong\" scoring logic,\n * so this just says to move on past those widgets\n *\n * TODO(LEMS-2543) widgets that use this probably shouldn't have any\n * scoring logic and the thing scoring an exercise\n * should just know to skip these\n */\nfunction scoreNoop(points: number = 0): PerseusScore {\n return {\n type: \"points\",\n earned: points,\n total: points,\n message: null,\n };\n}\n\nexport default scoreNoop;\n","import scoreNoop from \"../../util/score-noop\";\n\nimport type {\n PerseusFreeResponseUserInput,\n PerseusFreeResponseRubric,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreFreeResponse(\n userInput: PerseusFreeResponseUserInput,\n rubric: PerseusFreeResponseRubric,\n locale: string,\n): PerseusScore {\n // TODO(AX-961): Implement support for external scoring. Since the user's\n // input is free text input, we can't easily do scoring inside the\n // widget, so we'll need to have a way to do it by some other method.\n // For now, we'll just always give full credit.\n return scoreNoop();\n}\n\nexport default scoreFreeResponse;\n","import ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusFreeResponseUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the free response widget to see if it is scorable.\n * Since the input is free text, we only check that it is not empty.\n */\nfunction validateFreeResponse(\n userInput: PerseusFreeResponseUserInput,\n): ValidationResult {\n if (userInput.currentValue.trim() === \"\") {\n return {\n type: \"invalid\",\n message: ErrorCodes.USER_INPUT_EMPTY,\n };\n }\n\n return null;\n}\n\nexport default validateFreeResponse;\n","// The `group` widget is basically a widget hosting a full Perseus system in\n\nimport {flattenScores, scoreWidgetsFunctional} from \"../../score\";\n\nimport type {\n PerseusGroupRubric,\n PerseusGroupUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n// it. As such, scoring a group means scoring all widgets it contains.\nfunction scoreGroup(\n userInput: PerseusGroupUserInput,\n rubric: PerseusGroupRubric,\n locale: string,\n): PerseusScore {\n const scores = scoreWidgetsFunctional(\n rubric.widgets,\n Object.keys(rubric.widgets),\n userInput,\n locale,\n );\n\n return flattenScores(scores);\n}\n\nexport default scoreGroup;\n","import {scoreIsEmpty} from \"./score\";\nimport {getWidgetValidator} from \"./widgets/widget-registry\";\n\nimport type {UserInputMap, ValidationDataMap} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks the given user input to see if any answerable widgets have not been\n * \"filled in\" (ie. if they're empty). Another way to think about this\n * function is that its a check to see if we can score the provided input.\n */\nexport function emptyWidgetsFunctional(\n widgets: ValidationDataMap,\n // This is a port of old code, I'm not sure why\n // we need widgetIds vs the keys of the widgets object\n widgetIds: ReadonlyArray<string>,\n userInputMap: UserInputMap,\n locale: string,\n): ReadonlyArray<string> {\n return widgetIds.filter((id) => {\n const widget = widgets[id];\n if (!widget || widget.static === true) {\n // Static widgets shouldn't count as empty\n return false;\n }\n\n const validator = getWidgetValidator(widget.type);\n const userInput = userInputMap[id];\n const validationData = widget.options;\n const score = validator?.(userInput, validationData, locale);\n\n if (score) {\n return scoreIsEmpty(score);\n }\n });\n}\n","import {emptyWidgetsFunctional} from \"../../validate\";\n\nimport type {\n PerseusGroupUserInput,\n PerseusGroupValidationData,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\nfunction validateGroup(\n userInput: PerseusGroupUserInput,\n validationData: PerseusGroupValidationData,\n locale: string,\n): ValidationResult {\n const emptyWidgets = emptyWidgetsFunctional(\n validationData.widgets,\n Object.keys(validationData.widgets),\n userInput,\n locale,\n );\n\n if (emptyWidgets.length === 0) {\n return null;\n }\n\n return {type: \"invalid\", message: null};\n}\n\nexport default validateGroup;\n","import type {\n PerseusLabelImageUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\nfunction validateLabelImage(\n userInput: PerseusLabelImageUserInput,\n): ValidationResult {\n let numAnswered = 0;\n for (let i = 0; i < userInput.markers.length; i++) {\n const userSelection = userInput.markers[i].selected;\n if (userSelection && userSelection.length > 0) {\n numAnswered++;\n }\n }\n // We expect all question markers to be answered before grading.\n if (numAnswered !== userInput.markers.length) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateLabelImage;\n","import type {PerseusMockWidgetUserInput} from \"./mock-widget-validation.types\";\nimport type {ValidationResult} from \"@khanacademy/perseus-core\";\n\nfunction validateMockWidget(\n userInput: PerseusMockWidgetUserInput,\n): ValidationResult {\n if (userInput.currentValue == null || userInput.currentValue === \"\") {\n return {\n type: \"invalid\",\n message: \"\",\n };\n }\n\n return null;\n}\n\nexport default validateMockWidget;\n","import validateMockWidget from \"./validate-mock-widget\";\n\nimport type {\n PerseusMockWidgetRubric,\n PerseusMockWidgetUserInput,\n} from \"./mock-widget-validation.types\";\nimport type {PerseusScore} from \"@khanacademy/perseus-core\";\n\nfunction scoreMockWidget(\n userInput: PerseusMockWidgetUserInput,\n rubric: PerseusMockWidgetRubric,\n): PerseusScore {\n const validationResult = validateMockWidget(userInput);\n if (validationResult != null) {\n return validationResult;\n }\n\n return {\n type: \"points\",\n earned: userInput.currentValue === rubric.value ? 1 : 0,\n total: 1,\n message: \"\",\n };\n}\n\nexport default scoreMockWidget;\n","import {\n Registry,\n type WidgetScorerFunction,\n type WidgetValidatorFunction,\n} from \"@khanacademy/perseus-core\";\n\nimport scoreNoop from \"../util/score-noop\";\n\nimport scoreCategorizer from \"./categorizer/score-categorizer\";\nimport validateCategorizer from \"./categorizer/validate-categorizer\";\nimport scoreCSProgram from \"./cs-program/score-cs-program\";\nimport scoreDropdown from \"./dropdown/score-dropdown\";\nimport validateDropdown from \"./dropdown/validate-dropdown\";\nimport scoreExpression from \"./expression/score-expression\";\nimport validateExpression from \"./expression/validate-expression\";\nimport scoreFreeResponse from \"./free-response/score-free-response\";\nimport validateFreeResponse from \"./free-response/validate-free-response\";\nimport scoreGrapher from \"./grapher/score-grapher\";\nimport scoreGroup from \"./group/score-group\";\nimport validateGroup from \"./group/validate-group\";\nimport scoreIframe from \"./iframe/score-iframe\";\nimport scoreInputNumber from \"./input-number/score-input-number\";\nimport scoreInteractiveGraph from \"./interactive-graph/score-interactive-graph\";\nimport scoreLabelImage from \"./label-image/score-label-image\";\nimport validateLabelImage from \"./label-image/validate-label-image\";\nimport scoreMatcher from \"./matcher/score-matcher\";\nimport scoreMatrix from \"./matrix/score-matrix\";\nimport validateMatrix from \"./matrix/validate-matrix\";\nimport scoreMockWidget from \"./mock-widget/score-mock-widget\";\nimport scoreNumberLine from \"./number-line/score-number-line\";\nimport validateNumberLine from \"./number-line/validate-number-line\";\nimport scoreNumericInput from \"./numeric-input/score-numeric-input\";\nimport scoreOrderer from \"./orderer/score-orderer\";\nimport validateOrderer from \"./orderer/validate-orderer\";\nimport scorePlotter from \"./plotter/score-plotter\";\nimport validatePlotter from \"./plotter/validate-plotter\";\nimport scoreRadio from \"./radio/score-radio\";\nimport validateRadio from \"./radio/validate-radio\";\nimport scoreSorter from \"./sorter/score-sorter\";\nimport validateSorter from \"./sorter/validate-sorter\";\nimport scoreTable from \"./table/score-table\";\nimport validateTable from \"./table/validate-table\";\n\ntype ScoringLogic = {\n scorer: WidgetScorerFunction;\n validator?: WidgetValidatorFunction;\n};\n\nconst widgets = new Registry<ScoringLogic>(\"Score widget registry\");\n\nexport function registerWidget(\n type: string,\n scorer: WidgetScorerFunction,\n validator?: WidgetValidatorFunction,\n) {\n const logic = {\n scorer,\n validator,\n };\n widgets.set(type, logic);\n}\n\nexport const getWidgetValidator = (\n type: string,\n): WidgetValidatorFunction | null => {\n return widgets.get(type)?.validator ?? null;\n};\n\nexport const getWidgetScorer = (type: string): WidgetScorerFunction | null => {\n return widgets.get(type)?.scorer ?? null;\n};\n\nregisterWidget(\n \"categorizer\",\n scoreCategorizer as any,\n validateCategorizer as any,\n);\nregisterWidget(\"cs-program\", scoreCSProgram as any);\nregisterWidget(\"dropdown\", scoreDropdown as any, validateDropdown as any);\nregisterWidget(\"expression\", scoreExpression as any, validateExpression as any);\nregisterWidget(\n \"free-response\",\n scoreFreeResponse as any,\n validateFreeResponse as any,\n);\nregisterWidget(\"grapher\", scoreGrapher as any);\nregisterWidget(\"group\", scoreGroup as any, validateGroup as any);\nregisterWidget(\"iframe\", scoreIframe as any);\nregisterWidget(\"input-number\", scoreInputNumber as any);\nregisterWidget(\"interactive-graph\", scoreInteractiveGraph as any);\nregisterWidget(\n \"label-image\",\n scoreLabelImage as any,\n validateLabelImage as any,\n);\nregisterWidget(\"matcher\", scoreMatcher as any);\nregisterWidget(\"matrix\", scoreMatrix as any, validateMatrix as any);\nregisterWidget(\"mock-widget\", scoreMockWidget as any, scoreMockWidget as any);\nregisterWidget(\n \"number-line\",\n scoreNumberLine as any,\n validateNumberLine as any,\n);\nregisterWidget(\"numeric-input\", scoreNumericInput as any);\nregisterWidget(\"orderer\", scoreOrderer as any, validateOrderer as any);\nregisterWidget(\"plotter\", scorePlotter as any, validatePlotter as any);\nregisterWidget(\"radio\", scoreRadio as any, validateRadio as any);\nregisterWidget(\"sorter\", scoreSorter as any, validateSorter as any);\nregisterWidget(\"table\", scoreTable as any, validateTable as any);\nregisterWidget(\"deprecated-standin\", () => scoreNoop(1) as any);\nregisterWidget(\"measurer\", () => scoreNoop(1) as any);\n\nregisterWidget(\"definition\", scoreNoop as any);\nregisterWidget(\"explanation\", scoreNoop as any);\nregisterWidget(\"image\", scoreNoop as any);\nregisterWidget(\"interaction\", scoreNoop as any);\nregisterWidget(\"molecule\", scoreNoop as any);\nregisterWidget(\"passage\", scoreNoop as any);\nregisterWidget(\"passage-ref\", scoreNoop as any);\nregisterWidget(\"passage-ref-target\", scoreNoop as any);\nregisterWidget(\"video\", scoreNoop as any);\n","import {\n Errors,\n getUpgradedWidgetOptions,\n getWidgetIdsFromContent,\n PerseusError,\n} from \"@khanacademy/perseus-core\";\n\nimport {getWidgetScorer, getWidgetValidator} from \"./widgets/widget-registry\";\n\nimport type {\n PerseusRenderer,\n PerseusScore,\n PerseusWidgetsMap,\n UserInputMap,\n} from \"@khanacademy/perseus-core\";\n\nconst noScore: PerseusScore = {\n type: \"points\",\n earned: 0,\n total: 0,\n message: null,\n};\n\n/**\n * If a widget says that it is empty once it is graded.\n * Trying to encapsulate references to the score format.\n */\nexport function scoreIsEmpty(score: PerseusScore): boolean {\n // HACK(benkomalo): ugh. this isn't great; the Perseus score objects\n // overload the type \"invalid\" for what should probably be three\n // distinct cases:\n // - truly empty or not fully filled out\n // - invalid or malformed inputs\n // - \"almost correct\" like inputs where the widget wants to give\n // feedback (e.g. a fraction needs to be reduced, or `pi` should\n // be used instead of 3.14)\n //\n // Unfortunately the coercion happens all over the place, as these\n // Perseus style score objects are created *everywhere* (basically\n // in every widget), so it's hard to change now. We assume that\n // anything with a \"message\" is not truly empty, and one of the\n // latter two cases for now.\n return (\n score.type === \"invalid\" &&\n (!score.message || score.message.length === 0)\n );\n}\n\n/**\n * Combine two score objects.\n *\n * Given two score objects for two different widgets, combine them so that\n * if one is wrong, the total score is wrong, etc.\n */\nfunction combineScores(\n scoreA: PerseusScore,\n scoreB: PerseusScore,\n): PerseusScore {\n let message;\n\n if (scoreA.type === \"points\" && scoreB.type === \"points\") {\n if (\n scoreA.message &&\n scoreB.message &&\n scoreA.message !== scoreB.message\n ) {\n // TODO(alpert): Figure out how to combine messages usefully\n message = null;\n } else {\n message = scoreA.message || scoreB.message;\n }\n\n return {\n type: \"points\",\n earned: scoreA.earned + scoreB.earned,\n total: scoreA.total + scoreB.total,\n message: message,\n };\n }\n if (scoreA.type === \"points\" && scoreB.type === \"invalid\") {\n return scoreB;\n }\n if (scoreA.type === \"invalid\" && scoreB.type === \"points\") {\n return scoreA;\n }\n if (scoreA.type === \"invalid\" && scoreB.type === \"invalid\") {\n if (\n scoreA.message &&\n scoreB.message &&\n scoreA.message !== scoreB.message\n ) {\n // TODO(alpert): Figure out how to combine messages usefully\n message = null;\n } else {\n message = scoreA.message || scoreB.message;\n }\n\n return {\n type: \"invalid\",\n message: message,\n };\n }\n\n /**\n * The above checks cover all combinations of score type, so if we get here\n * then something is amiss with our inputs.\n */\n throw new PerseusError(\n \"PerseusScore with unknown type encountered\",\n Errors.InvalidInput,\n {\n metadata: {\n scoreA: JSON.stringify(scoreA),\n scoreB: JSON.stringify(scoreB),\n },\n },\n );\n}\n\nexport function flattenScores(widgetScoreMap: {\n [widgetId: string]: PerseusScore;\n}): PerseusScore {\n return Object.values(widgetScoreMap).reduce(combineScores, noScore);\n}\n\n/**\n * score a Perseus item\n *\n * @param perseusRenderData - the full answer data, includes the correct answer\n * @param userInputMap - the user's input for each widget, mapped by ID\n * @param locale - string locale for math parsing (\"de\" 1.000,00 vs \"en\" 1,000.00)\n */\nexport function scorePerseusItem(\n perseusRenderData: PerseusRenderer,\n userInputMap: UserInputMap,\n locale: string,\n): PerseusScore {\n // There seems to be a chance that PerseusRenderer.widgets might include\n // widget data for widgets that are not in PerseusRenderer.content,\n // so this checks that the widgets are being used before scoring them\n const usedWidgetIds = getWidgetIdsFromContent(perseusRenderData.content);\n const scores = scoreWidgetsFunctional(\n perseusRenderData.widgets,\n usedWidgetIds,\n userInputMap,\n locale,\n );\n return flattenScores(scores);\n}\n\n// TODO: combine scorePerseusItem with scoreWidgetsFunctional\nexport function scoreWidgetsFunctional(\n widgets: PerseusWidgetsMap,\n // This is a port of old code, I'm not sure why\n // we need widgetIds vs the keys of the widgets object\n widgetIds: ReadonlyArray<string>,\n userInputMap: UserInputMap,\n locale: string,\n): {[widgetId: string]: PerseusScore} {\n const upgradedWidgets = getUpgradedWidgetOptions(widgets);\n\n const gradedWidgetIds = widgetIds.filter((id) => {\n const props = upgradedWidgets[id];\n const widgetIsGraded: boolean = props?.graded == null || props.graded;\n const widgetIsStatic = !!props?.static;\n // Ungraded widgets or widgets set to static shouldn't be graded.\n return widgetIsGraded && !widgetIsStatic;\n });\n\n const widgetScores: Record<string, PerseusScore> = {};\n gradedWidgetIds.forEach((id) => {\n const widget = upgradedWidgets[id];\n if (!widget) {\n return;\n }\n\n const userInput = userInputMap[id];\n const validator = getWidgetValidator(widget.type);\n const scorer = getWidgetScorer(widget.type);\n\n // We do validation (empty checks) first and then scoring. If\n // validation fails, it's result is itself a PerseusScore.\n const score =\n validator?.(userInput, widget.options, locale) ??\n scorer?.(userInput, widget.options, locale);\n if (score != null) {\n widgetScores[id] = score;\n }\n });\n\n return widgetScores;\n}\n","import {getWidgetIdsFromContent} from \"@khanacademy/perseus-core\";\n\nimport type {PerseusItem, UserInputMap} from \"@khanacademy/perseus-core\";\n\n/**\n * Check the emptiness of DINER widgets (for the AX team):\n * - Dropdown\n * - InteractiveGraph\n * - NumericInput\n * - Expression\n * - Radio\n *\n * @param {PerseusItem} itemData\n * @param {UserInputMap} userInputMap\n * @returns {boolean} true if there's an empty widget, otherwise false\n */\nfunction hasEmptyDINERWidgets(\n itemData: PerseusItem,\n userInputMap: UserInputMap,\n): boolean {\n const usedWidgetIds = getWidgetIdsFromContent(itemData.question.content);\n const widgets = itemData.question.widgets;\n\n for (const widgetId of usedWidgetIds) {\n const widget = widgets[widgetId];\n const input = userInputMap[widgetId];\n\n switch (widget.type) {\n case \"dropdown\": {\n // see `validateDropdown`\n if (input.value === 0) {\n return true;\n }\n break;\n }\n case \"interactive-graph\": {\n // IG doesn't do client-side validation\n break;\n }\n case \"numeric-input\": {\n // this is possibly a source of bugs,\n // really it should be:\n // empty input && not coefficient && answer is not 1\n // but we don't have answers here\n // (see: `scoreNumericInput`)\n if (!input.currentValue && !widget.options.coefficient) {\n return true;\n }\n break;\n }\n case \"expression\": {\n // see `validateExpression`\n if (!input) {\n return true;\n }\n break;\n }\n case \"radio\": {\n // see `validateRadio`\n if (!input.choicesSelected.includes(true)) {\n return true;\n }\n break;\n }\n }\n }\n\n return false;\n}\n\nexport default hasEmptyDINERWidgets;\n"],"names":["APPROXIMATED_PI_ERROR","CHOOSE_CORRECT_NUM_ERROR","EXTRA_SYMBOLS_ERROR","FILL_ALL_CELLS_ERROR","INVALID_SELECTION_ERROR","MISSING_PERCENT_ERROR","MULTIPLICATION_SIGN_ERROR","NEEDS_TO_BE_SIMPLIFIED_ERROR","NOT_NONE_ABOVE_ERROR","USER_INPUT_EMPTY","WRONG_CASE_ERROR","WRONG_LETTER_ERROR","ErrorCodes","MAXERROR_EPSILON","Math","pow","KhanAnswerTypes","predicate","defaultForms","createValidatorFunctional","options","_","extend","simplify","ratio","forms","acceptableForms","isArray","split","inexact","undefined","maxError","contains","without","push","fractionTransformer","text","replace","match","mobileDeviceMatch","parsedInt","parseInt","num","denom","simplified","parseFloat","KhanMath","getGCD","value","exact","isNaN","integer","decimal","rounded","proper","transformed","flatMap","o","abs","improper","fractionExists","includes","pi","possibilities","sign","integ","reduce","memo","form","concat","approximatesPi","number","piMult","PI","roundedNumber","round","each","possibility","piApprox","multiplier","forEach","coefficient","log","percent","String","trim","hasPercentSign","indexOf","length","substring","t","mixed","precision","normal","badLeadingZero","x","commas","c","guess","fallback","score","empty","correct","message","findCorrectAnswer","j","l","val","interpretedGuess","anyAreNaN","any","convertToPredicate","correctAnswer","correctFloat","type","expression","parseSolution","solutionString","solution","KAS","parse","parsed","PerseusError","Errors","InvalidInput","expr","isSimplified","ungraded","answer","result","compare","equal","wrongVariableNames","wrongVariableCase","suppressAlmostThere","answerX","resultX","scoreCategorizer","userInput","rubric","allCorrect","values","i","earned","total","validateCategorizer","validationData","incomplete","items","some","scoreCSProgram","status","scoreDropdown","choices","validateDropdown","scoreExpression","locale","clone","decimal_separator","getDecimalSeparator","createValidator","metadata","JSON","stringify","matchingAnswerForm","matchMessage","allEmpty","firstUngradedResult","answerForm","answerForms","validator","considered","validateExpression","getCoefficientsByType","data","coords","grader","GrapherUtil","functionForType","getCoefficients","asymptote","scoreGrapher","guessCoeffs","correctCoeffs","areEqual","scoreIframe","collinear","canonicalSineCoefficients","similar","clockwise","geometry","getClockwiseAngle","angles","getSinusoidCoefficients","getQuadraticCoefficients","coefficients","scoreInteractiveGraph","hasValue","Boolean","center","radius","approximateDeepEqual","canonicalGuessCoeffs","canonicalCorrectCoeffs","approximateEqual","Error","slice","sort","Number","POSITIVE_INFINITY","knumber","DEFAULT_TOLERANCE","deepClone","invoke","allowReflexAngles","areClockwise","shouldReverseCoords","reverse","map","angle","isEqual","graph","scoreLabelImageMarker","hasAnswers","isCorrect","every","choice","scoreLabelImage","numCorrect","markers","selected","answers","scoreMatcher","left","right","scoreMatrix","supplied","solutionSize","getMatrixSize","suppliedSize","incorrectSize","incorrect","times","row","col","validateMatrix","toString","scoreNumberLine","range","start","initialX","startRel","isInequality","correctRel","correctPos","numLinePosition","correctX","rel","validateNumberLine","divisionRange","outsideAllowedRange","numDivisions","isTickCrtl","findEndpoint","tex","currentIndex","bracketDepth","len","parseNextExpression","handler","openBracketIndex","endpoint","nextExpIndex","expressionTeX","parsedExp","walkTex","getNextFracIndex","dfrac","frac","nextFrac","nextDFrac","min","parsedString","firstParsedExpression","secondParsedExpression","parseTex","exp1","exp2","texWithoutFracs","answerFormButtons","title","content","maybeParsePercentInput","inputValue","normalizedAnswerExpected","endsWith","scoreNumericInput","defaultAnswerForms","e","filter","stringAnswer","validatorForms","strict","currentValue","localValue","matchedAnswer","validateFn","find","scoreOrderer","current","correctOptions","option","validateOrderer","scorePlotter","validatePlotter","starting","scoreRadio","numSelected","choicesSelected","sum","currentChoice","noneOfTheAboveSelected","index","isNoneOfTheAbove","validateRadio","scoreSorter","validateSorter","changed","filterNonEmpty","table","cell","validateTable","hasEmptyCell","scoreTable","validationResult","rowSolution","rowSupplied","cellSupplied","cellSolution","splice","inputNumberAnswerTypes","name","rational","scoreInputNumber","answerType","stringValue","scoreNoop","points","scoreFreeResponse","validateFreeResponse","scoreGroup","scores","scoreWidgetsFunctional","widgets","Object","keys","flattenScores","emptyWidgetsFunctional","widgetIds","userInputMap","id","widget","static","getWidgetValidator","scoreIsEmpty","validateGroup","emptyWidgets","validateLabelImage","numAnswered","userSelection","validateMockWidget","scoreMockWidget","Registry","registerWidget","scorer","logic","set","get","getWidgetScorer","noScore","combineScores","scoreA","scoreB","widgetScoreMap","scorePerseusItem","perseusRenderData","usedWidgetIds","getWidgetIdsFromContent","upgradedWidgets","getUpgradedWidgetOptions","gradedWidgetIds","props","widgetIsGraded","graded","widgetIsStatic","widgetScores","hasEmptyDINERWidgets","itemData","question","widgetId","input"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAMA,qBAAAA,CAAwB,uBAC9B,CAAA,MAAMC,wBAA2B,CAAA,0BAAA,CACjC,MAAMC,mBAAsB,CAAA,qBAAA,CAC5B,MAAMC,oBAAAA,CAAuB,sBAC7B,CAAA,MAAMC,wBAA0B,yBAChC,CAAA,MAAMC,qBAAwB,CAAA,uBAAA,CAC9B,MAAMC,yBAAAA,CAA4B,4BAClC,MAAMC,4BAAAA,CAA+B,8BACrC,CAAA,MAAMC,oBAAuB,CAAA,sBAAA,CAC7B,MAAMC,gBAAmB,CAAA,kBAAA,CACzB,MAAMC,gBAAAA,CAAmB,kBACzB,CAAA,MAAMC,mBAAqB,oBAE3B,CAAA,MAAMC,UAAa,CAAA,CACfZ,qBACAC,CAAAA,wBAAAA,CACAC,oBACAC,oBACAC,CAAAA,uBAAAA,CACAC,qBACAC,CAAAA,yBAAAA,CACAC,4BACAC,CAAAA,oBAAAA,CACAC,iBACAC,gBACAC,CAAAA,kBACJ;;AClBA,MAAME,iBAAmBC,IAAKC,CAAAA,GAAG,CAAC,CAAG,CAAA,KAiE/BC,MAAAA,eAAAA,CAAkB,CA0BpBC,SAAAA,CAAW,CACPC,YAAAA,CAAc,4CACdC,yBAA2B,CAAA,SACvBF,SAAoB,CACpBG,OAAY,EAGZA,OAAUC,CAAAA,kBAAAA,CAAEC,MAAM,CACd,CACIC,QAAAA,CAAU,WACVC,KAAO,CAAA,KAAA,CACPC,MAAOT,eAAgBC,CAAAA,SAAS,CAACC,YACrC,CACAE,CAAAA,OAAAA,CAAAA,CAEJ,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vC,OAAO,IACX,CACA,KACJ,CACJ,CACJ,CAEA,OAAO,KACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/error-codes.ts","../src/util/answer-types.ts","../src/widgets/categorizer/score-categorizer.ts","../src/widgets/categorizer/validate-categorizer.ts","../src/widgets/cs-program/score-cs-program.ts","../src/widgets/dropdown/score-dropdown.ts","../src/widgets/dropdown/validate-dropdown.ts","../src/widgets/expression/score-expression.ts","../src/widgets/expression/validate-expression.ts","../src/widgets/grapher/score-grapher.ts","../src/widgets/iframe/score-iframe.ts","../src/widgets/interactive-graph/score-interactive-graph.ts","../src/widgets/label-image/score-label-image.ts","../src/widgets/matcher/score-matcher.ts","../src/widgets/matrix/score-matrix.ts","../src/widgets/matrix/validate-matrix.ts","../src/widgets/number-line/score-number-line.ts","../src/widgets/number-line/validate-number-line.ts","../src/util/tex-wrangler.ts","../src/widgets/numeric-input/score-numeric-input.ts","../src/widgets/orderer/score-orderer.ts","../src/widgets/orderer/validate-orderer.ts","../src/widgets/plotter/score-plotter.ts","../src/widgets/plotter/validate-plotter.ts","../src/widgets/radio/score-radio.ts","../src/widgets/radio/validate-radio.ts","../src/widgets/sorter/score-sorter.ts","../src/widgets/sorter/validate-sorter.ts","../src/widgets/table/utils.ts","../src/widgets/table/validate-table.ts","../src/widgets/table/score-table.ts","../src/widgets/input-number/score-input-number.ts","../src/util/score-noop.ts","../src/widgets/free-response/score-free-response.ts","../src/widgets/free-response/validate-free-response.ts","../src/widgets/group/score-group.ts","../src/validate.ts","../src/widgets/group/validate-group.ts","../src/widgets/label-image/validate-label-image.ts","../src/widgets/mock-widget/validate-mock-widget.ts","../src/widgets/mock-widget/score-mock-widget.ts","../src/widgets/widget-registry.ts","../src/score.ts","../src/has-empty-diner-widgets.ts"],"sourcesContent":["const APPROXIMATED_PI_ERROR = \"APPROXIMATED_PI_ERROR\";\nconst CHOOSE_CORRECT_NUM_ERROR = \"CHOOSE_CORRECT_NUM_ERROR\";\nconst EXTRA_SYMBOLS_ERROR = \"EXTRA_SYMBOLS_ERROR\";\nconst FILL_ALL_CELLS_ERROR = \"FILL_ALL_CELLS_ERROR\";\nconst INVALID_SELECTION_ERROR = \"INVALID_SELECTION_ERROR\";\nconst MISSING_PERCENT_ERROR = \"MISSING_PERCENT_ERROR\";\nconst MULTIPLICATION_SIGN_ERROR = \"MULTIPLICATION_SIGN_ERROR\";\nconst NEEDS_TO_BE_SIMPLIFIED_ERROR = \"NEEDS_TO_BE_SIMPLIFIED_ERROR\";\nconst NOT_NONE_ABOVE_ERROR = \"NOT_NONE_ABOVE_ERROR\";\nconst USER_INPUT_EMPTY = \"USER_INPUT_EMPTY\";\nconst USER_INPUT_TOO_LONG = \"USER_INPUT_TOO_LONG\";\nconst WRONG_CASE_ERROR = \"WRONG_CASE_ERROR\";\nconst WRONG_LETTER_ERROR = \"WRONG_LETTER_ERROR\";\n\nconst ErrorCodes = {\n APPROXIMATED_PI_ERROR,\n CHOOSE_CORRECT_NUM_ERROR,\n EXTRA_SYMBOLS_ERROR,\n FILL_ALL_CELLS_ERROR,\n INVALID_SELECTION_ERROR,\n MISSING_PERCENT_ERROR,\n MULTIPLICATION_SIGN_ERROR,\n NEEDS_TO_BE_SIMPLIFIED_ERROR,\n NOT_NONE_ABOVE_ERROR,\n USER_INPUT_EMPTY,\n USER_INPUT_TOO_LONG,\n WRONG_CASE_ERROR,\n WRONG_LETTER_ERROR,\n};\n\nexport default ErrorCodes;\n","/* eslint-disable no-useless-escape */\nimport * as KAS from \"@khanacademy/kas\";\nimport {KhanMath} from \"@khanacademy/kmath\";\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport ErrorCodes from \"../error-codes\";\n\nconst MAXERROR_EPSILON = Math.pow(2, -42);\n\ntype Guess = any;\ntype Predicate = (guess: number, maxError: number) => boolean;\ntype TransformedFraction = {\n value: number;\n exact: boolean;\n};\n\n// TOOD(kevinb): Figure out how this relates to KEScore in\n// perseus-all-package/types.js and see if there's a way to\n// unify these types.\nexport type Score = {\n empty: boolean;\n correct: boolean;\n message: string | null | undefined;\n suppressAlmostThere?: boolean | null | undefined;\n guess: Guess;\n // It would be nice if we could ungraded required\n ungraded?: boolean;\n};\n\n/**\n * Answer types\n *\n * Utility for creating answerable questions displayed in exercises\n *\n * Different answer types produce different kinds of input displays, and do\n * different kinds of checking on the solutions.\n *\n * Each of the objects contain two functions, setup and createValidator.\n *\n * The setup function takes a solutionarea and solution, and performs setup\n * within the solutionarea, and then returns an object which contains:\n *\n * answer: a function which, when called, will retrieve the current answer from\n * the solutionarea, which can then be validated using the validator\n * function\n * validator: a function returned from the createValidator function (defined\n * below)\n * solution: the correct answer to the problem\n * showGuess: a function which, when given a guess, shows the guess within the\n * provided solutionarea\n * showGuessCustom: a function which displays parts of a guess that are not\n * within the solutionarea; currently only used for custom\n * answers\n *\n * The createValidator function only takes a solution, and it returns a\n * function which can be used to validate an answer.\n *\n * The resulting validator function returns:\n * - true: if the answer is fully correct\n * - false: if the answer is incorrect\n * - \"\" (the empty string): if no answer has been provided (e.g. the answer box\n * is left unfilled)\n * - a string: if there is some slight error\n *\n * In most cases, setup and createValidator don't really need the solution DOM\n * element so we have setupFunctional and createValidatorFunctional for them\n * which take only $solution.text() and $solution.data(). This makes it easier\n * to reuse specific answer types.\n *\n * TODO(alpert): Think of a less-absurd name for createValidatorFunctional.\n *\n */\nconst KhanAnswerTypes = {\n /*\n * predicate answer type\n *\n * performs simple predicate-based checking of a numeric solution, with\n * different kinds of number formats\n *\n * Uses the data-forms option on the solution to choose which number formats\n * are acceptable. Available data-forms:\n *\n * - integer: 3\n * - proper: 3/5\n * - improper: 5/3\n * - pi: 3 pi\n * - log: log(5)\n * - percent: 15%\n * - mixed: 1 1/3\n * - decimal: 1.7\n *\n * The solution should be a predicate of the form:\n *\n * function(guess, maxError) {\n * return abs(guess - 3) < maxError;\n * }\n *\n */\n predicate: {\n defaultForms: \"integer, proper, improper, mixed, decimal\",\n createValidatorFunctional: function (\n predicate: Predicate,\n options: any,\n ): (arg1: Guess) => Score {\n // Extract the options from the given solution object\n options = _.extend(\n {\n simplify: \"required\",\n ratio: false,\n forms: KhanAnswerTypes.predicate.defaultForms,\n },\n options,\n );\n let acceptableForms;\n // this is maintaining backwards compatibility\n // TODO(merlob) fix all places that depend on this, then delete\n if (!_.isArray(options.forms)) {\n acceptableForms = options.forms.split(/\\s*,\\s*/);\n } else {\n acceptableForms = options.forms;\n }\n\n // TODO(jack): remove options.inexact in favor of options.maxError\n if (options.inexact === undefined) {\n // If we aren't allowing inexact, ensure that we don't have a\n // large maxError as well.\n options.maxError = 0;\n }\n // Allow a small tolerance on maxError, to avoid numerical\n // representation issues (2.3 should be correct for a solution of\n // 2.45 with maxError=0.15).\n options.maxError = +options.maxError + MAXERROR_EPSILON;\n\n // If percent is an acceptable form, make sure it's the last one\n // in the list so we don't prematurely complain about not having\n // a percent sign when the user entered the correct answer in a\n // different form (such as a decimal or fraction)\n if (_.contains(acceptableForms, \"percent\")) {\n acceptableForms = _.without(acceptableForms, \"percent\");\n acceptableForms.push(\"percent\");\n }\n\n // Take text looking like a fraction, and turn it into a number\n const fractionTransformer = function (\n text,\n ): ReadonlyArray<TransformedFraction> {\n text = text\n // Replace unicode minus sign with hyphen\n .replace(/\\u2212/, \"-\")\n // Remove space after +, -\n .replace(/([+-])\\s+/g, \"$1\")\n // Remove leading/trailing whitespace\n .replace(/(^\\s*)|(\\s*$)/gi, \"\");\n\n // Extract numerator and denominator\n const match = text.match(/^([+-]?\\d+)\\s*\\/\\s*([+-]?\\d+)$/);\n // Fractions are represented as \"-\\frac{numerator}{denominator}\"\n // in Mobile device input instead of \"numerator/denominator\" as\n // in web-browser.\n const mobileDeviceMatch = text.match(\n /^([+-]?)\\\\frac\\{([+-]?\\d+)\\}\\{([+-]?\\d+)\\}$/,\n );\n const parsedInt = parseInt(text, 10);\n if (match || mobileDeviceMatch) {\n let num;\n let denom;\n let simplified = true;\n if (match) {\n num = parseFloat(match[1]);\n denom = parseFloat(match[2]);\n } else {\n num = parseFloat(mobileDeviceMatch[2]);\n if (mobileDeviceMatch[1] === \"-\") {\n if (num < 0) {\n simplified = false;\n }\n num = -num;\n }\n denom = parseFloat(mobileDeviceMatch[3]);\n }\n\n simplified =\n simplified &&\n denom > 0 &&\n (options.ratio || denom !== 1) &&\n KhanMath.getGCD(num, denom) === 1;\n return [\n {\n value: num / denom,\n exact: simplified,\n },\n ];\n }\n if (!isNaN(parsedInt) && \"\" + parsedInt === text) {\n return [\n {\n value: parsedInt,\n exact: true,\n },\n ];\n }\n\n return [];\n };\n\n /*\n * Different forms of numbers\n *\n * Each function returns a list of objects of the form:\n *\n * {\n * value: numerical value,\n * exact: true/false\n * }\n */\n const forms = {\n // integer, which is encompassed by decimal\n integer: function (text) {\n // Compare the decimal form to the decimal form rounded to\n // an integer. Only accept if the user actually entered an\n // integer.\n const decimal = forms.decimal(text);\n const rounded = forms.decimal(text, 1);\n if (\n (decimal[0].value != null &&\n decimal[0].value === rounded[0].value) ||\n (decimal[1].value != null &&\n decimal[1].value === rounded[1].value)\n ) {\n return decimal;\n }\n return [];\n },\n\n // A proper fraction\n proper: function (text) {\n const transformed = fractionTransformer(text);\n return transformed.flatMap((o: TransformedFraction) => {\n // All fractions that are less than 1\n if (Math.abs(o.value) < 1) {\n return [o];\n }\n return [];\n });\n },\n\n // an improper fraction\n improper: function (text) {\n // As our answer keys are always in simplest form, we need\n // to check for the existence of a fraction in the input before\n // validating the answer. If no fraction is found, we consider\n // the answer to be incorrect.\n const fractionExists: boolean =\n text.includes(\"/\") || text.match(/\\\\(d?frac)/);\n\n if (!fractionExists) {\n return [];\n }\n\n const transformed = fractionTransformer(text);\n return transformed.flatMap((o: TransformedFraction) => {\n // All fractions that are greater than 1\n if (Math.abs(o.value) >= 1) {\n return [o];\n }\n return [];\n });\n },\n\n // pi-like numbers\n pi: function (text) {\n let match;\n let possibilities: ReadonlyArray<any> = [];\n\n // Replace unicode minus sign with hyphen\n text = text.replace(/\\u2212/, \"-\");\n\n // - pi\n // (Note: we also support \\pi (for TeX), p, tau (and \\tau,\n // and t), pau.)\n if (\n (match = text.match(\n /^([+-]?)\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n possibilities = [\n {\n value: parseFloat(match[1] + \"1\"),\n exact: true,\n },\n ];\n\n // 5 / 6 pi\n } else if (\n (match = text.match(\n /^([+-]?\\s*\\d+\\s*(?:\\/\\s*[+-]?\\s*\\d+)?)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n possibilities = fractionTransformer(match[1]);\n\n // 4 5 / 6 pi\n } else if (\n (match = text.match(\n /^([+-]?)\\s*(\\d+)\\s*([+-]?\\d+)\\s*\\/\\s*([+-]?\\d+)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n const sign = parseFloat(match[1] + \"1\");\n const integ = parseFloat(match[2]);\n const num = parseFloat(match[3]);\n const denom = parseFloat(match[4]);\n const simplified =\n num < denom && KhanMath.getGCD(num, denom) === 1;\n\n possibilities = [\n {\n value: sign * (integ + num / denom),\n exact: simplified,\n },\n ];\n\n // 5 pi / 6\n } else if (\n (match = text.match(\n /^([+-]?\\s*\\d+)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)\\s*(?:\\/\\s*([+-]?\\s*\\d+))?$/i,\n ))\n ) {\n possibilities = fractionTransformer(\n match[1] + \"/\" + match[3],\n );\n\n // - pi / 4\n } else if (\n (match = text.match(\n /^([+-]?)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)\\s*(?:\\/\\s*([+-]?\\d+))?$/i,\n ))\n ) {\n possibilities = fractionTransformer(\n match[1] + \"1/\" + match[3],\n );\n\n // 0\n } else if (text === \"0\") {\n possibilities = [{value: 0, exact: true}];\n\n // 0.5 pi (fallback)\n } else if (\n (match = text.match(\n /^(.+)\\s*\\*?\\s*(\\\\?pi|p|\\u03c0|\\\\?tau|t|\\u03c4|pau)$/i,\n ))\n ) {\n possibilities = forms.decimal(match[1]);\n } else {\n possibilities = _.reduce(\n KhanAnswerTypes.predicate.defaultForms.split(\n /\\s*,\\s*/,\n ),\n function (memo, form) {\n return memo.concat(forms[form](text));\n },\n [],\n );\n\n // If the answer is a floating point number that's\n // near a multiple of pi, mark is as being possibly\n // an approximation of pi. We actually check if\n // it's a plausible approximation of pi/12, since\n // sometimes the correct answer is like pi/3 or pi/4.\n // We also say it's a pi-approximation if it involves\n // x/7 (since 22/7 is an approximation of pi.)\n // Never mark an integer as being an approximation\n // of pi.\n let approximatesPi = false;\n const number = parseFloat(text);\n if (!isNaN(number) && number !== parseInt(text)) {\n const piMult = Math.PI / 12;\n const roundedNumber =\n piMult * Math.round(number / piMult);\n if (Math.abs(number - roundedNumber) < 0.01) {\n approximatesPi = true;\n }\n } else if (text.match(/\\/\\s*7/)) {\n approximatesPi = true;\n }\n if (approximatesPi) {\n _.each(possibilities, function (possibility) {\n possibility.piApprox = true;\n });\n }\n return possibilities;\n }\n\n let multiplier = Math.PI;\n if (text.match(/\\\\?tau|t|\\u03c4/)) {\n multiplier = Math.PI * 2;\n }\n\n // We're taking an early stand along side xkcd in the\n // inevitable ti vs. pau debate... http://xkcd.com/1292\n if (text.match(/pau/)) {\n multiplier = Math.PI * 1.5;\n }\n\n possibilities.forEach((possibility) => {\n possibility.value *= multiplier;\n });\n return possibilities;\n },\n\n // Converts '' to 1 and '-' to -1 so you can write \"[___] x\"\n // and accept sane things\n coefficient: function (text) {\n let possibilities:\n | Array<never>\n | Array<{\n exact: boolean;\n value: number;\n }> = [];\n\n // Replace unicode minus sign with hyphen\n text = text.replace(/\\u2212/, \"-\");\n\n if (text === \"\") {\n possibilities = [{value: 1, exact: true}];\n } else if (text === \"-\") {\n possibilities = [{value: -1, exact: true}];\n }\n return possibilities;\n },\n\n // simple log(c) form\n log: function (text) {\n let match;\n let possibilities = [];\n\n // Replace unicode minus sign with hyphen\n text = text.replace(/\\u2212/, \"-\");\n text = text.replace(/[ \\(\\)]/g, \"\");\n\n if ((match = text.match(/^log\\s*(\\S+)\\s*$/i))) {\n // @ts-expect-error - TS2322 - Type '{ value: number | undefined; exact: boolean; }[]' is not assignable to type 'never[]'.\n possibilities = forms.decimal(match[1]);\n } else if (text === \"0\") {\n // @ts-expect-error - TS2322 - Type 'number' is not assignable to type 'never'. | TS2322 - Type 'boolean' is not assignable to type 'never'.\n possibilities = [{value: 0, exact: true}];\n }\n return possibilities;\n },\n\n // Numbers with percent signs\n percent: function (text) {\n text = String(text).trim();\n // store whether or not there is a percent sign\n let hasPercentSign = false;\n\n if (text.indexOf(\"%\") === text.length - 1) {\n text = text.substring(0, text.length - 1).trim();\n hasPercentSign = true;\n }\n\n const transformed = forms.decimal(text);\n transformed.forEach((t) => {\n t.exact = hasPercentSign;\n // @ts-expect-error - TS2532 - Object is possibly 'undefined'.\n t.value = t.value / 100;\n });\n return transformed;\n },\n\n // Mixed numbers, like 1 3/4\n mixed: function (text) {\n const match = text\n // Replace unicode minus sign with hyphen\n .replace(/\\u2212/, \"-\")\n // Remove space after +, -\n .replace(/([+-])\\s+/g, \"$1\")\n // Extract integer, numerator and denominator\n .match(/^([+-]?)(\\d+)\\s+(\\d+)\\s*\\/\\s*(\\d+)$/);\n\n if (match) {\n const sign = parseFloat(match[1] + \"1\");\n const integ = parseFloat(match[2]);\n const num = parseFloat(match[3]);\n const denom = parseFloat(match[4]);\n const simplified =\n num < denom && KhanMath.getGCD(num, denom) === 1;\n\n return [\n {\n value: sign * (integ + num / denom),\n exact: simplified,\n },\n ];\n }\n\n return [];\n },\n\n // Decimal numbers -- compare entered text rounded to\n // 'precision' Reciprical of the precision against the correct\n // answer. We round to 1/1e10 by default, which is healthily\n // less than machine epsilon but should be more than any real\n // decimal answer would use. (The 'integer' answer type uses\n // precision == 1.)\n decimal: function (text: string, precision = 1e10) {\n const normal = function (text) {\n text = String(text).trim();\n\n const match = text\n // Replace unicode minus sign with hyphen\n .replace(/\\u2212/, \"-\")\n // Remove space after +, -\n .replace(/([+-])\\s+/g, \"$1\")\n // Extract integer, numerator and denominator. If\n // commas or spaces are used, they must be in the\n // \"correct\" places\n .match(\n /^([+-]?(?:\\d{1,3}(?:[, ]?\\d{3})*\\.?|\\d{0,3}(?:[, ]?\\d{3})*\\.(?:\\d{3}[, ]?)*\\d{1,3}))$/,\n );\n\n // You can't start a number with `0,`, to prevent us\n // interpeting '0.342' as correct for '342'\n const badLeadingZero = text.match(/^0[0,]*,/);\n\n if (match && !badLeadingZero) {\n let x = parseFloat(match[1].replace(/[, ]/g, \"\"));\n\n if (options.inexact === undefined) {\n x = Math.round(x * precision) / precision;\n }\n\n return x;\n }\n };\n\n const commas = function (text: string) {\n text = text.replace(/([\\.,])/g, function (_, c) {\n return c === \".\" ? \",\" : \".\";\n });\n return normal(text);\n };\n\n return [\n {value: normal(text), exact: true},\n {value: commas(text), exact: true},\n ];\n },\n } as const;\n\n // validator function\n return function (guess: Guess): Score {\n // The fallback variable is used in place of the answer, if no\n // answer is provided (i.e. the field is left blank)\n const fallback =\n options.fallback != null ? \"\" + options.fallback : \"\";\n\n guess = String(guess).trim() || fallback;\n\n const score: Score = {\n empty: guess === \"\",\n correct: false,\n message: null as string | null | undefined,\n guess: guess,\n };\n\n // Iterate over all the acceptable forms\n // and exit if one of the answers is correct.\n //\n // HACK: This function is a bug fix from LEMS-2962;\n // after a transition from jQuery's `each` to JS's `forEach`\n // we realized this code was banking on the ability to:\n // 1. exit early from nested loops (can be tricky outside of functions)\n // 2. mutate external variables (score)\n // Could probably be refactored to be a pure function that\n // returns a score, but this code is poorly tested and prone to break.\n const findCorrectAnswer = () => {\n // WARNING: Don't use `forEach` without additional refactoring\n // because code needs to be able to exit early\n for (const form of acceptableForms) {\n const transformed = forms[form](guess);\n for (let j = 0, l = transformed.length; j < l; j++) {\n const val = transformed[j].value;\n const exact = transformed[j].exact;\n const piApprox = transformed[j].piApprox;\n // If a string was returned, and it exactly matches,\n // return true\n if (predicate(val, options.maxError)) {\n // If the exact correct number was returned,\n // return true\n if (exact || options.simplify === \"optional\") {\n score.correct = true;\n score.message = options.message || null;\n // If the answer is correct, don't say it's\n // empty. This happens, for example, with the\n // coefficient type where guess === \"\" but is\n // interpreted as \"1\" which is correct.\n score.empty = false;\n } else if (form === \"percent\") {\n // Otherwise, an error was returned\n score.empty = true;\n score.message =\n ErrorCodes.MISSING_PERCENT_ERROR;\n } else {\n if (options.simplify !== \"enforced\") {\n score.empty = true;\n }\n score.message =\n ErrorCodes.NEEDS_TO_BE_SIMPLIFIED_ERROR;\n }\n // HACK: The return false below stops the looping of the\n // callback since predicate check succeeded.\n // No more forms to look to verify the user guess.\n return false;\n }\n if (\n piApprox &&\n predicate(val, Math.abs(val * 0.001))\n ) {\n score.empty = true;\n score.message =\n ErrorCodes.APPROXIMATED_PI_ERROR;\n }\n }\n }\n };\n\n // mutates `score`\n findCorrectAnswer();\n\n if (score.correct === false) {\n let interpretedGuess = false;\n _.each(forms, function (form) {\n const anyAreNaN = _.any(form(guess), function (t) {\n return t.value != null && !_.isNaN(t.value);\n });\n\n if (anyAreNaN) {\n interpretedGuess = true;\n }\n });\n if (!interpretedGuess) {\n score.empty = true;\n score.message = ErrorCodes.EXTRA_SYMBOLS_ERROR;\n return score;\n }\n }\n\n return score;\n };\n },\n },\n\n /*\n * number answer type\n *\n * wraps the predicate answer type to performs simple number-based checking\n * of a solution\n */\n number: {\n convertToPredicate: function (\n correctAnswer: string,\n options: any,\n ): [predicate: Predicate, options: any] {\n const correctFloat = parseFloat(correctAnswer);\n\n return [\n function (guess, maxError) {\n return Math.abs(guess - correctFloat) < maxError;\n },\n {\n ...options,\n type: \"predicate\",\n },\n ];\n },\n createValidatorFunctional: function (\n correctAnswer: string,\n options: any,\n ): (arg1: Guess) => Score {\n return KhanAnswerTypes.predicate.createValidatorFunctional(\n ...KhanAnswerTypes.number.convertToPredicate(\n correctAnswer,\n options,\n ),\n );\n },\n },\n\n /*\n * The expression answer type parses a given expression or equation\n * and semantically compares it to the solution. In addition, instant\n * feedback is provided by rendering the last answer that fully parsed.\n *\n * Parsing options:\n * functions (e.g. data-functions=\"f g h\")\n * A space or comma separated list of single-letter variables that\n * should be interpreted as functions. Case sensitive. \"e\" and \"i\"\n * are reserved.\n *\n * no functions specified: f(x+y) == fx + fy\n * with \"f\" as a function: f(x+y) != fx + fy\n *\n * Comparison options:\n * same-form (e.g. data-same-form)\n * If present, the answer must match the solution's structure in\n * addition to evaluating the same. Commutativity and excess negation\n * are ignored, but all other changes will trigger a rejection. Useful\n * for requiring a particular form of an equation, or if the answer\n * must be factored.\n *\n * example question: Factor x^2 + x - 2\n * example solution: (x-1)(x+2)\n * accepted answers: (x-1)(x+2), (x+2)(x-1), ---(-x-2)(-1+x), etc.\n * rejected answers: x^2+x-2, x*x+x-2, x(x+1)-2, (x-1)(x+2)^1, etc.\n * rejection message: Your answer is not in the correct form\n *\n * simplify (e.g. data-simplify)\n * If present, the answer must be fully expanded and simplified. Use\n * carefully - simplification is hard and there may be bugs, or you\n * might not agree on the definition of \"simplified\" used. You will\n * get an error if the provided solution is not itself fully expanded\n * and simplified.\n *\n * example question: Simplify ((n*x^5)^5) / (n^(-2)*x^2)^-3\n * example solution: x^31 / n\n * accepted answers: x^31 / n, x^31 / n^1, x^31 * n^(-1), etc.\n * rejected answers: (x^25 * n^5) / (x^(-6) * n^6), etc.\n * rejection message: Your answer is not fully expanded and simplified\n *\n * Rendering options:\n * times (e.g. data-times)\n * If present, explicit multiplication (such as between numbers) will\n * be rendered with a cross/x symbol (TeX: \\times) instead of the usual\n * center dot (TeX: \\cdot).\n *\n * normal rendering: 2 * 3^x -> 2 \\cdot 3^{x}\n * but with \"times\": 2 * 3^x -> 2 \\times 3^{x}\n */\n expression: {\n parseSolution: function (solutionString: string, options: any): any {\n let solution = KAS.parse(solutionString, options);\n if (!solution.parsed) {\n throw new PerseusError(\n \"The provided solution (\" +\n solutionString +\n \") didn't parse.\",\n Errors.InvalidInput,\n );\n } else if (options.simplified && !solution.expr.isSimplified()) {\n throw new PerseusError(\n \"The provided solution (\" +\n solutionString +\n \") isn't fully expanded and simplified.\",\n Errors.InvalidInput,\n );\n } else {\n solution = solution.expr;\n }\n return solution;\n },\n\n createValidatorFunctional: function (\n solution: any,\n options: any,\n ): (arg1: Guess) => Score {\n return function (guess: Guess): Score {\n const score = {\n empty: false,\n correct: false,\n message: null as string | null | undefined,\n guess: guess,\n // Setting `ungraded` to true indicates that if the\n // guess doesn't match any of the solutions, the guess\n // shouldn't be marked as incorrect; instead, `message`\n // should be shown to the user. This is different from\n // setting `empty` to true, since the behavior of `empty`\n // is that `message` only will be shown if the guess is\n // graded as empty for every solution.\n ungraded: false,\n } as const;\n\n // Don't bother parsing an empty input\n if (!guess) {\n // @ts-expect-error - TS2540 - Cannot assign to 'empty' because it is a read-only property.\n score.empty = true;\n return score;\n }\n\n const answer = KAS.parse(guess, options);\n\n // An unsuccessful parse doesn't count as wrong\n if (!answer.parsed) {\n // @ts-expect-error - TS2540 - Cannot assign to 'empty' because it is a read-only property.\n score.empty = true;\n return score;\n }\n\n // Solution will need to be parsed again if we're creating\n // this from a multiple question type\n if (typeof solution === \"string\") {\n solution = KhanAnswerTypes.expression.parseSolution(\n solution,\n options,\n );\n }\n\n const result = KAS.compare(answer.expr, solution, options);\n\n if (result.equal) {\n // Correct answer\n // @ts-expect-error - TS2540 - Cannot assign to 'correct' because it is a read-only property.\n score.correct = true;\n } else if (\n result.wrongVariableNames ||\n result.wrongVariableCase\n ) {\n // We don't want to give people an error for getting the\n // variable names or the variable case wrong.\n // TODO(aasmund): This should ideally have been handled\n // under the `result.message` condition, but the\n // KAS messages currently aren't translatable.\n // @ts-expect-error - TS2540 - Cannot assign to 'ungraded' because it is a read-only property.\n score.ungraded = true;\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message = result.wrongVariableCase\n ? ErrorCodes.WRONG_CASE_ERROR\n : ErrorCodes.WRONG_LETTER_ERROR;\n // Don't tell the use they're \"almost there\" in this case, that may not be true and isn't helpful.\n // @ts-expect-error - TS2339 - Property 'suppressAlmostThere' does not exist on type '{ readonly empty: false; readonly correct: false; readonly message: string | null | undefined; readonly guess: any; readonly ungraded: false; }'.\n score.suppressAlmostThere = true;\n } else if (result.message) {\n // Nearly correct answer\n // TODO(aasmund): This message also isn't translatable;\n // need to fix that in KAS\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message = result.message;\n } else {\n // Replace x with * and see if it would have been correct\n // TODO(aasmund): I think this branch is effectively dead,\n // because the replacement will only work in situations\n // where the variables are wrong (except if the variable\n // is x, in which case the replacement won't work either),\n // which is handled by another branch. When we implement a\n // more sophisticated variable check, revive this or\n // remove it completely if it will never come into play.\n const answerX = KAS.parse(\n guess.replace(/[xX]/g, \"*\"),\n options,\n );\n if (answerX.parsed) {\n const resultX = KAS.compare(\n answerX.expr,\n solution,\n options,\n );\n if (resultX.equal) {\n // @ts-expect-error - TS2540 - Cannot assign to 'ungraded' because it is a read-only property.\n score.ungraded = true;\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message =\n ErrorCodes.MULTIPLICATION_SIGN_ERROR;\n } else if (resultX.message) {\n // TODO(aasmund): I18nize `score.message`\n // @ts-expect-error - TS2540 - Cannot assign to 'message' because it is a read-only property.\n score.message =\n resultX.message +\n \" Also, I'm a computer. I only understand \" +\n \"multiplication if you use an \" +\n \"asterisk (*) as the multiplication \" +\n \"sign.\";\n }\n }\n }\n return score;\n };\n },\n },\n} as const;\n\nexport default KhanAnswerTypes;\n","import type {\n PerseusCategorizerRubric,\n PerseusCategorizerUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreCategorizer(\n userInput: PerseusCategorizerUserInput,\n rubric: PerseusCategorizerRubric,\n): PerseusScore {\n let allCorrect = true;\n rubric.values.forEach((value, i) => {\n if (userInput.values[i] !== value) {\n allCorrect = false;\n }\n });\n return {\n type: \"points\",\n earned: allCorrect ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreCategorizer;\n","import ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusCategorizerUserInput,\n PerseusCategorizerValidationData,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks userInput from the categorizer widget to see if the user has selected\n * a category for each item.\n * @param userInput - The user's input corresponding to an array of indices that\n * represent the selected category for each row/item.\n * @param validationData - An array of strings corresponding to each row/item\n * @param strings - Used to provide a validation message\n */\nfunction validateCategorizer(\n userInput: PerseusCategorizerUserInput,\n validationData: PerseusCategorizerValidationData,\n): ValidationResult {\n const incomplete = validationData.items.some(\n (_, i) => userInput.values[i] == null,\n );\n\n if (incomplete) {\n return {\n type: \"invalid\",\n message: ErrorCodes.INVALID_SELECTION_ERROR,\n };\n }\n return null;\n}\n\nexport default validateCategorizer;\n","import type {\n PerseusCSProgramUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreCSProgram(userInput: PerseusCSProgramUserInput): PerseusScore {\n // The CS program can tell us whether it's correct or incorrect,\n // and pass an optional message\n if (userInput.status === \"correct\") {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: userInput.message || null,\n };\n }\n if (userInput.status === \"incorrect\") {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: userInput.message || null,\n };\n }\n return {\n type: \"invalid\",\n message: \"Keep going, you're not there yet!\",\n };\n}\n\nexport default scoreCSProgram;\n","import type {\n PerseusDropdownRubric,\n PerseusDropdownUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreDropdown(\n userInput: PerseusDropdownUserInput,\n rubric: PerseusDropdownRubric,\n): PerseusScore {\n const correct = rubric.choices[userInput.value - 1].correct;\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreDropdown;\n","import type {\n PerseusDropdownUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks if the user has selected an item from the dropdown before scoring.\n * This is shown with a userInput value / index other than 0.\n */\nfunction validateDropdown(\n userInput: PerseusDropdownUserInput,\n): ValidationResult {\n if (userInput.value === 0) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return null;\n}\n\nexport default validateDropdown;\n","import * as KAS from \"@khanacademy/kas\";\nimport {\n Errors,\n getDecimalSeparator,\n PerseusError,\n} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport KhanAnswerTypes from \"../../util/answer-types\";\n\nimport type {Score} from \"../../util/answer-types\";\nimport type {\n PerseusExpressionRubric,\n PerseusExpressionUserInput,\n PerseusScore,\n PerseusExpressionAnswerForm,\n} from \"@khanacademy/perseus-core\";\n\n/* Content creators input a list of answers which are matched from top to\n * bottom. The intent is that they can include spcific solutions which should\n * be graded as correct or incorrect (or ungraded!) first, then get more\n * general.\n *\n * We iterate through each answer, trying to match it with the user's input\n * using the following angorithm:\n * - Try to parse the user's input. If it doesn't parse then return \"not\n * graded\".\n * - For each answer:\n * ~ Try to validate the user's input against the answer. The answer is\n * expected to parse.\n * ~ If the user's input validates (the validator judges it \"correct\"), we've\n * matched and can stop considering answers.\n * - If there were no matches or the matching answer is considered \"ungraded\",\n * show the user an error. TODO(joel) - what error?\n * - Otherwise, pass through the resulting points and message.\n */\nfunction scoreExpression(\n userInput: PerseusExpressionUserInput,\n rubric: PerseusExpressionRubric,\n locale: string,\n): PerseusScore {\n const options = _.clone(rubric);\n _.extend(options, {\n decimal_separator: getDecimalSeparator(locale),\n });\n\n const createValidator = (answer: PerseusExpressionAnswerForm) => {\n // We give options to KAS.parse here because it is parsing the\n // solution answer, not the student answer, and we don't want a\n // solution to work if the student is using a different language\n // (different from the content creation language, ie. English).\n const expression = KAS.parse(answer.value, rubric);\n // An answer may not be parsed if the expression was defined\n // incorrectly. For example if the answer is using a symbol defined\n // in the function variables list for the expression.\n if (!expression.parsed) {\n /* c8 ignore next */\n throw new PerseusError(\n \"Unable to parse solution answer for expression\",\n Errors.InvalidInput,\n {metadata: {rubric: JSON.stringify(rubric)}},\n );\n }\n\n return KhanAnswerTypes.expression.createValidatorFunctional(\n expression.expr,\n _({}).extend(options, {\n simplify: answer.simplify,\n form: answer.form,\n }),\n );\n };\n\n // Find the first answer form that matches the user's input and that\n // is considered correct. Also, track whether the input is\n // considered \"empty\" for all answer forms, and keep the validation\n // result for the first answer form for which the user's input was\n // considered \"ungraded\".\n // (Terminology reminder: the answer forms are provided by the\n // assessment items; they are not the user's input. Each one might\n // represent a correct answer, an incorrect one (if the exercise\n // creator has predicted certain common wrong answers and wants to\n // provide guidance via a message), or an ungraded one (same idea,\n // but without giving the user an incorrect mark for the question).\n let matchingAnswerForm: PerseusExpressionAnswerForm | undefined;\n let matchMessage: string | undefined;\n let allEmpty = true;\n let firstUngradedResult: Score | undefined;\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n for (const answerForm of rubric.answerForms || []) {\n const validator = createValidator(answerForm);\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!validator) {\n continue;\n }\n\n const result = validator(userInput);\n\n // Short-circuit as soon as the user's input matches some answer\n // (independently of whether the answer is correct)\n if (result.correct) {\n matchingAnswerForm = answerForm;\n matchMessage = result.message || \"\";\n break;\n }\n\n allEmpty = allEmpty && result.empty;\n // If this answer form is correct and the user's input is considered\n // \"ungraded\" for it, we'll want to keep the evaluation result for\n // later. If the user's input doesn't match any answer forms, we'll\n // show the message from this validation.\n if (\n answerForm.considered === \"correct\" &&\n result.ungraded &&\n !firstUngradedResult\n ) {\n firstUngradedResult = result;\n }\n }\n\n // Now check to see if we matched any answer form at all, and if\n // we did, whether it's considered correct, incorrect, or ungraded\n if (!matchingAnswerForm) {\n if (firstUngradedResult) {\n // While we didn't directly match with any answer form, we\n // did at some point get an \"ungraded\" validation result,\n // which might indicate e.g. a mismatch in variable casing.\n // We'll return \"invalid\", which will let the user try again\n // with no penalty, and the hopefully helpful validation\n // message.\n return {\n type: \"invalid\",\n message: firstUngradedResult.message,\n suppressAlmostThere: firstUngradedResult.suppressAlmostThere,\n };\n }\n if (allEmpty) {\n // If everything graded as empty, it's invalid.\n return {\n type: \"invalid\",\n message: null,\n };\n }\n // We fell through all the possibilities and we're not empty,\n // so the answer is considered incorrect.\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n };\n }\n if (matchingAnswerForm.considered === \"ungraded\") {\n return {\n type: \"invalid\",\n message: matchMessage,\n };\n }\n // We matched a graded answer form, so we can now tell the user\n // whether their input was correct or incorrect, and hand out\n // points accordingly\n return {\n type: \"points\",\n earned: matchingAnswerForm.considered === \"correct\" ? 1 : 0,\n total: 1,\n message: matchMessage,\n };\n}\n\nexport default scoreExpression;\n","import type {\n PerseusExpressionUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the expression widget to see if it is scorable.\n *\n * Note: Most of the expression widget's validation requires the Rubric because\n * of its use of KhanAnswerTypes as a core part of scoring.\n *\n * @see `scoreExpression()` for more details.\n */\nfunction validateExpression(\n userInput: PerseusExpressionUserInput,\n): ValidationResult {\n if (userInput === \"\") {\n return {type: \"invalid\", message: null};\n }\n\n return null;\n}\n\nexport default validateExpression;\n","import {Errors, PerseusError, GrapherUtil} from \"@khanacademy/perseus-core\";\n\nimport type {\n PerseusGrapherRubric,\n PerseusGrapherUserInput,\n PerseusScore,\n GrapherAnswerTypes,\n} from \"@khanacademy/perseus-core\";\n\nfunction getCoefficientsByType(\n data: GrapherAnswerTypes,\n): ReadonlyArray<number> | undefined {\n if (data.coords == null) {\n return undefined;\n }\n if (data.type === \"exponential\" || data.type === \"logarithm\") {\n const grader = GrapherUtil.functionForType(data.type);\n return grader.getCoefficients(data.coords, data.asymptote);\n } else if (\n data.type === \"linear\" ||\n data.type === \"quadratic\" ||\n data.type === \"absolute_value\" ||\n data.type === \"sinusoid\" ||\n data.type === \"tangent\"\n ) {\n const grader = GrapherUtil.functionForType(data.type);\n return grader.getCoefficients(data.coords);\n } else {\n throw new PerseusError(\"Invalid grapher type\", Errors.InvalidInput);\n }\n}\n\nfunction scoreGrapher(\n userInput: PerseusGrapherUserInput,\n rubric: PerseusGrapherRubric,\n): PerseusScore {\n if (userInput.type !== rubric.correct.type) {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n }\n\n // We haven't moved the coords\n if (userInput.coords == null) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n // Get new function handler for grading\n const grader = GrapherUtil.functionForType(userInput.type);\n const guessCoeffs = getCoefficientsByType(userInput);\n const correctCoeffs = getCoefficientsByType(rubric.correct);\n\n if (guessCoeffs == null || correctCoeffs == null) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n if (grader.areEqual(guessCoeffs, correctCoeffs)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreGrapher;\n","import type {\n PerseusIFrameUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n// TODO: merge this with scoreCSProgram, it's the same code\nfunction scoreIframe(userInput: PerseusIFrameUserInput): PerseusScore {\n // The iframe can tell us whether it's correct or incorrect,\n // and pass an optional message\n if (userInput.status === \"correct\") {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: userInput.message || null,\n };\n }\n if (userInput.status === \"incorrect\") {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: userInput.message || null,\n };\n }\n return {\n type: \"invalid\",\n message: \"Keep going, you're not there yet!\",\n };\n}\n\nexport default scoreIframe;\n","import {\n number as knumber,\n geometry,\n angles,\n coefficients,\n} from \"@khanacademy/kmath\";\nimport {\n approximateDeepEqual,\n approximateEqual,\n deepClone,\n} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusInteractiveGraphUserInput,\n PerseusInteractiveGraphRubric,\n PerseusScore,\n Coord,\n} from \"@khanacademy/perseus-core\";\n\nconst {collinear, canonicalSineCoefficients, similar, clockwise} = geometry;\nconst {getClockwiseAngle} = angles;\nconst {getSinusoidCoefficients, getQuadraticCoefficients} = coefficients;\n\nfunction scoreInteractiveGraph(\n userInput: PerseusInteractiveGraphUserInput,\n rubric: PerseusInteractiveGraphRubric,\n): PerseusScore {\n // None-type graphs are not graded\n if (userInput.type === \"none\" && rubric.correct.type === \"none\") {\n return {\n type: \"points\",\n earned: 0,\n total: 0,\n message: null,\n };\n }\n\n // When nothing has moved, there will neither be coords nor the\n // circle's center/radius fields. When those fields are absent, skip\n // all these checks; just go mark the answer as empty.\n const hasValue = Boolean(\n // @ts-expect-error - TS2339 - Property 'coords' does not exist on type 'PerseusGraphType'.\n userInput.coords ||\n // @ts-expect-error - TS2339 - Property 'center' does not exist on type 'PerseusGraphType'. | TS2339 - Property 'radius' does not exist on type 'PerseusGraphType'.\n (userInput.center && userInput.radius),\n );\n\n if (userInput.type === rubric.correct.type && hasValue) {\n if (\n userInput.type === \"linear\" &&\n rubric.correct.type === \"linear\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords;\n const correct = rubric.correct.coords;\n\n // If both of the guess points are on the correct line, it's\n // correct.\n if (\n collinear(correct[0], correct[1], guess[0]) &&\n collinear(correct[0], correct[1], guess[1])\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"linear-system\" &&\n rubric.correct.type === \"linear-system\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords;\n const correct = rubric.correct.coords;\n\n if (\n (collinear(correct[0][0], correct[0][1], guess[0][0]) &&\n collinear(correct[0][0], correct[0][1], guess[0][1]) &&\n collinear(correct[1][0], correct[1][1], guess[1][0]) &&\n collinear(correct[1][0], correct[1][1], guess[1][1])) ||\n (collinear(correct[0][0], correct[0][1], guess[1][0]) &&\n collinear(correct[0][0], correct[0][1], guess[1][1]) &&\n collinear(correct[1][0], correct[1][1], guess[0][0]) &&\n collinear(correct[1][0], correct[1][1], guess[0][1]))\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"quadratic\" &&\n rubric.correct.type === \"quadratic\" &&\n userInput.coords != null\n ) {\n // If the parabola coefficients match, it's correct.\n const guessCoeffs = getQuadraticCoefficients(userInput.coords);\n const correctCoeffs = getQuadraticCoefficients(\n rubric.correct.coords,\n );\n if (approximateDeepEqual(guessCoeffs, correctCoeffs)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"sinusoid\" &&\n rubric.correct.type === \"sinusoid\" &&\n userInput.coords != null\n ) {\n const guessCoeffs = getSinusoidCoefficients(userInput.coords);\n const correctCoeffs = getSinusoidCoefficients(\n rubric.correct.coords,\n );\n\n const canonicalGuessCoeffs = canonicalSineCoefficients(guessCoeffs);\n const canonicalCorrectCoeffs =\n canonicalSineCoefficients(correctCoeffs);\n // If the canonical coefficients match, it's correct.\n if (\n approximateDeepEqual(\n canonicalGuessCoeffs,\n canonicalCorrectCoeffs,\n )\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"circle\" &&\n rubric.correct.type === \"circle\"\n ) {\n if (\n approximateDeepEqual(userInput.center, rubric.correct.center) &&\n approximateEqual(userInput.radius, rubric.correct.radius)\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"point\" &&\n rubric.correct.type === \"point\" &&\n userInput.coords != null\n ) {\n let correct = rubric.correct.coords;\n if (correct == null) {\n throw new Error(\"Point graph rubric has null coords\");\n }\n const guess = userInput.coords.slice();\n correct = correct.slice();\n // Everything's already rounded so we shouldn't need to do an\n // eq() comparison but _.isEqual(0, -0) is false, so we'll use\n // eq() anyway. The sort should be fine because it'll stringify\n // it and -0 converted to a string is \"0\"\n // TODO(benchristel): once we drop support for Safari 15, use\n // toSorted here to avoid mutating the input arrays!\n guess?.sort();\n correct.sort();\n if (approximateDeepEqual(guess, correct)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"polygon\" &&\n rubric.correct.type === \"polygon\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords.slice();\n const correct = rubric.correct.coords.slice();\n\n let match;\n if (rubric.correct.match === \"similar\") {\n match = similar(guess, correct, Number.POSITIVE_INFINITY);\n } else if (rubric.correct.match === \"congruent\") {\n match = similar(guess, correct, knumber.DEFAULT_TOLERANCE);\n } else if (rubric.correct.match === \"approx\") {\n match = similar(guess, correct, 0.1);\n } else {\n /* exact */\n guess.sort();\n correct.sort();\n match = approximateDeepEqual(guess, correct);\n }\n\n if (match) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"segment\" &&\n rubric.correct.type === \"segment\" &&\n userInput.coords != null\n ) {\n let guess = deepClone(userInput.coords);\n let correct = deepClone(rubric.correct.coords);\n guess = _.invoke(guess, \"sort\").sort();\n correct = _.invoke(correct, \"sort\").sort();\n if (approximateDeepEqual(guess, correct)) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"ray\" &&\n rubric.correct.type === \"ray\" &&\n userInput.coords != null\n ) {\n const guess = userInput.coords;\n const correct = rubric.correct.coords;\n if (\n approximateDeepEqual(guess[0], correct[0]) &&\n collinear(correct[0], correct[1], guess[1])\n ) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n } else if (\n userInput.type === \"angle\" &&\n rubric.correct.type === \"angle\"\n ) {\n const coords = userInput.coords;\n const correct = rubric.correct.coords;\n const allowReflexAngles = rubric.correct.allowReflexAngles;\n\n // While the angle graph should always have 3 points, our types\n // technically allow for null values. We'll check for that here.\n // TODO: (LEMS-2857) We would like to update the type of coords\n // to be non-nullable, as the graph should always have 3 points.\n if (!coords) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n // We need to check both the direction of the angle and the\n // whether the graph allows for reflexive angles in order to\n // to determine if we need to reverse the coords for scoring.\n const areClockwise = clockwise([coords[0], coords[2], coords[1]]);\n const shouldReverseCoords = areClockwise && !allowReflexAngles;\n const guess = shouldReverseCoords\n ? (coords.slice().reverse() as [Coord, Coord, Coord])\n : coords;\n\n let match;\n if (rubric.correct.match === \"congruent\") {\n const angles = _.map([guess, correct], function (coords) {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!coords) {\n return false;\n }\n const angle = getClockwiseAngle(coords, allowReflexAngles);\n return angle;\n });\n // @ts-expect-error - TS2556 - A spread argument must either have a tuple type or be passed to a rest parameter.\n match = approximateEqual(...angles);\n } else {\n /* exact */\n match =\n approximateDeepEqual(guess[1], correct[1]) &&\n collinear(correct[1], correct[0], guess[0]) &&\n collinear(correct[1], correct[2], guess[2]);\n }\n\n if (match) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n }\n }\n\n // The input wasn't correct, so check if it's a blank input or if it's\n // actually just wrong\n if (!hasValue || _.isEqual(userInput, rubric.graph)) {\n // We're where we started.\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreInteractiveGraph;\n","import type {\n PerseusLabelImageUserInput,\n PerseusLabelImageRubric,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n// Question state for marker as result of user selected answers.\nexport type InteractiveMarkerScore = {\n // Whether user selected answers for the marker.\n hasAnswers: boolean;\n // Whether user (answer) selection answered the question correctly.\n isCorrect: boolean;\n};\n\nexport function scoreLabelImageMarker(\n userInput: PerseusLabelImageUserInput[\"markers\"][number][\"selected\"],\n rubric: PerseusLabelImageRubric[\"markers\"][number][\"answers\"],\n): InteractiveMarkerScore {\n const score = {\n hasAnswers: false,\n isCorrect: false,\n };\n\n if (userInput && userInput.length > 0) {\n score.hasAnswers = true;\n }\n\n if (rubric.length > 0) {\n if (userInput && userInput.length === rubric.length) {\n // All correct answers are selected by the user.\n score.isCorrect = userInput.every((choice) =>\n rubric.includes(choice),\n );\n }\n } else if (!userInput || userInput.length === 0) {\n // Correct as no answers should be selected by the user.\n score.isCorrect = true;\n }\n\n return score;\n}\n\nfunction scoreLabelImage(\n userInput: PerseusLabelImageUserInput,\n rubric: PerseusLabelImageRubric,\n): PerseusScore {\n let numCorrect = 0;\n\n for (let i = 0; i < userInput.markers.length; i++) {\n const score = scoreLabelImageMarker(\n userInput.markers[i].selected,\n rubric.markers[i].answers,\n );\n\n if (score.isCorrect) {\n numCorrect++;\n }\n }\n\n return {\n type: \"points\",\n // Markers with no expected answers are graded as correct if user\n // makes no answer selection.\n earned: numCorrect === userInput.markers.length ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreLabelImage;\n","import _ from \"underscore\";\n\nimport type {\n PerseusMatcherRubric,\n PerseusMatcherUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreMatcher(\n userInput: PerseusMatcherUserInput,\n rubric: PerseusMatcherRubric,\n): PerseusScore {\n const correct =\n _.isEqual(userInput.left, rubric.left) &&\n _.isEqual(userInput.right, rubric.right);\n\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreMatcher;\n","import {getMatrixSize} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport KhanAnswerTypes from \"../../util/answer-types\";\n\nimport type {\n PerseusMatrixRubric,\n PerseusMatrixUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreMatrix(\n userInput: PerseusMatrixUserInput,\n rubric: PerseusMatrixRubric,\n): PerseusScore {\n const solution = rubric.answers;\n const supplied = userInput.answers;\n const solutionSize = getMatrixSize(solution);\n const suppliedSize = getMatrixSize(supplied);\n\n const incorrectSize =\n solutionSize[0] !== suppliedSize[0] ||\n solutionSize[1] !== suppliedSize[1];\n\n const createValidator = KhanAnswerTypes.number.createValidatorFunctional;\n let message = null;\n let incorrect = false;\n _(suppliedSize[0]).times((row) => {\n _(suppliedSize[1]).times((col) => {\n if (!incorrectSize) {\n const validator = createValidator(\n // @ts-expect-error - TS2345 - Argument of type 'number' is not assignable to parameter of type 'string'.\n solution[row][col],\n {\n simplify: true,\n },\n );\n const result = validator(supplied[row][col]);\n if (result.message) {\n // @ts-expect-error - TS2322 - Type 'string' is not assignable to type 'null'.\n message = result.message;\n }\n if (!result.correct) {\n incorrect = true;\n }\n }\n });\n });\n\n if (incorrectSize) {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n }\n\n return {\n type: \"points\",\n earned: incorrect ? 0 : 1,\n total: 1,\n message: message,\n };\n}\n\nexport default scoreMatrix;\n","import {getMatrixSize} from \"@khanacademy/perseus-core\";\n\nimport ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusMatrixUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the matrix widget to see if it is scorable.\n *\n * Note: The matrix widget cannot do much validation without the Scoring\n * Data because of its use of KhanAnswerTypes as a core part of scoring.\n *\n * @see `scoreMatrix()` for more details.\n */\nfunction validateMatrix(userInput: PerseusMatrixUserInput): ValidationResult {\n const supplied = userInput.answers;\n const suppliedSize = getMatrixSize(supplied);\n\n for (let row = 0; row < suppliedSize[0]; row++) {\n for (let col = 0; col < suppliedSize[1]; col++) {\n if (\n supplied[row][col] == null ||\n supplied[row][col].toString().length === 0\n ) {\n return {\n type: \"invalid\",\n message: ErrorCodes.FILL_ALL_CELLS_ERROR,\n };\n }\n }\n }\n\n return null;\n}\n\nexport default validateMatrix;\n","import {number as knumber} from \"@khanacademy/kmath\";\n\nimport type {\n PerseusNumberLineRubric,\n PerseusNumberLineUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreNumberLine(\n userInput: PerseusNumberLineUserInput,\n rubric: PerseusNumberLineRubric,\n): PerseusScore {\n const range = rubric.range;\n const start = rubric.initialX != null ? rubric.initialX : range[0];\n const startRel = rubric.isInequality ? \"ge\" : \"eq\";\n const correctRel = rubric.correctRel || \"eq\";\n const correctPos = knumber.equal(\n userInput.numLinePosition,\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n rubric.correctX || 0,\n );\n\n if (correctPos && correctRel === userInput.rel) {\n return {\n type: \"points\",\n earned: 1,\n total: 1,\n message: null,\n };\n }\n if (userInput.numLinePosition === start && userInput.rel === startRel) {\n // We're where we started.\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreNumberLine;\n","import type {\n PerseusNumberLineUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input is within the allowed range and not the same as the initial\n * state.\n * @param userInput\n * @see 'scoreNumberLine' for the scoring logic.\n */\nfunction validateNumberLine(\n userInput: PerseusNumberLineUserInput,\n): Extract<PerseusScore, {type: \"invalid\"}> | null {\n const divisionRange = userInput.divisionRange;\n const outsideAllowedRange =\n userInput.numDivisions > divisionRange[1] ||\n userInput.numDivisions < divisionRange[0];\n\n // TODO: I don't think isTickCrtl is a thing anymore\n if (userInput.isTickCrtl && outsideAllowedRange) {\n return {\n type: \"invalid\",\n message: \"Number of divisions is outside the allowed range.\",\n };\n }\n return null;\n}\n\nexport default validateNumberLine;\n","/*\n * In this file, an `expression` is some portion of valid TeX enclosed in\n * curly brackets.\n */\n\n/*\n * Find the index at which an expression ends, i.e., has an unmatched\n * closing curly bracket. This method assumes that we start with a non-open\n * bracket character and end when we've seen more left than right brackets\n * (rather than assuming that we start with a bracket character and wait for\n * bracket equality).\n */\nfunction findEndpoint(tex, currentIndex: number) {\n let bracketDepth = 0;\n\n for (let i = currentIndex, len = tex.length; i < len; i++) {\n const c = tex[i];\n\n if (c === \"{\") {\n bracketDepth++;\n } else if (c === \"}\") {\n bracketDepth--;\n }\n\n if (bracketDepth < 0) {\n return i;\n }\n }\n // If we never see unbalanced curly brackets, default to the\n // entire string\n return tex.length;\n}\n\n/*\n * Parses an individual set of curly brackets into TeX.\n */\nfunction parseNextExpression(\n tex: string,\n currentIndex: number,\n handler: (exp1: string, exp2: string) => string,\n) {\n // Find the first '{' and grab subsequent TeX\n // Ex) tex: '{3}{7}', and we want the '3'\n const openBracketIndex = tex.indexOf(\"{\", currentIndex);\n\n // If there is no open bracket, set the endpoint to the end of the string\n // and the expression to an empty string. This helps ensure we don't\n // get stuck in an infinite loop when users handtype TeX.\n if (openBracketIndex === -1) {\n return {\n endpoint: tex.length,\n expression: \"\",\n };\n }\n\n const nextExpIndex = openBracketIndex + 1;\n\n // Truncate to only contain remaining TeX\n const endpoint = findEndpoint(tex, nextExpIndex);\n const expressionTeX = tex.substring(nextExpIndex, endpoint);\n\n const parsedExp = walkTex(expressionTeX, handler);\n\n return {\n endpoint: endpoint,\n expression: parsedExp,\n };\n}\n\nfunction getNextFracIndex(tex: string, currentIndex: number) {\n const dfrac = \"\\\\dfrac\";\n const frac = \"\\\\frac\";\n\n const nextFrac = tex.indexOf(frac, currentIndex);\n const nextDFrac = tex.indexOf(dfrac, currentIndex);\n\n if (nextFrac > -1 && nextDFrac > -1) {\n return Math.min(nextFrac, nextDFrac);\n }\n if (nextFrac > -1) {\n return nextFrac;\n }\n if (nextDFrac > -1) {\n return nextDFrac;\n }\n return -1;\n}\n\nfunction walkTex(\n tex: string,\n handler: (exp1: string, exp2: string) => string,\n): string {\n if (!tex) {\n return \"\";\n }\n\n // Ex) tex: '2 \\dfrac {3}{7}'\n let parsedString = \"\";\n let currentIndex = 0;\n let nextFrac = getNextFracIndex(tex, currentIndex);\n\n // For each \\dfrac, find the two expressions (wrapped in {}) and recur\n while (nextFrac > -1) {\n // Gather first fragment, preceding \\dfrac\n // Ex) parsedString: '2 '\n parsedString += tex.substring(currentIndex, nextFrac);\n\n // Remove everything preceding \\dfrac, which has been parsed\n currentIndex = nextFrac;\n\n // Parse first expression and move index past it\n // Ex) firstParsedExpression.expression: '3'\n const firstParsedExpression = parseNextExpression(\n tex,\n currentIndex,\n handler,\n );\n currentIndex = firstParsedExpression.endpoint + 1;\n\n // Parse second expression\n // Ex) secondParsedExpression.expression: '7'\n const secondParsedExpression = parseNextExpression(\n tex,\n currentIndex,\n handler,\n );\n currentIndex = secondParsedExpression.endpoint + 1;\n\n // Add expressions to running total of parsed expressions\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (parsedString.length) {\n parsedString += \" \";\n }\n\n // Apply a custom handler based on the parsed subexpressions\n parsedString += handler(\n firstParsedExpression.expression,\n secondParsedExpression.expression,\n );\n\n // Find next DFrac, relative to currentIndex\n nextFrac = getNextFracIndex(tex, currentIndex);\n }\n\n // Add remaining TeX, which is \\dfrac-free\n parsedString += tex.slice(currentIndex);\n\n return parsedString;\n}\n\n/*\n * Modify a TeX expression, returning another TeX expression. The resulting\n * expression will have its innermost fractions stubbed out with \\fracs\n * (as opposed to \\dfracs). All other content will remain untouched.\n */\nexport function modifyTex(tex: string): string {\n function isNestedFraction(tex: string) {\n return tex.indexOf(\"\\\\frac\") > -1 || tex.indexOf(\"\\\\dfrac\") > -1;\n }\n const handler = function (exp1: string, exp2: string) {\n let prefix;\n if (isNestedFraction(exp1) || isNestedFraction(exp2)) {\n prefix = \"\\\\dfrac\";\n } else {\n prefix = \"\\\\frac\";\n }\n return prefix + \" {\" + exp1 + \"}{\" + exp2 + \"}\";\n };\n return walkTex(tex, handler);\n}\n\n/*\n * Parse a TeX expression into something interpretable by input-number.\n * The process is concerned with: (1) parsing fractions, i.e., \\dfracs; and\n * (2) removing backslash-escaping from certain characters (right now, only\n * percent signs).\n *\n * The basic algorithm for handling \\dfracs splits on \\dfracs and then recurs\n * on the subsequent \"expressions\", i.e., the {} pairs that follow \\dfrac. The\n * recursion is to allow for nested \\dfrac elements.\n *\n * Backslash-escapes are removed with a simple search-and-replace.\n */\nexport function parseTex(tex: string): string {\n const handler = function (exp1: string, exp2: string) {\n return exp1 + \"/\" + exp2;\n };\n const texWithoutFracs = walkTex(tex, handler);\n return texWithoutFracs.replace(\"\\\\%\", \"%\");\n}\n","import KhanAnswerTypes from \"../../util/answer-types\";\nimport {parseTex} from \"../../util/tex-wrangler\";\n\nimport type {Score} from \"../../util/answer-types\";\nimport type {\n PerseusNumericInputRubric,\n PerseusNumericInputUserInput,\n PerseusScore,\n MathFormat,\n PerseusNumericInputAnswer,\n} from \"@khanacademy/perseus-core\";\n\nconst answerFormButtons: ReadonlyArray<{\n title: string;\n value: MathFormat;\n content: string;\n}> = [\n {title: \"Integers\", value: \"integer\", content: \"6\"},\n {title: \"Decimals\", value: \"decimal\", content: \"0.75\"},\n {title: \"Proper fractions\", value: \"proper\", content: \"\\u2157\"},\n {\n title: \"Improper fractions\",\n value: \"improper\",\n content: \"\\u2077\\u2044\\u2084\",\n },\n {title: \"Mixed numbers\", value: \"mixed\", content: \"1\\u00BE\"},\n {title: \"Numbers with \\u03C0\", value: \"pi\", content: \"\\u03C0\"},\n];\n\n// This function checks if the user inputted a percent value, parsing\n// it as a number (and maybe scaling) so that it can be graded.\n// NOTE(michaelpolyak): Unlike `KhanAnswerTypes.number.percent()` which\n// can accept several input forms with or without \"%\", the decision\n// to parse based on the presence of \"%\" in the input, is so that we\n// don't accidently scale the user typed value before grading, CP-930.\nexport function maybeParsePercentInput(\n inputValue: string | number,\n normalizedAnswerExpected: boolean,\n): string | number {\n // If the input value is not a string ending with \"%\", then there's\n // nothing more to do. The value will be graded as inputted by user.\n if (!(typeof inputValue === \"string\" && inputValue.endsWith(\"%\"))) {\n return inputValue;\n }\n\n const value = parseFloat(inputValue.slice(0, -1));\n // If the input value stripped of the \"%\" cannot be parsed as a\n // number (the slice is not really necessary for parseFloat to work\n // if the string starts with a number) then return the original\n // input for grading.\n if (isNaN(value)) {\n return inputValue;\n }\n\n // Next, if all correct answers are in the range of |0,1| then we\n // scale the user typed value. We assume this is the correct thing\n // to do since the input value ends with \"%\".\n if (normalizedAnswerExpected) {\n return value / 100;\n }\n\n // Otherwise, we return input value (number) stripped of the \"%\".\n return value;\n}\n\nfunction scoreNumericInput(\n userInput: PerseusNumericInputUserInput,\n rubric: PerseusNumericInputRubric,\n): PerseusScore {\n const defaultAnswerForms = answerFormButtons\n .map((e) => e[\"value\"])\n // Don't default to validating the answer as a pi answer\n // if answerForm isn't set on the answer\n // https://khanacademy.atlassian.net/browse/LC-691\n .filter((e) => e !== \"pi\");\n\n const createValidator = (answer: PerseusNumericInputAnswer) => {\n const stringAnswer = `${answer.value}`;\n\n // Always validate against the provided answer forms (pi, decimal, etc.)\n const validatorForms = [...(answer.answerForms ?? [])];\n\n // When an answer is set to strict, we validate using ONLY\n // the provided answerForms. If strict is false, or if there\n // were no provided answer forms, we will include all\n // of the default answer forms in our validator.\n if (!answer.strict || validatorForms.length === 0) {\n validatorForms.push(...defaultAnswerForms);\n }\n\n return KhanAnswerTypes.number.createValidatorFunctional(stringAnswer, {\n message: answer.message,\n simplify:\n answer.status === \"correct\" ? answer.simplify : \"optional\",\n inexact: true, // TODO(merlob) backfill / delete\n maxError: answer.maxError,\n forms: validatorForms,\n });\n };\n\n // We may have received TeX; try to parse it before grading.\n // If `currentValue` is not TeX, this should be a no-op.\n const currentValue = parseTex(userInput.currentValue);\n\n const normalizedAnswerExpected = rubric.answers\n .filter((answer) => answer.status === \"correct\")\n .every((answer) => answer.value != null && Math.abs(answer.value) <= 1);\n\n // The coefficient is an attribute of the widget\n let localValue: string | number = currentValue;\n if (rubric.coefficient) {\n if (!localValue) {\n localValue = 1;\n } else if (localValue === \"-\") {\n localValue = -1;\n }\n }\n const matchedAnswer:\n | (PerseusNumericInputAnswer & {score: Score})\n | undefined = rubric.answers\n .map((answer) => {\n const validateFn = createValidator(answer);\n const score = validateFn(\n maybeParsePercentInput(localValue, normalizedAnswerExpected),\n );\n return {...answer, score};\n })\n .find((answer) => {\n // NOTE: \"answer.score.correct\" indicates a match via the validate function.\n // It does NOT indicate that the answer itself is correct.\n return (\n answer.score.correct ||\n (answer.status === \"correct\" && answer.score.empty)\n );\n });\n\n const result: Score =\n matchedAnswer?.status === \"correct\"\n ? matchedAnswer.score\n : {\n empty: matchedAnswer?.status === \"ungraded\",\n correct: matchedAnswer?.status === \"correct\",\n message: matchedAnswer?.message ?? null,\n guess: localValue,\n };\n\n if (result.empty) {\n return {\n type: \"invalid\",\n message: result.message,\n };\n }\n return {\n type: \"points\",\n earned: result.correct ? 1 : 0,\n total: 1,\n message: result.message,\n };\n}\n\nexport default scoreNumericInput;\n","import _ from \"underscore\";\n\nimport type {\n PerseusOrdererRubric,\n PerseusOrdererUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreOrderer(\n userInput: PerseusOrdererUserInput,\n rubric: PerseusOrdererRubric,\n): PerseusScore {\n const correct = _.isEqual(\n userInput.current,\n rubric.correctOptions.map((option) => option.content),\n );\n\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreOrderer;\n","import type {\n PerseusOrdererUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the orderer widget to see if the user has started\n * ordering the options, making the widget scorable.\n * @param userInput\n * @see `scoreOrderer` for more details.\n */\nfunction validateOrderer(userInput: PerseusOrdererUserInput): ValidationResult {\n if (userInput.current.length === 0) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateOrderer;\n","import {approximateDeepEqual} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusPlotterUserInput,\n PerseusPlotterRubric,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scorePlotter(\n userInput: PerseusPlotterUserInput,\n rubric: PerseusPlotterRubric,\n): PerseusScore {\n return {\n type: \"points\",\n earned: approximateDeepEqual(userInput, rubric.correct) ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scorePlotter;\n","import {approximateDeepEqual} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusPlotterUserInput,\n PerseusPlotterValidationData,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input to confirm it is not the same as the starting values for the graph.\n * This means the user has modified the graph, and the question can be scored.\n *\n * @see 'scorePlotter' for more details on scoring.\n */\nfunction validatePlotter(\n userInput: PerseusPlotterUserInput,\n validationData: PerseusPlotterValidationData,\n): ValidationResult {\n if (approximateDeepEqual(userInput, validationData.starting)) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return null;\n}\n\nexport default validatePlotter;\n","import ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusRadioRubric,\n PerseusRadioUserInput,\n PerseusScore,\n RecursiveReadonly,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreRadio(\n userInput: RecursiveReadonly<PerseusRadioUserInput>,\n rubric: RecursiveReadonly<PerseusRadioRubric>,\n): PerseusScore {\n const numSelected = userInput.choicesSelected.reduce((sum, selected) => {\n return sum + (selected ? 1 : 0);\n }, 0);\n\n const numCorrect: number = rubric.choices.reduce((sum, currentChoice) => {\n return currentChoice.correct ? sum + 1 : sum;\n }, 0);\n\n if (numCorrect > 1 && numSelected !== numCorrect) {\n return {\n type: \"invalid\",\n message: ErrorCodes.CHOOSE_CORRECT_NUM_ERROR,\n };\n // If NOTA and some other answer are checked, ...\n }\n\n const noneOfTheAboveSelected = rubric.choices.some(\n (choice, index) =>\n choice.isNoneOfTheAbove && userInput.choicesSelected[index],\n );\n\n if (noneOfTheAboveSelected && numSelected > 1) {\n return {\n type: \"invalid\",\n message: ErrorCodes.NOT_NONE_ABOVE_ERROR,\n };\n }\n\n const correct = userInput.choicesSelected.every((selected, i) => {\n let isCorrect: boolean;\n if (rubric.choices[i].isNoneOfTheAbove) {\n isCorrect = rubric.choices.every((choice, j) => {\n return i === j || !choice.correct;\n });\n } else {\n isCorrect = !!rubric.choices[i].correct;\n }\n return isCorrect === selected;\n });\n\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreRadio;\n","import type {\n PerseusRadioUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks if the user has selected at least one option. Additional validation\n * is done in scoreRadio to check if the number of selected options is correct\n * and if the user has selected both a correct option and the \"none of the above\"\n * option.\n * @param userInput\n * @see `scoreRadio` for the additional validation logic and the scoring logic.\n */\nfunction validateRadio(userInput: PerseusRadioUserInput): ValidationResult {\n if (!userInput.choicesSelected.includes(true)) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateRadio;\n","import {approximateDeepEqual} from \"@khanacademy/perseus-core\";\nimport _ from \"underscore\";\n\nimport type {\n PerseusSorterRubric,\n PerseusSorterUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreSorter(\n userInput: PerseusSorterUserInput,\n rubric: PerseusSorterRubric,\n): PerseusScore {\n const correct = approximateDeepEqual(userInput.options, rubric.correct);\n return {\n type: \"points\",\n earned: correct ? 1 : 0,\n total: 1,\n message: null,\n };\n}\n\nexport default scoreSorter;\n","import type {\n PerseusSorterUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input for the sorter widget to ensure that the user has made\n * changes before attempting to score the widget.\n * @param userInput\n * @see 'scoreSorter' in 'packages/perseus/src/widgets/sorter/score-sorter.ts'\n * for more details on how the sorter widget is scored.\n */\nfunction validateSorter(userInput: PerseusSorterUserInput): ValidationResult {\n // If the sorter widget hasn't been changed yet, we treat it as \"empty\" which\n // prevents the \"Check\" button from becoming active. We want the user\n // to make a change before trying to move forward. This makes an\n // assumption that the initial order isn't the correct order! However,\n // this should be rare if it happens, and interacting with the list\n // will enable the button, so they won't be locked out of progressing.\n if (!userInput.changed) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n return null;\n}\n\nexport default validateSorter;\n","/**\n * Filters the given table (modelled as a 2D array) to remove any rows that are\n * completely empty.\n *\n * @returns A new table with only non-empty rows.\n */\nexport const filterNonEmpty = function (\n table: ReadonlyArray<ReadonlyArray<string>>,\n) {\n return table.filter(function (row) {\n // Return only rows that are non-empty.\n return row.some((cell) => cell);\n });\n};\n","import {filterNonEmpty} from \"./utils\";\n\nimport type {\n PerseusTableUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\nfunction validateTable(userInput: PerseusTableUserInput): ValidationResult {\n const supplied = filterNonEmpty(userInput);\n\n const hasEmptyCell = supplied.some(function (row) {\n return row.some(function (cell) {\n return cell === \"\";\n });\n });\n\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (hasEmptyCell || !supplied.length) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateTable;\n","import KhanAnswerTypes from \"../../util/answer-types\";\n\nimport {filterNonEmpty} from \"./utils\";\nimport validateTable from \"./validate-table\";\n\nimport type {\n PerseusTableRubric,\n PerseusScore,\n PerseusTableUserInput,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreTable(\n userInput: PerseusTableUserInput,\n rubric: PerseusTableRubric,\n): PerseusScore {\n const validationResult = validateTable(userInput);\n if (validationResult != null) {\n return validationResult;\n }\n\n const supplied = filterNonEmpty(userInput);\n const solution = filterNonEmpty(rubric.answers);\n if (supplied.length !== solution.length) {\n return {\n type: \"points\",\n earned: 0,\n total: 1,\n message: null,\n };\n }\n\n const createValidator = KhanAnswerTypes.number.createValidatorFunctional;\n let message: string | null = null;\n const allCorrect = solution.every(function (rowSolution) {\n for (let i = 0; i < supplied.length; i++) {\n const rowSupplied = supplied[i];\n const correct = rowSupplied.every(function (cellSupplied, i) {\n const cellSolution = rowSolution[i];\n const validator = createValidator(cellSolution, {\n simplify: true,\n });\n const result = validator(cellSupplied);\n if (result.message) {\n message = result.message;\n }\n return result.correct;\n });\n if (correct) {\n supplied.splice(i, 1);\n return true;\n }\n }\n return false;\n });\n return {\n type: \"points\",\n earned: allCorrect ? 1 : 0,\n total: 1,\n message,\n };\n}\n\nexport default scoreTable;\n","import KhanAnswerTypes from \"../../util/answer-types\";\nimport {parseTex} from \"../../util/tex-wrangler\";\n\nimport type {\n PerseusInputNumberRubric,\n PerseusInputNumberUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nexport const inputNumberAnswerTypes = {\n number: {\n name: \"Numbers\",\n forms: \"integer, decimal, proper, improper, mixed\",\n },\n decimal: {\n name: \"Decimals\",\n forms: \"decimal\",\n },\n integer: {\n name: \"Integers\",\n forms: \"integer\",\n },\n rational: {\n name: \"Fractions and mixed numbers\",\n forms: \"integer, proper, improper, mixed\",\n },\n improper: {\n name: \"Improper numbers (no mixed)\",\n forms: \"integer, proper, improper\",\n },\n mixed: {\n name: \"Mixed numbers (no improper)\",\n forms: \"integer, proper, mixed\",\n },\n percent: {\n name: \"Numbers or percents\",\n forms: \"integer, decimal, proper, improper, mixed, percent\",\n },\n pi: {\n name: \"Numbers with pi\",\n forms: \"pi\",\n },\n} as const;\n\nfunction scoreInputNumber(\n userInput: PerseusInputNumberUserInput,\n rubric: PerseusInputNumberRubric,\n): PerseusScore {\n if (rubric.answerType == null) {\n rubric.answerType = \"number\";\n }\n\n // note(matthewc): this will get immediately parsed again by\n // `KhanAnswerTypes.number.convertToPredicate`, but a string is\n // expected here\n const stringValue = `${rubric.value}`;\n const val = KhanAnswerTypes.number.createValidatorFunctional(stringValue, {\n simplify: rubric.simplify,\n inexact: rubric.inexact || undefined,\n maxError: rubric.maxError,\n forms: inputNumberAnswerTypes[rubric.answerType].forms,\n });\n\n // We may have received TeX; try to parse it before grading.\n // If `currentValue` is not TeX, this should be a no-op.\n const currentValue = parseTex(userInput.currentValue);\n\n const result = val(currentValue);\n\n if (result.empty) {\n return {\n type: \"invalid\",\n message: result.message,\n };\n }\n return {\n type: \"points\",\n earned: result.correct ? 1 : 0,\n total: 1,\n message: result.message,\n };\n}\n\nexport default scoreInputNumber;\n","import type {PerseusScore} from \"@khanacademy/perseus-core\";\n\n/**\n * Several widgets don't have \"right\"/\"wrong\" scoring logic,\n * so this just says to move on past those widgets\n *\n * TODO(LEMS-2543) widgets that use this probably shouldn't have any\n * scoring logic and the thing scoring an exercise\n * should just know to skip these\n */\nfunction scoreNoop(points: number = 0): PerseusScore {\n return {\n type: \"points\",\n earned: points,\n total: points,\n message: null,\n };\n}\n\nexport default scoreNoop;\n","import scoreNoop from \"../../util/score-noop\";\n\nimport type {\n PerseusFreeResponseUserInput,\n PerseusFreeResponseRubric,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\nfunction scoreFreeResponse(\n userInput: PerseusFreeResponseUserInput,\n rubric: PerseusFreeResponseRubric,\n locale: string,\n): PerseusScore {\n // TODO(AX-961): Implement support for external scoring. Since the user's\n // input is free text input, we can't easily do scoring inside the\n // widget, so we'll need to have a way to do it by some other method.\n // For now, we'll just always give full credit.\n return scoreNoop();\n}\n\nexport default scoreFreeResponse;\n","import ErrorCodes from \"../../error-codes\";\n\nimport type {\n PerseusFreeResponseUserInput,\n PerseusFreeResponseWidgetOptions,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks user input from the free response widget to see if it is scorable.\n * Since the input is free text, we only check that it is not empty.\n */\nfunction validateFreeResponse(\n userInput: PerseusFreeResponseUserInput,\n widgetOptions: PerseusFreeResponseWidgetOptions,\n): ValidationResult {\n const userInputLength = userInput.currentValue.trim().length;\n\n if (userInputLength === 0) {\n return {\n type: \"invalid\",\n message: ErrorCodes.USER_INPUT_EMPTY,\n };\n }\n\n if (\n !widgetOptions.allowUnlimitedCharacters &&\n userInputLength > widgetOptions.characterLimit\n ) {\n return {\n type: \"invalid\",\n message: ErrorCodes.USER_INPUT_TOO_LONG,\n };\n }\n\n return null;\n}\n\nexport default validateFreeResponse;\n","// The `group` widget is basically a widget hosting a full Perseus system in\n\nimport {flattenScores, scoreWidgetsFunctional} from \"../../score\";\n\nimport type {\n PerseusGroupRubric,\n PerseusGroupUserInput,\n PerseusScore,\n} from \"@khanacademy/perseus-core\";\n\n// it. As such, scoring a group means scoring all widgets it contains.\nfunction scoreGroup(\n userInput: PerseusGroupUserInput,\n rubric: PerseusGroupRubric,\n locale: string,\n): PerseusScore {\n const scores = scoreWidgetsFunctional(\n rubric.widgets,\n Object.keys(rubric.widgets),\n userInput,\n locale,\n );\n\n return flattenScores(scores);\n}\n\nexport default scoreGroup;\n","import {scoreIsEmpty} from \"./score\";\nimport {getWidgetValidator} from \"./widgets/widget-registry\";\n\nimport type {UserInputMap, ValidationDataMap} from \"@khanacademy/perseus-core\";\n\n/**\n * Checks the given user input to see if any answerable widgets have not been\n * \"filled in\" (ie. if they're empty). Another way to think about this\n * function is that its a check to see if we can score the provided input.\n */\nexport function emptyWidgetsFunctional(\n widgets: ValidationDataMap,\n // This is a port of old code, I'm not sure why\n // we need widgetIds vs the keys of the widgets object\n widgetIds: ReadonlyArray<string>,\n userInputMap: UserInputMap,\n locale: string,\n): ReadonlyArray<string> {\n return widgetIds.filter((id) => {\n const widget = widgets[id];\n if (!widget || widget.static === true) {\n // Static widgets shouldn't count as empty\n return false;\n }\n\n const validator = getWidgetValidator(widget.type);\n const userInput = userInputMap[id];\n const validationData = widget.options;\n const score = validator?.(userInput, validationData, locale);\n\n if (score) {\n return scoreIsEmpty(score);\n }\n });\n}\n","import {emptyWidgetsFunctional} from \"../../validate\";\n\nimport type {\n PerseusGroupUserInput,\n PerseusGroupValidationData,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\nfunction validateGroup(\n userInput: PerseusGroupUserInput,\n validationData: PerseusGroupValidationData,\n locale: string,\n): ValidationResult {\n const emptyWidgets = emptyWidgetsFunctional(\n validationData.widgets,\n Object.keys(validationData.widgets),\n userInput,\n locale,\n );\n\n if (emptyWidgets.length === 0) {\n return null;\n }\n\n return {type: \"invalid\", message: null};\n}\n\nexport default validateGroup;\n","import type {\n PerseusLabelImageUserInput,\n ValidationResult,\n} from \"@khanacademy/perseus-core\";\n\nfunction validateLabelImage(\n userInput: PerseusLabelImageUserInput,\n): ValidationResult {\n let numAnswered = 0;\n for (let i = 0; i < userInput.markers.length; i++) {\n const userSelection = userInput.markers[i].selected;\n if (userSelection && userSelection.length > 0) {\n numAnswered++;\n }\n }\n // We expect all question markers to be answered before grading.\n if (numAnswered !== userInput.markers.length) {\n return {\n type: \"invalid\",\n message: null,\n };\n }\n\n return null;\n}\n\nexport default validateLabelImage;\n","import type {PerseusMockWidgetUserInput} from \"./mock-widget-validation.types\";\nimport type {ValidationResult} from \"@khanacademy/perseus-core\";\n\nfunction validateMockWidget(\n userInput: PerseusMockWidgetUserInput,\n): ValidationResult {\n if (userInput.currentValue == null || userInput.currentValue === \"\") {\n return {\n type: \"invalid\",\n message: \"\",\n };\n }\n\n return null;\n}\n\nexport default validateMockWidget;\n","import validateMockWidget from \"./validate-mock-widget\";\n\nimport type {\n PerseusMockWidgetRubric,\n PerseusMockWidgetUserInput,\n} from \"./mock-widget-validation.types\";\nimport type {PerseusScore} from \"@khanacademy/perseus-core\";\n\nfunction scoreMockWidget(\n userInput: PerseusMockWidgetUserInput,\n rubric: PerseusMockWidgetRubric,\n): PerseusScore {\n const validationResult = validateMockWidget(userInput);\n if (validationResult != null) {\n return validationResult;\n }\n\n return {\n type: \"points\",\n earned: userInput.currentValue === rubric.value ? 1 : 0,\n total: 1,\n message: \"\",\n };\n}\n\nexport default scoreMockWidget;\n","import {\n Registry,\n type WidgetScorerFunction,\n type WidgetValidatorFunction,\n} from \"@khanacademy/perseus-core\";\n\nimport scoreNoop from \"../util/score-noop\";\n\nimport scoreCategorizer from \"./categorizer/score-categorizer\";\nimport validateCategorizer from \"./categorizer/validate-categorizer\";\nimport scoreCSProgram from \"./cs-program/score-cs-program\";\nimport scoreDropdown from \"./dropdown/score-dropdown\";\nimport validateDropdown from \"./dropdown/validate-dropdown\";\nimport scoreExpression from \"./expression/score-expression\";\nimport validateExpression from \"./expression/validate-expression\";\nimport scoreFreeResponse from \"./free-response/score-free-response\";\nimport validateFreeResponse from \"./free-response/validate-free-response\";\nimport scoreGrapher from \"./grapher/score-grapher\";\nimport scoreGroup from \"./group/score-group\";\nimport validateGroup from \"./group/validate-group\";\nimport scoreIframe from \"./iframe/score-iframe\";\nimport scoreInputNumber from \"./input-number/score-input-number\";\nimport scoreInteractiveGraph from \"./interactive-graph/score-interactive-graph\";\nimport scoreLabelImage from \"./label-image/score-label-image\";\nimport validateLabelImage from \"./label-image/validate-label-image\";\nimport scoreMatcher from \"./matcher/score-matcher\";\nimport scoreMatrix from \"./matrix/score-matrix\";\nimport validateMatrix from \"./matrix/validate-matrix\";\nimport scoreMockWidget from \"./mock-widget/score-mock-widget\";\nimport scoreNumberLine from \"./number-line/score-number-line\";\nimport validateNumberLine from \"./number-line/validate-number-line\";\nimport scoreNumericInput from \"./numeric-input/score-numeric-input\";\nimport scoreOrderer from \"./orderer/score-orderer\";\nimport validateOrderer from \"./orderer/validate-orderer\";\nimport scorePlotter from \"./plotter/score-plotter\";\nimport validatePlotter from \"./plotter/validate-plotter\";\nimport scoreRadio from \"./radio/score-radio\";\nimport validateRadio from \"./radio/validate-radio\";\nimport scoreSorter from \"./sorter/score-sorter\";\nimport validateSorter from \"./sorter/validate-sorter\";\nimport scoreTable from \"./table/score-table\";\nimport validateTable from \"./table/validate-table\";\n\ntype ScoringLogic = {\n scorer: WidgetScorerFunction;\n validator?: WidgetValidatorFunction;\n};\n\nconst widgets = new Registry<ScoringLogic>(\"Score widget registry\");\n\nexport function registerWidget(\n type: string,\n scorer: WidgetScorerFunction,\n validator?: WidgetValidatorFunction,\n) {\n const logic = {\n scorer,\n validator,\n };\n widgets.set(type, logic);\n}\n\nexport const getWidgetValidator = (\n type: string,\n): WidgetValidatorFunction | null => {\n return widgets.get(type)?.validator ?? null;\n};\n\nexport const getWidgetScorer = (type: string): WidgetScorerFunction | null => {\n return widgets.get(type)?.scorer ?? null;\n};\n\nregisterWidget(\n \"categorizer\",\n scoreCategorizer as any,\n validateCategorizer as any,\n);\nregisterWidget(\"cs-program\", scoreCSProgram as any);\nregisterWidget(\"dropdown\", scoreDropdown as any, validateDropdown as any);\nregisterWidget(\"expression\", scoreExpression as any, validateExpression as any);\nregisterWidget(\n \"free-response\",\n scoreFreeResponse as any,\n validateFreeResponse as any,\n);\nregisterWidget(\"grapher\", scoreGrapher as any);\nregisterWidget(\"group\", scoreGroup as any, validateGroup as any);\nregisterWidget(\"iframe\", scoreIframe as any);\nregisterWidget(\"input-number\", scoreInputNumber as any);\nregisterWidget(\"interactive-graph\", scoreInteractiveGraph as any);\nregisterWidget(\n \"label-image\",\n scoreLabelImage as any,\n validateLabelImage as any,\n);\nregisterWidget(\"matcher\", scoreMatcher as any);\nregisterWidget(\"matrix\", scoreMatrix as any, validateMatrix as any);\nregisterWidget(\"mock-widget\", scoreMockWidget as any, scoreMockWidget as any);\nregisterWidget(\n \"number-line\",\n scoreNumberLine as any,\n validateNumberLine as any,\n);\nregisterWidget(\"numeric-input\", scoreNumericInput as any);\nregisterWidget(\"orderer\", scoreOrderer as any, validateOrderer as any);\nregisterWidget(\"plotter\", scorePlotter as any, validatePlotter as any);\nregisterWidget(\"radio\", scoreRadio as any, validateRadio as any);\nregisterWidget(\"sorter\", scoreSorter as any, validateSorter as any);\nregisterWidget(\"table\", scoreTable as any, validateTable as any);\nregisterWidget(\"deprecated-standin\", () => scoreNoop(1) as any);\nregisterWidget(\"measurer\", () => scoreNoop(1) as any);\n\nregisterWidget(\"definition\", scoreNoop as any);\nregisterWidget(\"explanation\", scoreNoop as any);\nregisterWidget(\"image\", scoreNoop as any);\nregisterWidget(\"interaction\", scoreNoop as any);\nregisterWidget(\"molecule\", scoreNoop as any);\nregisterWidget(\"passage\", scoreNoop as any);\nregisterWidget(\"passage-ref\", scoreNoop as any);\nregisterWidget(\"passage-ref-target\", scoreNoop as any);\nregisterWidget(\"video\", scoreNoop as any);\n","import {\n Errors,\n applyDefaultsToWidgets,\n getWidgetIdsFromContent,\n PerseusError,\n} from \"@khanacademy/perseus-core\";\n\nimport {getWidgetScorer, getWidgetValidator} from \"./widgets/widget-registry\";\n\nimport type {\n PerseusRenderer,\n PerseusScore,\n PerseusWidgetsMap,\n UserInputMap,\n} from \"@khanacademy/perseus-core\";\n\nconst noScore: PerseusScore = {\n type: \"points\",\n earned: 0,\n total: 0,\n message: null,\n};\n\n/**\n * If a widget says that it is empty once it is graded.\n * Trying to encapsulate references to the score format.\n */\nexport function scoreIsEmpty(score: PerseusScore): boolean {\n // HACK(benkomalo): ugh. this isn't great; the Perseus score objects\n // overload the type \"invalid\" for what should probably be three\n // distinct cases:\n // - truly empty or not fully filled out\n // - invalid or malformed inputs\n // - \"almost correct\" like inputs where the widget wants to give\n // feedback (e.g. a fraction needs to be reduced, or `pi` should\n // be used instead of 3.14)\n //\n // Unfortunately the coercion happens all over the place, as these\n // Perseus style score objects are created *everywhere* (basically\n // in every widget), so it's hard to change now. We assume that\n // anything with a \"message\" is not truly empty, and one of the\n // latter two cases for now.\n return (\n score.type === \"invalid\" &&\n (!score.message || score.message.length === 0)\n );\n}\n\n/**\n * Combine two score objects.\n *\n * Given two score objects for two different widgets, combine them so that\n * if one is wrong, the total score is wrong, etc.\n */\nfunction combineScores(\n scoreA: PerseusScore,\n scoreB: PerseusScore,\n): PerseusScore {\n let message;\n\n if (scoreA.type === \"points\" && scoreB.type === \"points\") {\n if (\n scoreA.message &&\n scoreB.message &&\n scoreA.message !== scoreB.message\n ) {\n // TODO(alpert): Figure out how to combine messages usefully\n message = null;\n } else {\n message = scoreA.message || scoreB.message;\n }\n\n return {\n type: \"points\",\n earned: scoreA.earned + scoreB.earned,\n total: scoreA.total + scoreB.total,\n message: message,\n };\n }\n if (scoreA.type === \"points\" && scoreB.type === \"invalid\") {\n return scoreB;\n }\n if (scoreA.type === \"invalid\" && scoreB.type === \"points\") {\n return scoreA;\n }\n if (scoreA.type === \"invalid\" && scoreB.type === \"invalid\") {\n if (\n scoreA.message &&\n scoreB.message &&\n scoreA.message !== scoreB.message\n ) {\n // TODO(alpert): Figure out how to combine messages usefully\n message = null;\n } else {\n message = scoreA.message || scoreB.message;\n }\n\n return {\n type: \"invalid\",\n message: message,\n };\n }\n\n /**\n * The above checks cover all combinations of score type, so if we get here\n * then something is amiss with our inputs.\n */\n throw new PerseusError(\n \"PerseusScore with unknown type encountered\",\n Errors.InvalidInput,\n {\n metadata: {\n scoreA: JSON.stringify(scoreA),\n scoreB: JSON.stringify(scoreB),\n },\n },\n );\n}\n\nexport function flattenScores(widgetScoreMap: {\n [widgetId: string]: PerseusScore;\n}): PerseusScore {\n return Object.values(widgetScoreMap).reduce(combineScores, noScore);\n}\n\n/**\n * score a Perseus item\n *\n * @param perseusRenderData - the full answer data, includes the correct answer\n * @param userInputMap - the user's input for each widget, mapped by ID\n * @param locale - string locale for math parsing (\"de\" 1.000,00 vs \"en\" 1,000.00)\n */\nexport function scorePerseusItem(\n perseusRenderData: PerseusRenderer,\n userInputMap: UserInputMap,\n locale: string,\n): PerseusScore {\n // There seems to be a chance that PerseusRenderer.widgets might include\n // widget data for widgets that are not in PerseusRenderer.content,\n // so this checks that the widgets are being used before scoring them\n const usedWidgetIds = getWidgetIdsFromContent(perseusRenderData.content);\n const scores = scoreWidgetsFunctional(\n perseusRenderData.widgets,\n usedWidgetIds,\n userInputMap,\n locale,\n );\n return flattenScores(scores);\n}\n\n// TODO: combine scorePerseusItem with scoreWidgetsFunctional\nexport function scoreWidgetsFunctional(\n widgets: PerseusWidgetsMap,\n // This is a port of old code, I'm not sure why\n // we need widgetIds vs the keys of the widgets object\n widgetIds: ReadonlyArray<string>,\n userInputMap: UserInputMap,\n locale: string,\n): {[widgetId: string]: PerseusScore} {\n const upgradedWidgets = applyDefaultsToWidgets(widgets);\n\n const gradedWidgetIds = widgetIds.filter((id) => {\n const props = upgradedWidgets[id];\n const widgetIsGraded: boolean = props?.graded == null || props.graded;\n const widgetIsStatic = !!props?.static;\n // Ungraded widgets or widgets set to static shouldn't be graded.\n return widgetIsGraded && !widgetIsStatic;\n });\n\n const widgetScores: Record<string, PerseusScore> = {};\n gradedWidgetIds.forEach((id) => {\n const widget = upgradedWidgets[id];\n if (!widget) {\n return;\n }\n\n const userInput = userInputMap[id];\n const validator = getWidgetValidator(widget.type);\n const scorer = getWidgetScorer(widget.type);\n\n // We do validation (empty checks) first and then scoring. If\n // validation fails, it's result is itself a PerseusScore.\n const score =\n validator?.(userInput, widget.options, locale) ??\n scorer?.(userInput, widget.options, locale);\n if (score != null) {\n widgetScores[id] = score;\n }\n });\n\n return widgetScores;\n}\n","import {getWidgetIdsFromContent} from \"@khanacademy/perseus-core\";\n\nimport type {PerseusItem, UserInputMap} from \"@khanacademy/perseus-core\";\n\n/**\n * Check the emptiness of DINER widgets (for the AX team):\n * - Dropdown\n * - InteractiveGraph\n * - NumericInput\n * - Expression\n * - Radio\n *\n * @param {PerseusItem} itemData\n * @param {UserInputMap} userInputMap\n * @returns {boolean} true if there's an empty widget, otherwise false\n */\nfunction hasEmptyDINERWidgets(\n itemData: PerseusItem,\n userInputMap: UserInputMap,\n): boolean {\n const usedWidgetIds = getWidgetIdsFromContent(itemData.question.content);\n const widgets = itemData.question.widgets;\n\n for (const widgetId of usedWidgetIds) {\n const widget = widgets[widgetId];\n const input = userInputMap[widgetId];\n\n switch (widget.type) {\n case \"dropdown\": {\n // see `validateDropdown`\n if (input.value === 0) {\n return true;\n }\n break;\n }\n case \"interactive-graph\": {\n // IG doesn't do client-side validation\n break;\n }\n case \"numeric-input\": {\n // this is possibly a source of bugs,\n // really it should be:\n // empty input && not coefficient && answer is not 1\n // but we don't have answers here\n // (see: `scoreNumericInput`)\n if (!input.currentValue && !widget.options.coefficient) {\n return true;\n }\n break;\n }\n case \"expression\": {\n // see `validateExpression`\n if (!input) {\n return true;\n }\n break;\n }\n case \"radio\": {\n // see `validateRadio`\n if (!input.choicesSelected.includes(true)) {\n return true;\n }\n break;\n }\n }\n }\n\n return false;\n}\n\nexport default hasEmptyDINERWidgets;\n"],"names":["APPROXIMATED_PI_ERROR","CHOOSE_CORRECT_NUM_ERROR","EXTRA_SYMBOLS_ERROR","FILL_ALL_CELLS_ERROR","INVALID_SELECTION_ERROR","MISSING_PERCENT_ERROR","MULTIPLICATION_SIGN_ERROR","NEEDS_TO_BE_SIMPLIFIED_ERROR","NOT_NONE_ABOVE_ERROR","USER_INPUT_EMPTY","USER_INPUT_TOO_LONG","WRONG_CASE_ERROR","WRONG_LETTER_ERROR","ErrorCodes","MAXERROR_EPSILON","Math","pow","KhanAnswerTypes","predicate","defaultForms","createValidatorFunctional","options","_","extend","simplify","ratio","forms","acceptableForms","isArray","split","inexact","undefined","maxError","contains","without","push","fractionTransformer","text","replace","match","mobileDeviceMatch","parsedInt","parseInt","num","denom","simplified","parseFloat","KhanMath","getGCD","value","exact","isNaN","integer","decimal","rounded","proper","transformed","flatMap","o","abs","improper","fractionExists","includes","pi","possibilities","sign","integ","reduce","memo","form","concat","approximatesPi","number","piMult","PI","roundedNumber","round","each","possibility","piApprox","multiplier","forEach","coefficient","log","percent","String","trim","hasPercentSign","indexOf","length","substring","t","mixed","precision","normal","badLeadingZero","x","commas","c","guess","fallback","score","empty","correct","message","findCorrectAnswer","j","l","val","interpretedGuess","anyAreNaN","any","convertToPredicate","correctAnswer","correctFloat","type","expression","parseSolution","solutionString","solution","KAS","parse","parsed","PerseusError","Errors","InvalidInput","expr","isSimplified","ungraded","answer","result","compare","equal","wrongVariableNames","wrongVariableCase","suppressAlmostThere","answerX","resultX","scoreCategorizer","userInput","rubric","allCorrect","values","i","earned","total","validateCategorizer","validationData","incomplete","items","some","scoreCSProgram","status","scoreDropdown","choices","validateDropdown","scoreExpression","locale","clone","decimal_separator","getDecimalSeparator","createValidator","metadata","JSON","stringify","matchingAnswerForm","matchMessage","allEmpty","firstUngradedResult","answerForm","answerForms","validator","considered","validateExpression","getCoefficientsByType","data","coords","grader","GrapherUtil","functionForType","getCoefficients","asymptote","scoreGrapher","guessCoeffs","correctCoeffs","areEqual","scoreIframe","collinear","canonicalSineCoefficients","similar","clockwise","geometry","getClockwiseAngle","angles","getSinusoidCoefficients","getQuadraticCoefficients","coefficients","scoreInteractiveGraph","hasValue","Boolean","center","radius","approximateDeepEqual","canonicalGuessCoeffs","canonicalCorrectCoeffs","approximateEqual","Error","slice","sort","Number","POSITIVE_INFINITY","knumber","DEFAULT_TOLERANCE","deepClone","invoke","allowReflexAngles","areClockwise","shouldReverseCoords","reverse","map","angle","isEqual","graph","scoreLabelImageMarker","hasAnswers","isCorrect","every","choice","scoreLabelImage","numCorrect","markers","selected","answers","scoreMatcher","left","right","scoreMatrix","supplied","solutionSize","getMatrixSize","suppliedSize","incorrectSize","incorrect","times","row","col","validateMatrix","toString","scoreNumberLine","range","start","initialX","startRel","isInequality","correctRel","correctPos","numLinePosition","correctX","rel","validateNumberLine","divisionRange","outsideAllowedRange","numDivisions","isTickCrtl","findEndpoint","tex","currentIndex","bracketDepth","len","parseNextExpression","handler","openBracketIndex","endpoint","nextExpIndex","expressionTeX","parsedExp","walkTex","getNextFracIndex","dfrac","frac","nextFrac","nextDFrac","min","parsedString","firstParsedExpression","secondParsedExpression","parseTex","exp1","exp2","texWithoutFracs","answerFormButtons","title","content","maybeParsePercentInput","inputValue","normalizedAnswerExpected","endsWith","scoreNumericInput","defaultAnswerForms","e","filter","stringAnswer","validatorForms","strict","currentValue","localValue","matchedAnswer","validateFn","find","scoreOrderer","current","correctOptions","option","validateOrderer","scorePlotter","validatePlotter","starting","scoreRadio","numSelected","choicesSelected","sum","currentChoice","noneOfTheAboveSelected","index","isNoneOfTheAbove","validateRadio","scoreSorter","validateSorter","changed","filterNonEmpty","table","cell","validateTable","hasEmptyCell","scoreTable","validationResult","rowSolution","rowSupplied","cellSupplied","cellSolution","splice","inputNumberAnswerTypes","name","rational","scoreInputNumber","answerType","stringValue","scoreNoop","points","scoreFreeResponse","validateFreeResponse","widgetOptions","userInputLength","allowUnlimitedCharacters","characterLimit","scoreGroup","scores","scoreWidgetsFunctional","widgets","Object","keys","flattenScores","emptyWidgetsFunctional","widgetIds","userInputMap","id","widget","static","getWidgetValidator","scoreIsEmpty","validateGroup","emptyWidgets","validateLabelImage","numAnswered","userSelection","validateMockWidget","scoreMockWidget","Registry","registerWidget","scorer","logic","set","get","getWidgetScorer","noScore","combineScores","scoreA","scoreB","widgetScoreMap","scorePerseusItem","perseusRenderData","usedWidgetIds","getWidgetIdsFromContent","upgradedWidgets","applyDefaultsToWidgets","gradedWidgetIds","props","widgetIsGraded","graded","widgetIsStatic","widgetScores","hasEmptyDINERWidgets","itemData","question","widgetId","input"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAMA,qBAAAA,CAAwB,uBAC9B,CAAA,MAAMC,wBAA2B,CAAA,0BAAA,CACjC,MAAMC,mBAAAA,CAAsB,qBAC5B,CAAA,MAAMC,oBAAuB,CAAA,sBAAA,CAC7B,MAAMC,uBAAAA,CAA0B,0BAChC,MAAMC,qBAAAA,CAAwB,uBAC9B,CAAA,MAAMC,yBAA4B,CAAA,2BAAA,CAClC,MAAMC,4BAAAA,CAA+B,8BACrC,CAAA,MAAMC,oBAAuB,CAAA,sBAAA,CAC7B,MAAMC,gBAAAA,CAAmB,mBACzB,MAAMC,mBAAAA,CAAsB,qBAC5B,CAAA,MAAMC,gBAAmB,CAAA,kBAAA,CACzB,MAAMC,kBAAAA,CAAqB,oBAE3B,CAAA,MAAMC,UAAa,CAAA,CACfb,qBACAC,CAAAA,wBAAAA,CACAC,oBACAC,oBACAC,CAAAA,uBAAAA,CACAC,qBACAC,CAAAA,yBAAAA,CACAC,4BACAC,CAAAA,oBAAAA,CACAC,gBACAC,CAAAA,mBAAAA,CACAC,gBACAC,CAAAA,kBACJ;;ACp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