-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary: As part of the Server Side Scoring project, this refines Grapher's Rubric to be only what is needed for scoring. It also refines the UserInput type to refer to the rubric as the types are mostly the same. In addition, it cleans up some error expects and some related TODOs by adding lots more typing. Issue: LEMS-2466 ## Test plan: - Confirm all tests pass - Confirm widget works as intended via Storybook Author: Myranae Reviewers: Myranae, handeyeco Required Reviewers: Approved By: handeyeco Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1730
- Loading branch information
Showing
7 changed files
with
309 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus": patch | ||
--- | ||
|
||
Refine Grapher types and clean up relevant code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import type {Coord} from "@khanacademy/perseus"; | ||
|
||
export type Coords = [Coord, Coord]; | ||
|
||
// Includes common properties for all function types and plotDefaults | ||
type SharedGrapherType = { | ||
url: string; | ||
defaultCoords: Coords; | ||
getFunctionForCoeffs: (coeffs: ReadonlyArray<number>, x: number) => number; | ||
getEquationString: (coords: Coords, asymptote?: Coords) => string | null; | ||
areEqual: ( | ||
coeffs1: ReadonlyArray<number>, | ||
coeffs2: ReadonlyArray<number>, | ||
) => boolean; | ||
Movable: any; | ||
getCoefficients: ( | ||
coords: Coords, | ||
asymptote?: Coords, | ||
) => ReadonlyArray<number> | undefined; | ||
}; | ||
|
||
type AsymptoticGraphsType = { | ||
defaultAsymptote: Coords; | ||
extraCoordConstraint: ( | ||
newCoord: Coord, | ||
oldCoord: Coord, | ||
coords: Coords, | ||
asymptote: Coords, | ||
graph: any, | ||
) => boolean | Coord; | ||
extraAsymptoteConstraint: ( | ||
newCoord: Coord, | ||
oldCoord: Coord, | ||
coords: Coords, | ||
asymptote: Coords, | ||
graph: any, | ||
) => Coord; | ||
allowReflectOverAsymptote: boolean; | ||
}; | ||
|
||
export type LinearType = SharedGrapherType & { | ||
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {fn: any}; | ||
}; | ||
|
||
export type QuadraticType = SharedGrapherType & { | ||
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => { | ||
a: number; | ||
b: number; | ||
c: number; | ||
}; | ||
}; | ||
|
||
export type SinusoidType = SharedGrapherType & { | ||
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => { | ||
a: number; | ||
b: number; | ||
c: number; | ||
d: number; | ||
}; | ||
}; | ||
|
||
export type TangentType = SharedGrapherType & { | ||
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {fn: any}; | ||
}; | ||
|
||
export type ExponentialType = SharedGrapherType & | ||
AsymptoticGraphsType & { | ||
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {fn: any}; | ||
}; | ||
|
||
export type LogarithmType = SharedGrapherType & | ||
AsymptoticGraphsType & { | ||
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {fn: any}; | ||
}; | ||
|
||
export type AbsoluteValueType = SharedGrapherType & { | ||
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {fn: any}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.