Skip to content

Commit

Permalink
Merge branch 'main' into locked-vector-aria
Browse files Browse the repository at this point in the history
  • Loading branch information
nishasy committed Sep 30, 2024
2 parents fddca1b + 17ebfc0 commit ca8a7a8
Show file tree
Hide file tree
Showing 51 changed files with 1,941 additions and 827 deletions.
5 changes: 0 additions & 5 deletions .changeset/angry-penguins-itch.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/breezy-rockets-greet.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@khanacademy/perseus": patch
---

Split out validation logic in Radio
Move and test Grapher's validator
6 changes: 0 additions & 6 deletions .changeset/dry-parents-invite.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/dull-kids-pretend.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/early-rivers-tell.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/eleven-elephants-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Omit unused data from interactive graph onChange callback
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@khanacademy/perseus": patch
---

Split validation logic from LabelImage
Port some tests to new custom matcher
5 changes: 5 additions & 0 deletions .changeset/honest-games-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Internal: remove dead code from InteractiveGraph.validate()
5 changes: 0 additions & 5 deletions .changeset/loud-parrots-run.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/many-apricots-repair.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/modern-sheep-bathe.md

This file was deleted.

2 changes: 0 additions & 2 deletions .changeset/nasty-coats-sin.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/nervous-otters-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Split out InteractiveGraph validator
6 changes: 0 additions & 6 deletions .changeset/rude-lamps-warn.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/sour-spoons-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Split validation logic out of Matrix
6 changes: 0 additions & 6 deletions .changeset/spotty-days-burn.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/strange-houses-breathe.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/strong-numbers-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Move validation logic out of the cs-program widget and add tests
5 changes: 0 additions & 5 deletions .changeset/ten-seas-chew.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/tough-snails-double.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/violet-icons-breathe.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/yellow-poets-poke.md

This file was deleted.

27 changes: 27 additions & 0 deletions packages/perseus-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# @khanacademy/perseus-editor

## 14.5.0

### Minor Changes

