@khanacademy/perseus 50.1.0 → 51.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/es/index.js +558 -2400
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/es/strings.js +58 -11
  4. package/dist/es/strings.js.map +1 -1
  5. package/dist/index.d.ts +3 -8
  6. package/dist/index.js +500 -2318
  7. package/dist/index.js.map +1 -1
  8. package/dist/renderer-util.d.ts +1 -2
  9. package/dist/renderer.d.ts +2 -2
  10. package/dist/server-item-renderer.d.ts +1 -1
  11. package/dist/strings.d.ts +204 -13
  12. package/dist/strings.js +75 -10
  13. package/dist/strings.js.map +1 -1
  14. package/dist/types.d.ts +1 -14
  15. package/dist/util/scoring.d.ts +1 -2
  16. package/dist/util/test-utils.d.ts +1 -2
  17. package/dist/util.d.ts +0 -14
  18. package/dist/widget-ai-utils/categorizer/categorizer-ai-utils.d.ts +1 -1
  19. package/dist/widget-ai-utils/dropdown/dropdown-ai-utils.d.ts +1 -1
  20. package/dist/widget-ai-utils/expression/expression-ai-utils.d.ts +1 -1
  21. package/dist/widget-ai-utils/grapher/grapher-ai-utils.d.ts +1 -1
  22. package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +1 -1
  23. package/dist/widget-ai-utils/label-image/label-image-ai-utils.d.ts +1 -1
  24. package/dist/widget-ai-utils/matcher/matcher-ai-utils.d.ts +1 -1
  25. package/dist/widget-ai-utils/matrix/matrix-ai-utils.d.ts +1 -1
  26. package/dist/widget-ai-utils/mock-widget/prompt-utils.d.ts +1 -1
  27. package/dist/widget-ai-utils/number-line/number-line-ai-utils.d.ts +1 -1
  28. package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +1 -1
  29. package/dist/widget-ai-utils/orderer/orderer-ai-utils.d.ts +1 -1
  30. package/dist/widget-ai-utils/radio/radio-ai-utils.d.ts +1 -1
  31. package/dist/widget-ai-utils/sorter/sorter-ai-utils.d.ts +1 -1
  32. package/dist/widgets/__shared__/score-noop.d.ts +1 -1
  33. package/dist/widgets/categorizer/categorizer.d.ts +2 -2
  34. package/dist/widgets/cs-program/cs-program.d.ts +1 -2
  35. package/dist/widgets/definition/definition.d.ts +1 -1
  36. package/dist/widgets/deprecated-standin/deprecated-standin.d.ts +1 -1
  37. package/dist/widgets/dropdown/dropdown.d.ts +2 -2
  38. package/dist/widgets/explanation/explanation.d.ts +1 -1
  39. package/dist/widgets/expression/expression.d.ts +5 -6
  40. package/dist/widgets/graded-group/graded-group.d.ts +1 -1
  41. package/dist/widgets/graded-group-set/graded-group-set.d.ts +1 -1
  42. package/dist/widgets/grapher/grapher.d.ts +1 -2
  43. package/dist/widgets/grapher/util.d.ts +5 -13
  44. package/dist/widgets/group/group.d.ts +2 -2
  45. package/dist/widgets/group/score-group.d.ts +1 -2
  46. package/dist/widgets/iframe/iframe.d.ts +1 -2
  47. package/dist/widgets/image/image.d.ts +1 -1
  48. package/dist/widgets/input-number/input-number.d.ts +1 -2
  49. package/dist/widgets/interaction/interaction.d.ts +1 -1
  50. package/dist/widgets/interactive-graph.d.ts +2 -3
  51. package/dist/widgets/interactive-graphs/graphs/linear-system.d.ts +2 -0
  52. package/dist/widgets/interactive-graphs/graphs/quadratic.d.ts +1 -3
  53. package/dist/widgets/interactive-graphs/graphs/ray.d.ts +2 -0
  54. package/dist/widgets/interactive-graphs/graphs/sinusoid.d.ts +4 -9
  55. package/dist/widgets/interactive-graphs/graphs/utils.d.ts +4 -0
  56. package/dist/widgets/interactive-graphs/math/index.d.ts +0 -1
  57. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +1 -1
  58. package/dist/widgets/interactive-graphs/types.d.ts +2 -1
  59. package/dist/widgets/label-image/label-image.d.ts +2 -4
  60. package/dist/widgets/label-image/marker.d.ts +1 -2
  61. package/dist/widgets/matcher/matcher.d.ts +1 -2
  62. package/dist/widgets/matrix/matrix.d.ts +2 -4
  63. package/dist/widgets/measurer/measurer.d.ts +1 -1
  64. package/dist/widgets/mock-widgets/mock-widget.d.ts +1 -1
  65. package/dist/widgets/mock-widgets/score-mock-widget.d.ts +1 -2
  66. package/dist/widgets/molecule/molecule.d.ts +1 -1
  67. package/dist/widgets/number-line/number-line.d.ts +2 -3
  68. package/dist/widgets/numeric-input/numeric-input.d.ts +1 -2
  69. package/dist/widgets/orderer/orderer.d.ts +1 -2
  70. package/dist/widgets/passage/passage.d.ts +1 -1
  71. package/dist/widgets/passage-ref/passage-ref.d.ts +1 -1
  72. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +1 -1
  73. package/dist/widgets/plotter/plotter.d.ts +1 -2
  74. package/dist/widgets/radio/radio-component.d.ts +1 -1
  75. package/dist/widgets/radio/radio.d.ts +1 -1
  76. package/dist/widgets/sorter/sorter.d.ts +1 -2
  77. package/dist/widgets/table/table.d.ts +1 -2
  78. package/dist/widgets/video/video.d.ts +1 -1
  79. package/package.json +46 -46
  80. package/dist/tex-wrangler.d.ts +0 -7
  81. package/dist/util/geometry.d.ts +0 -28
  82. package/dist/validation.types.d.ts +0 -166
  83. package/dist/widgets/categorizer/score-categorizer.d.ts +0 -5
  84. package/dist/widgets/categorizer/validate-categorizer.d.ts +0 -13
  85. package/dist/widgets/cs-program/score-cs-program.d.ts +0 -4
  86. package/dist/widgets/dropdown/score-dropdown.d.ts +0 -4
  87. package/dist/widgets/dropdown/validate-dropdown.d.ts +0 -8
  88. package/dist/widgets/expression/get-decimal-separator.d.ts +0 -5
  89. package/dist/widgets/expression/score-expression.d.ts +0 -5
  90. package/dist/widgets/expression/validate-expression.d.ts +0 -12
  91. package/dist/widgets/grapher/grapher-types.d.ts +0 -58
  92. package/dist/widgets/grapher/score-grapher.d.ts +0 -4
  93. package/dist/widgets/iframe/score-iframe.d.ts +0 -3
  94. package/dist/widgets/input-number/score-input-number.d.ts +0 -39
  95. package/dist/widgets/interactive-graphs/math/angles.d.ts +0 -7
  96. package/dist/widgets/interactive-graphs/score-interactive-graph.d.ts +0 -4
  97. package/dist/widgets/label-image/score-label-image.d.ts +0 -10
  98. package/dist/widgets/label-image/types.d.ts +0 -11
  99. package/dist/widgets/matcher/score-matcher.d.ts +0 -4
  100. package/dist/widgets/matrix/score-matrix.d.ts +0 -5
  101. package/dist/widgets/matrix/validate-matrix.d.ts +0 -13
  102. package/dist/widgets/number-line/score-number-line.d.ts +0 -4
  103. package/dist/widgets/number-line/validate-number-line.d.ts +0 -12
  104. package/dist/widgets/numeric-input/score-numeric-input.d.ts +0 -6
  105. package/dist/widgets/orderer/score-orderer.d.ts +0 -3
  106. package/dist/widgets/orderer/validate-orderer.d.ts +0 -10
  107. package/dist/widgets/plotter/score-plotter.d.ts +0 -4
  108. package/dist/widgets/plotter/validate-plotter.d.ts +0 -10
  109. package/dist/widgets/radio/score-radio.d.ts +0 -5
  110. package/dist/widgets/radio/validate-radio.d.ts +0 -12
  111. package/dist/widgets/sorter/score-sorter.d.ts +0 -4
  112. package/dist/widgets/sorter/validate-sorter.d.ts +0 -11
  113. package/dist/widgets/table/score-table.d.ts +0 -5
  114. package/dist/widgets/table/utils.d.ts +0 -7
  115. package/dist/widgets/table/validate-table.d.ts +0 -4
