Skip to content

Commit

Permalink
Refine Interactive Graph Rubric type (#1818)
Browse files Browse the repository at this point in the history
## Summary:
As part of the Server Side Scoring project, this refines the Interactive Graph widget's rubric to only what is used during the validation project. It updates the typing of correct to a union of correct types for all types of graphs.

Initial iteration: #1813

Issue: LEMS-2473

## Test plan:
- Confirm all checks pass
- Confirm graphs of all types still work as expected

Author: Myranae

Reviewers: Myranae, benchristel, jeremywiebe, handeyeco

Required Reviewers:

Approved By: handeyeco, benchristel

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1818
  • Loading branch information
Myranae authored Nov 6, 2024
1 parent 7f196ae commit 8aaf296
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 113 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-crabs-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Refine Interactive Graph's Rubric type
71 changes: 71 additions & 0 deletions packages/perseus/src/perseus-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,77 @@ export type PerseusGraphTypeRay = {
startCoords?: CollinearTuple;
} & PerseusGraphTypeCommon;

type AngleGraphCorrect = {
type: "angle";
allowReflexAngles: boolean;
match: "congruent";
coords: [Coord, Coord, Coord];
};

type CircleGraphCorrect = {
type: "circle";
center: Coord;
radius: number;
};

type LinearGraphCorrect = {
type: "linear";
coords: CollinearTuple;
};

type LinearSystemGraphCorrect = {
type: "linear-system";
coords: [CollinearTuple, CollinearTuple];
};

type NoneGraphCorrect = {
type: "none";
};

type PointGraphCorrect = {
type: "point";
coords: ReadonlyArray<Coord>;
};

type PolygonGraphCorrect = {
type: "polygon";
match: "similar" | "congruent" | "approx";
coords: ReadonlyArray<Coord>;
};

type QuadraticGraphCorrect = {
type: "quadratic";
coords: [Coord, Coord, Coord];
};

type SegmentGraphCorrect = {
type: "segment";
coords: CollinearTuple[];
};

type SinusoidGraphCorrect = {
type: "sinusoid";
coords: CollinearTuple;
};

type RayGraphCorrect = {
type: "ray";
coords: CollinearTuple;
};

export type PerseusGraphCorrectType =
| AngleGraphCorrect
| CircleGraphCorrect
| LinearGraphCorrect
| LinearSystemGraphCorrect
| NoneGraphCorrect
| PointGraphCorrect
| PolygonGraphCorrect
| QuadraticGraphCorrect
| RayGraphCorrect
| SegmentGraphCorrect
| SinusoidGraphCorrect;

export type PerseusLabelImageWidgetOptions = {
// Translatable Text; Tex representation of choices
choices: ReadonlyArray<string>;
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus/src/validation.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
PerseusPlotterWidgetOptions,
PerseusRadioChoice,
PerseusTableWidgetOptions,
PerseusGraphCorrectType,
} from "./perseus-types";
import type {InteractiveMarkerType} from "./widgets/label-image/types";
import type {Relationship} from "./widgets/number-line/number-line";
Expand Down Expand Up @@ -97,7 +98,7 @@ export type PerseusInputNumberUserInput = {

export type PerseusInteractiveGraphRubric = {
// TODO(LEMS-2344): make the type of `correct` more specific
correct: PerseusGraphType;
correct: PerseusGraphCorrectType;
graph: PerseusGraphType;
};

Expand Down
Loading

0 comments on commit 8aaf296

Please sign in to comment.