- [#1655](https://github.com/Khan/perseus/pull/1655) [`790e189a7`](https://github.com/Khan/perseus/commit/790e189a7fdcd215d78d1999879ab2fc7417e123) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked ellipse labels

* [#1653](https://github.com/Khan/perseus/pull/1653) [`ca4be05ab`](https://github.com/Khan/perseus/commit/ca4be05ab7367007330784796ad2561e3f5bb1c8) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked ellipse labels

- [#1652](https://github.com/Khan/perseus/pull/1652) [`1ed045583`](https://github.com/Khan/perseus/commit/1ed045583fec01be5baf5d4e86a8b582cbf782c2) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked vector labels

* [#1659](https://github.com/Khan/perseus/pull/1659) [`3dcb1fdf2`](https://github.com/Khan/perseus/commit/3dcb1fdf247eda0f0b78966daf04a9e4278d4373) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked function labels

- [#1658](https://github.com/Khan/perseus/pull/1658) [`20b3a2485`](https://github.com/Khan/perseus/commit/20b3a2485e2ba8deea798acc2732d9570c0dac45) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked function labels

* [#1650](https://github.com/Khan/perseus/pull/1650) [`03cddb6c3`](https://github.com/Khan/perseus/commit/03cddb6c39570e87ff2437273eb1287ff1417eec) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked vector labels

### Patch Changes

- [#1661](https://github.com/Khan/perseus/pull/1661) [`391641acb`](https://github.com/Khan/perseus/commit/391641acb153d2d6c0f8c29f5026a392ac1b3a62) Thanks [@handeyeco](https://github.com/handeyeco)! - Remove unused onInputError from APIOptions

* [#1674](https://github.com/Khan/perseus/pull/1674) [`f38d104d5`](https://github.com/Khan/perseus/commit/f38d104d580775cd67a0586143eacf7b864e4814) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Editor] Save empty full graph aria label/description as undefined

- [#1673](https://github.com/Khan/perseus/pull/1673) [`6f4702e41`](https://github.com/Khan/perseus/commit/6f4702e418ffdfaae01aa3f3a126b304b3250e34) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figures Labels] Make labels optional to increase type safety

- Updated dependencies [[`063159313`](https://github.com/Khan/perseus/commit/063159313c8b146589912ce42c14f06aa23d3e51), [`13d79edb9`](https://github.com/Khan/perseus/commit/13d79edb94fd7009b18a176b5c93b43fb03fee72), [`790e189a7`](https://github.com/Khan/perseus/commit/790e189a7fdcd215d78d1999879ab2fc7417e123), [`ae51ccdb8`](https://github.com/Khan/perseus/commit/ae51ccdb820894f6fc5c1b23556823efdd4edba6), [`3a10f6b1f`](https://github.com/Khan/perseus/commit/3a10f6b1fe85d915fbf947434d7ebdc0b35607f5), [`ca4be05ab`](https://github.com/Khan/perseus/commit/ca4be05ab7367007330784796ad2561e3f5bb1c8), [`b9d1af181`](https://github.com/Khan/perseus/commit/b9d1af181efeb093407d59ba0a8efe8912524757), [`9f9d42c4e`](https://github.com/Khan/perseus/commit/9f9d42c4e2d041408cf508f5bfaeafe03dc2acbc), [`1ed045583`](https://github.com/Khan/perseus/commit/1ed045583fec01be5baf5d4e86a8b582cbf782c2), [`9efad87d0`](https://github.com/Khan/perseus/commit/9efad87d00c58f16c5a5a95c6c7148bde62fe71a), [`3dcb1fdf2`](https://github.com/Khan/perseus/commit/3dcb1fdf247eda0f0b78966daf04a9e4278d4373), [`20b3a2485`](https://github.com/Khan/perseus/commit/20b3a2485e2ba8deea798acc2732d9570c0dac45), [`03cddb6c3`](https://github.com/Khan/perseus/commit/03cddb6c39570e87ff2437273eb1287ff1417eec), [`1642ad9c0`](https://github.com/Khan/perseus/commit/1642ad9c0cadaf2e4db316e5e4cb38a5c9a9f5fe), [`391641acb`](https://github.com/Khan/perseus/commit/391641acb153d2d6c0f8c29f5026a392ac1b3a62), [`6f4702e41`](https://github.com/Khan/perseus/commit/6f4702e418ffdfaae01aa3f3a126b304b3250e34), [`56f33ae01`](https://github.com/Khan/perseus/commit/56f33ae010390abd2050028db98c9a72fc604e1a)]:
- @khanacademy/perseus@35.0.0

## 14.4.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Perseus editors",
"author": "Khan Academy",
"license": "MIT",
"version": "14.4.0",
"version": "14.5.0",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -38,7 +38,7 @@
"@khanacademy/keypad-context": "^1.0.1",
"@khanacademy/kmath": "^0.1.13",
"@khanacademy/math-input": "^21.0.2",
"@khanacademy/perseus": "^34.1.0",
"@khanacademy/perseus": "^35.0.0",
"@khanacademy/perseus-core": "1.5.0",
"mafs": "^0.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,8 @@ const LockedLineSettings = (props: Props) => {
str += "s";
}

for (let i = 0; i < labels.length; i++) {
// Separate additional labels with commas.
if (i > 0) {
str += ",";
}
str += ` ${labels[i].text}`;
}
// Separate additional labels with commas.
str += ` ${labels.map((l) => l.text).join(", ")}`;
}

return str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,8 @@ const LockedPointSettings = (props: Props) => {
str += "s";
}

for (let i = 0; i < labels.length; i++) {
// Separate additional labels with commas.
if (i > 0) {
str += ",";
}
str += ` ${labels[i].text}`;
}
// Separate additional labels with commas.
str += ` ${labels.map((l) => l.text).join(", ")}`;
}

return str;
Expand Down
42 changes: 42 additions & 0 deletions packages/perseus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# @khanacademy/perseus

## 35.0.0

### Major Changes

- [#1668](https://github.com/Khan/perseus/pull/1668) [`063159313`](https://github.com/Khan/perseus/commit/063159313c8b146589912ce42c14f06aa23d3e51) Thanks [@handeyeco](https://github.com/handeyeco)! - Remove scoreWidgets from ServerItemRenderer

* [#1639](https://github.com/Khan/perseus/pull/1639) [`ae51ccdb8`](https://github.com/Khan/perseus/commit/ae51ccdb820894f6fc5c1b23556823efdd4edba6) Thanks [@handeyeco](https://github.com/handeyeco)! - Refactor virtally all widget types and consolidate user input

- [#1661](https://github.com/Khan/perseus/pull/1661) [`391641acb`](https://github.com/Khan/perseus/commit/391641acb153d2d6c0f8c29f5026a392ac1b3a62) Thanks [@handeyeco](https://github.com/handeyeco)! - Remove unused onInputError from APIOptions

### Minor Changes

- [#1655](https://github.com/Khan/perseus/pull/1655) [`790e189a7`](https://github.com/Khan/perseus/commit/790e189a7fdcd215d78d1999879ab2fc7417e123) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked ellipse labels

* [#1653](https://github.com/Khan/perseus/pull/1653) [`ca4be05ab`](https://github.com/Khan/perseus/commit/ca4be05ab7367007330784796ad2561e3f5bb1c8) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked ellipse labels

- [#1652](https://github.com/Khan/perseus/pull/1652) [`1ed045583`](https://github.com/Khan/perseus/commit/1ed045583fec01be5baf5d4e86a8b582cbf782c2) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked vector labels

* [#1659](https://github.com/Khan/perseus/pull/1659) [`3dcb1fdf2`](https://github.com/Khan/perseus/commit/3dcb1fdf247eda0f0b78966daf04a9e4278d4373) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked function labels

- [#1658](https://github.com/Khan/perseus/pull/1658) [`20b3a2485`](https://github.com/Khan/perseus/commit/20b3a2485e2ba8deea798acc2732d9570c0dac45) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked function labels

* [#1650](https://github.com/Khan/perseus/pull/1650) [`03cddb6c3`](https://github.com/Khan/perseus/commit/03cddb6c39570e87ff2437273eb1287ff1417eec) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked vector labels

- [#1679](https://github.com/Khan/perseus/pull/1679) [`56f33ae01`](https://github.com/Khan/perseus/commit/56f33ae010390abd2050028db98c9a72fc604e1a) Thanks [@handeyeco](https://github.com/handeyeco)! - Don't serialize widgetIsOpen

### Patch Changes

- [#1669](https://github.com/Khan/perseus/pull/1669) [`13d79edb9`](https://github.com/Khan/perseus/commit/13d79edb94fd7009b18a176b5c93b43fb03fee72) Thanks [@catandthemachines](https://github.com/catandthemachines)! - Updating protractor's default position within a graph.

* [#1662](https://github.com/Khan/perseus/pull/1662) [`3a10f6b1f`](https://github.com/Khan/perseus/commit/3a10f6b1fe85d915fbf947434d7ebdc0b35607f5) Thanks [@handeyeco](https://github.com/handeyeco)! - Split out validation logic in Radio

- [#1656](https://github.com/Khan/perseus/pull/1656) [`b9d1af181`](https://github.com/Khan/perseus/commit/b9d1af181efeb093407d59ba0a8efe8912524757) Thanks [@Myranae](https://github.com/Myranae)! - Move validation logic out of the sorter widget and add tests

* [#1665](https://github.com/Khan/perseus/pull/1665) [`9f9d42c4e`](https://github.com/Khan/perseus/commit/9f9d42c4e2d041408cf508f5bfaeafe03dc2acbc) Thanks [@nicolecomputer](https://github.com/nicolecomputer)! - Translations and polish for unlimited point

- [#1667](https://github.com/Khan/perseus/pull/1667) [`9efad87d0`](https://github.com/Khan/perseus/commit/9efad87d00c58f16c5a5a95c6c7148bde62fe71a) Thanks [@handeyeco](https://github.com/handeyeco)! - Split validation logic from LabelImage

* [#1663](https://github.com/Khan/perseus/pull/1663) [`1642ad9c0`](https://github.com/Khan/perseus/commit/1642ad9c0cadaf2e4db316e5e4cb38a5c9a9f5fe) Thanks [@benchristel](https://github.com/benchristel)! - Internal: revert buggy change to interactive graphs (never shipped)

- [#1673](https://github.com/Khan/perseus/pull/1673) [`6f4702e41`](https://github.com/Khan/perseus/commit/6f4702e418ffdfaae01aa3f3a126b304b3250e34) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figures Labels] Make labels optional to increase type safety

## 34.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Core Perseus API (includes renderers and widgets)",
"author": "Khan Academy",
"license": "MIT",
"version": "34.1.0",
"version": "35.0.0",
"publishConfig": {
"access": "public"
},
Expand Down
1 change: 1 addition & 0 deletions packages/perseus/src/mixins/widget-prop-denylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const denylist = [
"onChange",
"problemNum",
"apiOptions",
"widgetIsOpen",
"questionCompleted",
"findWidgets",
// added by src/editor.jsx, for widgets removing themselves
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type {Item} from "./multi-items/item-types";
import type {
Hint,
PerseusAnswerArea,
PerseusGraphType,
PerseusWidget,
PerseusWidgetsMap,
} from "./perseus-types";
import type {PerseusStrings} from "./strings";
import type {SizeClass} from "./util/sizing-utils";
import type {InteractiveGraphState} from "./widgets/interactive-graphs/types";
import type {KeypadAPI} from "@khanacademy/math-input";
import type {AnalyticsEventHandlerFn} from "@khanacademy/perseus-core";
import type {LinterContextProps} from "@khanacademy/perseus-linter";
Expand Down Expand Up @@ -90,7 +90,7 @@ export type ChangeHandler = (
// perseus-all-package/widgets/grapher.jsx
plot?: any;
// Interactive Graph callback (see legacy: interactive-graph.tsx)
graph?: InteractiveGraphState;
graph?: PerseusGraphType;
},
callback?: () => unknown | null | undefined,
silent?: boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {csProgramValidator} from "./cs-program-validator";

import type {PerseusCSProgramUserInput} from "../../validation.types";

describe("csProgramValidator", () => {
it("is correct when the state from the iframe shows the status is correct", () => {
// Arrange
const state: PerseusCSProgramUserInput = {
status: "correct",
message: "Good job!",
};

// Act
const result = csProgramValidator(state);

// Assert
expect(result).toHaveBeenAnsweredCorrectly();
});

it("is incorrect when the state from the iframe shows the status is incorrect", () => {
// Arrange
const state: PerseusCSProgramUserInput = {
status: "incorrect",
message: "Try again!",
};

// Act
const result = csProgramValidator(state);

// Assert
expect(result).toHaveBeenAnsweredIncorrectly();
});

// Note: It looks like the iframe only says if the answer is correct or
// incorrect, but status is set to "incomplete" by default.
it("should return invalid score before user interactions", () => {
// Arrange
const state: PerseusCSProgramUserInput = {
status: "incomplete",
message: null,
};

// Act
const result = csProgramValidator(state);

// Assert
expect(result).toHaveInvalidInput("Keep going, you're not there yet!");
});
});
29 changes: 29 additions & 0 deletions packages/perseus/src/widgets/cs-program/cs-program-validator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type {PerseusScore} from "../../types";
import type {PerseusCSProgramUserInput} from "../../validation.types";

export function csProgramValidator(
state: PerseusCSProgramUserInput,
): PerseusScore {
// The iframe can tell us whether it's correct or incorrect,
// and pass an optional message
if (state.status === "correct") {
return {
type: "points",
earned: 1,
total: 1,
message: state.message || null,
};
}
if (state.status === "incorrect") {
return {
type: "points",
earned: 0,
total: 1,
message: state.message || null,
};
}
return {
type: "invalid",
message: "Keep going, you're not there yet!",
};
}
Loading

0 comments on commit ca8a7a8

Please sign in to comment.