@@ -1,28 +0,0 @@
1
- /**
2
- * A collection of geomtry-related utility functions
3
- */
4
- import type { Coord, Line } from "../interactive2/types";
5
- export type Range = [number, number];
6
- export type SineCoefficient = [
7
- number,
8
- number,
9
- number,
10
- number
11
- ];
12
- export type QuadraticCoefficient = [number, number, number];
13
- export declare function sign(val: number): 0 | 1 | -1;
14
- export declare function ccw(a: Coord, b: Coord, c: Coord): number;
15
- export declare function collinear(a: Coord, b: Coord, c: Coord): boolean;
16
- export declare function intersects(ab: Line, cd: Line): boolean;
17
- export declare function polygonSidesIntersect(vertices: Coord[]): boolean;
18
- export declare function vector(a: any, b: any): number[];
19
- export declare function reverseVector(vector: Coord): Coord;
20
- export declare function clockwise(points: Coord[]): boolean;
21
- export declare function magnitude(v: ReadonlyArray<Coord>): number;
22
- export declare function angleMeasures(coords: ReadonlyArray<Coord>): ReadonlyArray<number>;
23
- export declare function similar(coords1: ReadonlyArray<Coord>, coords2: ReadonlyArray<Coord>, tolerance: number): boolean;
24
- export declare function lawOfCosines(a: number, b: number, c: number): number;
25
- export declare function canonicalSineCoefficients([amplitude, angularFrequency, phase, verticalOffset,]: [any, any, any, any]): any[];
26
- export declare function rotate<T>(array: ReadonlyArray<T>, n?: number): ReadonlyArray<T>;
27
- export declare function getLineEquation(first: Coord, second: Coord): string;
28
- export declare function getLineIntersection(firstPoints: ReadonlyArray<Coord>, secondPoints: ReadonlyArray<Coord>): string;
@@ -1,166 +0,0 @@
1
- /**
2
- * This file contains types used for validation and scoring. The types abide by
3
- * a naming convention so that they're easy to follow and that we remain
4
- * consistent across all of the widgets.
5
- *
6
- * These types are:
7
- *
8
- * `Perseus<Widget>UserInput`: the data returned by the widget that the user
9
- * entered. This is referred to as the 'guess' in some older parts of Perseus.
10
- *
11
- * `Perseus<Widget>ValidationData`: the data needed to do validation of the
12
- * user input. Validation refers to the different checks that we can do both on
13
- * the client-side (before submitting user input for scoring) and on the
14
- * server-side (when we score it). As such, it cannot contain any of the
15
- * sensitive scoring data that would reveal the answer.
16
- *
17
- * `Perseus<Widget>ScoringData` (nee `Perseus<Widget>Rubric`): the data needed
18
- * to score the user input. By convention, this type is defined as the set of
19
- * sensitive answer data and then intersected with
20
- * `Perseus<Widget>ValidationData`.
21
- *
22
- * For example:
23
- * ```
24
- * type Perseus<Widget>ScoringData = {
25
- * correct: string; // Used _only_ for scoring
26
- * size: number; // Used _only_ for scoring
27
- * } & Perseus<Widget>ValidationData;
28
- * ```
29
- */
30
- import type { InteractiveMarkerType } from "./widgets/label-image/types";
31
- import type { Relationship } from "./widgets/number-line/number-line";
32
- import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType } from "@khanacademy/perseus-core";
33
- export type UserInputStatus = "correct" | "incorrect" | "incomplete";
34
- export type PerseusCategorizerScoringData = {
35
- values: ReadonlyArray<number>;
36
- } & PerseusCategorizerValidationData;
37
- export type PerseusCategorizerUserInput = {
38
- values: PerseusCategorizerScoringData["values"];
39
- };
40
- export type PerseusCategorizerValidationData = {
41
- items: ReadonlyArray<string>;
42
- };
43
- export type PerseusCSProgramRubric = Empty;
44
- export type PerseusCSProgramUserInput = {
45
- status: UserInputStatus;
46
- message: string | null;
47
- };
48
- export type PerseusDropdownRubric = {
49
- choices: ReadonlyArray<PerseusDropdownChoice>;
50
- };
51
- export type PerseusDropdownUserInput = {
52
- value: number;
53
- };
54
- export type PerseusExpressionRubric = {
55
- answerForms: ReadonlyArray<PerseusExpressionAnswerForm>;
56
- functions: ReadonlyArray<string>;
57
- };
58
- export type PerseusExpressionUserInput = string;
59
- export type PerseusGroupRubric = PerseusGroupWidgetOptions;
60
- export type PerseusGroupUserInput = UserInputMap;
61
- export type PerseusGradedGroupRubric = PerseusGradedGroupWidgetOptions;
62
- export type PerseusGradedGroupSetRubric = PerseusGradedGroupSetWidgetOptions;
63
- export type PerseusGrapherRubric = {
64
- correct: GrapherAnswerTypes;
65
- };
66
- export type PerseusGrapherUserInput = PerseusGrapherRubric["correct"];
67
- export type PerseusIFrameRubric = Empty;
68
- export type PerseusIFrameUserInput = {
69
- status: UserInputStatus;
70
- message: string | null;
71
- };
72
- export type PerseusInputNumberRubric = {
73
- answerType?: "number" | "decimal" | "integer" | "rational" | "improper" | "mixed" | "percent" | "pi";
74
- inexact?: boolean;
75
- maxError?: number | string;
76
- simplify: "required" | "optional" | "enforced";
77
- value: string | number;
78
- };
79
- export type PerseusInputNumberUserInput = {
80
- currentValue: string;
81
- };
82
- export type PerseusInteractiveGraphRubric = {
83
- correct: PerseusGraphCorrectType;
84
- graph: PerseusGraphType;
85
- };
86
- export type PerseusInteractiveGraphUserInput = PerseusGraphType;
87
- export type PerseusLabelImageRubric = Empty;
88
- export type PerseusLabelImageUserInput = {
89
- markers: ReadonlyArray<InteractiveMarkerType>;
90
- };
91
- export type PerseusMatcherRubric = PerseusMatcherWidgetOptions;
92
- export type PerseusMatcherUserInput = {
93
- left: ReadonlyArray<string>;
94
- right: ReadonlyArray<string>;
95
- };
96
- export type PerseusMatrixRubric = {
97
- answers: PerseusMatrixWidgetAnswers;
98
- } & PerseusMatrixValidationData;
99
- export type PerseusMatrixValidationData = Empty;
100
- export type PerseusMatrixUserInput = {
101
- answers: PerseusMatrixRubric["answers"];
102
- };
103
- export type PerseusMockWidgetRubric = {
104
- value: string;
105
- };
106
- export type PerseusMockWidgetUserInput = {
107
- currentValue: string;
108
- };
109
- export type PerseusNumberLineScoringData = {
110
- correctRel: string | null | undefined;
111
- correctX: number;
112
- range: ReadonlyArray<number>;
113
- initialX: number | null | undefined;
114
- isInequality: boolean;
115
- };
116
- export type PerseusNumberLineUserInput = {
117
- isTickCrtl?: boolean;
118
- numLinePosition: number;
119
- rel: Relationship | "eq";
120
- numDivisions: number;
121
- divisionRange: ReadonlyArray<number>;
122
- };
123
- export type PerseusNumericInputRubric = {
124
- answers: ReadonlyArray<PerseusNumericInputAnswer>;
125
- coefficient: boolean;
126
- };
127
- export type PerseusNumericInputUserInput = {
128
- currentValue: string;
129
- };
130
- export type PerseusOrdererRubric = PerseusOrdererWidgetOptions;
131
- export type PerseusOrdererUserInput = {
132
- current: ReadonlyArray<string>;
133
- };
134
- export type PerseusPlotterScoringData = {
135
- correct: ReadonlyArray<number>;
136
- } & PerseusPlotterValidationData;
137
- export type PerseusPlotterValidationData = {
138
- starting: ReadonlyArray<number>;
139
- };
140
- export type PerseusPlotterUserInput = ReadonlyArray<number>;
141
- export type PerseusRadioRubric = {
142
- choices: ReadonlyArray<PerseusRadioChoice>;
143
- };
144
- export type PerseusRadioUserInput = {
145
- choicesSelected: ReadonlyArray<boolean>;
146
- };
147
- export type PerseusSorterRubric = {
148
- correct: ReadonlyArray<string>;
149
- };
150
- export type PerseusSorterUserInput = {
151
- options: ReadonlyArray<string>;
152
- changed: boolean;
153
- };
154
- export type PerseusTableRubric = {
155
- answers: ReadonlyArray<ReadonlyArray<string>>;
156
- };
157
- export type PerseusTableUserInput = ReadonlyArray<ReadonlyArray<string>>;
158
- export type Rubric = PerseusCategorizerScoringData | PerseusCSProgramRubric | PerseusDropdownRubric | PerseusExpressionRubric | PerseusGroupRubric | PerseusGradedGroupRubric | PerseusGradedGroupSetRubric | PerseusGrapherRubric | PerseusIFrameRubric | PerseusInputNumberRubric | PerseusInteractiveGraphRubric | PerseusLabelImageRubric | PerseusMatcherRubric | PerseusMatrixRubric | PerseusMockWidgetRubric | PerseusNumberLineScoringData | PerseusNumericInputRubric | PerseusOrdererRubric | PerseusPlotterScoringData | PerseusRadioRubric | PerseusSorterRubric | PerseusTableRubric;
159
- export type UserInput = PerseusCategorizerUserInput | PerseusCSProgramUserInput | PerseusDropdownUserInput | PerseusExpressionUserInput | PerseusGrapherUserInput | PerseusIFrameUserInput | PerseusInputNumberUserInput | PerseusInteractiveGraphUserInput | PerseusLabelImageUserInput | PerseusMatcherUserInput | PerseusMatrixUserInput | PerseusMockWidgetUserInput | PerseusNumberLineUserInput | PerseusNumericInputUserInput | PerseusOrdererUserInput | PerseusPlotterUserInput | PerseusRadioUserInput | PerseusSorterUserInput | PerseusTableUserInput;
160
- export type UserInputMap = {
161
- [widgetId: string]: UserInput | UserInputMap;
162
- };
163
- /**
164
- * deprecated prefer using UserInputMap
165
- */
166
- export type UserInputArray = ReadonlyArray<UserInputArray | UserInput | null | undefined>;
@@ -1,5 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusCategorizerScoringData, PerseusCategorizerUserInput } from "../../validation.types";
4
- declare function scoreCategorizer(userInput: PerseusCategorizerUserInput, scoringData: PerseusCategorizerScoringData, strings: PerseusStrings): PerseusScore;
5
- export default scoreCategorizer;
@@ -1,13 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { ValidationResult } from "../../types";
3
- import type { PerseusCategorizerUserInput, PerseusCategorizerValidationData } from "../../validation.types";
4
- /**
5
- * Checks userInput from the categorizer widget to see if the user has selected
6
- * a category for each item.
7
- * @param userInput - The user's input corresponding to an array of indices that
8
- * represent the selected category for each row/item.
9
- * @param validationData - An array of strings corresponding to each row/item
10
- * @param strings - Used to provide a validation message
11
- */
12
- declare function validateCategorizer(userInput: PerseusCategorizerUserInput, validationData: PerseusCategorizerValidationData, strings: PerseusStrings): ValidationResult;
13
- export default validateCategorizer;
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusCSProgramUserInput } from "../../validation.types";
3
- declare function scoreCSProgram(state: PerseusCSProgramUserInput): PerseusScore;
4
- export default scoreCSProgram;
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusDropdownRubric, PerseusDropdownUserInput } from "../../validation.types";
3
- declare function scoreDropdown(userInput: PerseusDropdownUserInput, rubric: PerseusDropdownRubric): PerseusScore;
4
- export default scoreDropdown;
@@ -1,8 +0,0 @@
1
- import type { ValidationResult } from "../../types";
2
- import type { PerseusDropdownUserInput } from "../../validation.types";
3
- /**
4
- * Checks if the user has selected an item from the dropdown before scoring.
5
- * This is shown with a userInput value / index other than 0.
6
- */
7
- declare function validateDropdown(userInput: PerseusDropdownUserInput): ValidationResult;
8
- export default validateDropdown;
@@ -1,5 +0,0 @@
1
- /**
2
- * Get the character used for separating decimals.
3
- */
4
- declare const getDecimalSeparator: (locale: string) => string;
5
- export default getDecimalSeparator;
@@ -1,5 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusExpressionRubric, PerseusExpressionUserInput } from "../../validation.types";
4
- declare function scoreExpression(userInput: PerseusExpressionUserInput, rubric: PerseusExpressionRubric, strings: PerseusStrings, locale: string): PerseusScore;
5
- export default scoreExpression;
@@ -1,12 +0,0 @@
1
- import type { ValidationResult } from "../../types";
2
- import type { PerseusExpressionUserInput } from "../../validation.types";
3
- /**
4
- * Checks user input from the expression widget to see if it is scorable.
5
- *
6
- * Note: Most of the expression widget's validation requires the Rubric because
7
- * of its use of KhanAnswerTypes as a core part of scoring.
8
- *
9
- * @see `scoreExpression()` for more details.
10
- */
11
- declare function validateExpression(userInput: PerseusExpressionUserInput): ValidationResult;
12
- export default validateExpression;
@@ -1,58 +0,0 @@
1
- import type { Coord } from "@khanacademy/perseus";
2
- export type Coords = [Coord, Coord];
3
- type SharedGrapherType = {
4
- url: string;
5
- defaultCoords: Coords;
6
- getFunctionForCoeffs: (coeffs: ReadonlyArray<number>, x: number) => number;
7
- getEquationString: (coords: Coords, asymptote?: Coords) => string | null;
8
- areEqual: (coeffs1: ReadonlyArray<number>, coeffs2: ReadonlyArray<number>) => boolean;
9
- Movable: any;
10
- getCoefficients: (coords: Coords, asymptote?: Coords) => ReadonlyArray<number> | undefined;
11
- };
12
- type AsymptoticGraphsType = {
13
- defaultAsymptote: Coords;
14
- extraCoordConstraint: (newCoord: Coord, oldCoord: Coord, coords: Coords, asymptote: Coords, graph: any) => boolean | Coord;
15
- extraAsymptoteConstraint: (newCoord: Coord, oldCoord: Coord, coords: Coords, asymptote: Coords, graph: any) => Coord;
16
- allowReflectOverAsymptote: boolean;
17
- };
18
- export type LinearType = SharedGrapherType & {
19
- getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
20
- fn: any;
21
- };
22
- };
23
- export type QuadraticType = SharedGrapherType & {
24
- getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
25
- a: number;
26
- b: number;
27
- c: number;
28
- };
29
- };
30
- export type SinusoidType = SharedGrapherType & {
31
- getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
32
- a: number;
33
- b: number;
34
- c: number;
35
- d: number;
36
- };
37
- };
38
- export type TangentType = SharedGrapherType & {
39
- getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
40
- fn: any;
41
- };
42
- };
43
- export type ExponentialType = SharedGrapherType & AsymptoticGraphsType & {
44
- getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
45
- fn: any;
46
- };
47
- };
48
- export type LogarithmType = SharedGrapherType & AsymptoticGraphsType & {
49
- getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
50
- fn: any;
51
- };
52
- };
53
- export type AbsoluteValueType = SharedGrapherType & {
54
- getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
55
- fn: any;
56
- };
57
- };
58
- export {};
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusGrapherRubric, PerseusGrapherUserInput } from "../../validation.types";
3
- declare function scoreGrapher(userInput: PerseusGrapherUserInput, rubric: PerseusGrapherRubric): PerseusScore;
4
- export default scoreGrapher;
@@ -1,3 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusIFrameUserInput } from "../../validation.types";
3
- export declare function scoreIframe(userInput: PerseusIFrameUserInput): PerseusScore;
@@ -1,39 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { PerseusInputNumberRubric, PerseusInputNumberUserInput } from "../../validation.types";
3
- import type { PerseusScore } from "@khanacademy/perseus";
4
- export declare const answerTypes: {
5
- readonly number: {
6
- readonly name: "Numbers";
7
- readonly forms: "integer, decimal, proper, improper, mixed";
8
- };
9
- readonly decimal: {
10
- readonly name: "Decimals";
11
- readonly forms: "decimal";
12
- };
13
- readonly integer: {
14
- readonly name: "Integers";
15
- readonly forms: "integer";
16
- };
17
- readonly rational: {
18
- readonly name: "Fractions and mixed numbers";
19
- readonly forms: "integer, proper, improper, mixed";
20
- };
21
- readonly improper: {
22
- readonly name: "Improper numbers (no mixed)";
23
- readonly forms: "integer, proper, improper";
24
- };
25
- readonly mixed: {
26
- readonly name: "Mixed numbers (no improper)";
27
- readonly forms: "integer, proper, mixed";
28
- };
29
- readonly percent: {
30
- readonly name: "Numbers or percents";
31
- readonly forms: "integer, decimal, proper, improper, mixed, percent";
32
- };
33
- readonly pi: {
34
- readonly name: "Numbers with pi";
35
- readonly forms: "pi";
36
- };
37
- };
38
- declare function scoreInputNumber(userInput: PerseusInputNumberUserInput, rubric: PerseusInputNumberRubric, strings: PerseusStrings): PerseusScore;
39
- export default scoreInputNumber;
@@ -1,7 +0,0 @@
1
- import type { Coord } from "@khanacademy/perseus";
2
- import type { vec } from "mafs";
3
- export declare function convertDegreesToRadians(degrees: number): number;
4
- export declare function calculateAngleInDegrees([x, y]: vec.Vector2): number;
5
- export declare function polar(r: number | vec.Vector2, th: number): vec.Vector2;
6
- export declare const getAngleFromVertex: (point: vec.Vector2, vertex: vec.Vector2) => number;
7
- export declare const getClockwiseAngle: (coords: [Coord, Coord, Coord], allowReflexAngles?: boolean) => number;
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusInteractiveGraphRubric, PerseusInteractiveGraphUserInput } from "../../validation.types";
3
- declare function scoreInteractiveGraph(userInput: PerseusInteractiveGraphUserInput, rubric: PerseusInteractiveGraphRubric): PerseusScore;
4
- export default scoreInteractiveGraph;
@@ -1,10 +0,0 @@
1
- import type { InteractiveMarkerType } from "./types";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusLabelImageRubric, PerseusLabelImageUserInput } from "../../validation.types";
4
- type InteractiveMarkerScore = {
5
- hasAnswers: boolean;
6
- isCorrect: boolean;
7
- };
8
- export declare function scoreMarker(marker: InteractiveMarkerType): InteractiveMarkerScore;
9
- declare function scoreLabelImage(userInput: PerseusLabelImageUserInput, rubric?: PerseusLabelImageRubric): PerseusScore;
10
- export default scoreLabelImage;
@@ -1,11 +0,0 @@
1
- export type MarkerType = {
2
- answers: ReadonlyArray<string>;
3
- label: string;
4
- x: number;
5
- y: number;
6
- };
7
- export type InteractiveMarkerType = MarkerType & {
8
- selected?: ReadonlyArray<string>;
9
- showCorrectness?: "correct" | "incorrect";
10
- focused?: boolean;
11
- };
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusMatcherRubric, PerseusMatcherUserInput } from "../../validation.types";
3
- declare function scoreMatcher(state: PerseusMatcherUserInput, rubric: PerseusMatcherRubric): PerseusScore;
4
- export default scoreMatcher;
@@ -1,5 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
4
- declare function scoreMatrix(userInput: PerseusMatrixUserInput, rubric: PerseusMatrixRubric, strings: PerseusStrings): PerseusScore;
5
- export default scoreMatrix;
@@ -1,13 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { ValidationResult } from "../../types";
3
- import type { PerseusMatrixUserInput, PerseusMatrixValidationData } from "../../validation.types";
4
- /**
5
- * Checks user input from the matrix widget to see if it is scorable.
6
- *
7
- * Note: The matrix widget cannot do much validation without the Scoring
8
- * Data because of its use of KhanAnswerTypes as a core part of scoring.
9
- *
10
- * @see `scoreMatrix()` for more details.
11
- */
12
- declare function validateMatrix(userInput: PerseusMatrixUserInput, validationData: PerseusMatrixValidationData, strings: PerseusStrings): ValidationResult;
13
- export default validateMatrix;
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusNumberLineScoringData, PerseusNumberLineUserInput } from "../../validation.types";
3
- declare function scoreNumberLine(userInput: PerseusNumberLineUserInput, scoringData: PerseusNumberLineScoringData): PerseusScore;
4
- export default scoreNumberLine;
@@ -1,12 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusNumberLineUserInput } from "../../validation.types";
3
- /**
4
- * Checks user input is within the allowed range and not the same as the initial
5
- * state.
6
- * @param userInput
7
- * @see 'scoreNumberLine' for the scoring logic.
8
- */
9
- declare function validateNumberLine(userInput: PerseusNumberLineUserInput): Extract<PerseusScore, {
10
- type: "invalid";
11
- }> | null;
12
- export default validateNumberLine;
@@ -1,6 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusNumericInputRubric, PerseusNumericInputUserInput } from "../../validation.types";
4
- export declare function maybeParsePercentInput(inputValue: string | number, normalizedAnswerExpected: boolean): string | number;
5
- declare function scoreNumericInput(userInput: PerseusNumericInputUserInput, rubric: PerseusNumericInputRubric, strings: PerseusStrings): PerseusScore;
6
- export default scoreNumericInput;
@@ -1,3 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusOrdererRubric, PerseusOrdererUserInput } from "../../validation.types";
3
- export declare function scoreOrderer(userInput: PerseusOrdererUserInput, rubric: PerseusOrdererRubric): PerseusScore;
@@ -1,10 +0,0 @@
1
- import type { ValidationResult } from "../../types";
2
- import type { PerseusOrdererUserInput } from "../../validation.types";
3
- /**
4
- * Checks user input from the orderer widget to see if the user has started
5
- * ordering the options, making the widget scorable.
6
- * @param userInput
7
- * @see `scoreOrderer` for more details.
8
- */
9
- declare function validateOrderer(userInput: PerseusOrdererUserInput): ValidationResult;
10
- export default validateOrderer;
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusPlotterScoringData, PerseusPlotterUserInput } from "../../validation.types";
3
- declare function scorePlotter(userInput: PerseusPlotterUserInput, scoringData: PerseusPlotterScoringData): PerseusScore;
4
- export default scorePlotter;
@@ -1,10 +0,0 @@
1
- import type { ValidationResult } from "../../types";
2
- import type { PerseusPlotterUserInput, PerseusPlotterValidationData } from "../../validation.types";
3
- /**
4
- * Checks user input to confirm it is not the same as the starting values for the graph.
5
- * This means the user has modified the graph, and the question can be scored.
6
- *
7
- * @see 'scorePlotter' for more details on scoring.
8
- */
9
- declare function validatePlotter(userInput: PerseusPlotterUserInput, validationData: PerseusPlotterValidationData): ValidationResult;
10
- export default validatePlotter;
@@ -1,5 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusRadioRubric, PerseusRadioUserInput } from "../../validation.types";
4
- declare function scoreRadio(userInput: PerseusRadioUserInput, rubric: PerseusRadioRubric, strings: PerseusStrings): PerseusScore;
5
- export default scoreRadio;
@@ -1,12 +0,0 @@
1
- import type { ValidationResult } from "../../types";
2
- import type { PerseusRadioUserInput } from "../../validation.types";
3
- /**
4
- * Checks if the user has selected at least one option. Additional validation
5
- * is done in scoreRadio to check if the number of selected options is correct
6
- * and if the user has selected both a correct option and the "none of the above"
7
- * option.
8
- * @param userInput
9
- * @see `scoreRadio` for the additional validation logic and the scoring logic.
10
- */
11
- declare function validateRadio(userInput: PerseusRadioUserInput): ValidationResult;
12
- export default validateRadio;
@@ -1,4 +0,0 @@
1
- import type { PerseusScore } from "../../types";
2
- import type { PerseusSorterRubric, PerseusSorterUserInput } from "../../validation.types";
3
- declare function scoreSorter(userInput: PerseusSorterUserInput, rubric: PerseusSorterRubric): PerseusScore;
4
- export default scoreSorter;
@@ -1,11 +0,0 @@
1
- import type { ValidationResult } from "../../types";
2
- import type { PerseusSorterUserInput } from "../../validation.types";
3
- /**
4
- * Checks user input for the sorter widget to ensure that the user has made
5
- * changes before attempting to score the widget.
6
- * @param userInput
7
- * @see 'scoreSorter' in 'packages/perseus/src/widgets/sorter/score-sorter.ts'
8
- * for more details on how the sorter widget is scored.
9
- */
10
- declare function validateSorter(userInput: PerseusSorterUserInput): ValidationResult;
11
- export default validateSorter;
@@ -1,5 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusTableRubric, PerseusTableUserInput } from "../../validation.types";
4
- declare function scoreTable(userInput: PerseusTableUserInput, rubric: PerseusTableRubric, strings: PerseusStrings): PerseusScore;
5
- export default scoreTable;
@@ -1,7 +0,0 @@
1
- /**
2
- * Filters the given table (modelled as a 2D array) to remove any rows that are
3
- * completely empty.
4
- *
5
- * @returns A new table with only non-empty rows.
6
- */
7
- export declare const filterNonEmpty: (table: ReadonlyArray<ReadonlyArray<string>>) => (readonly string[])[];
@@ -1,4 +0,0 @@
1
- import type { ValidationResult } from "../../types";
2
- import type { PerseusTableUserInput } from "../../validation.types";
3
- declare function validateTable(userInput: PerseusTableUserInput): ValidationResult;
4
- export default validateTable;