Skip to content

Commit

Permalink
Merge branch 'main' into new/unlimited-keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole Watts committed Sep 23, 2024
2 parents 72de686 + 1080a62 commit 0c97879
Show file tree
Hide file tree
Showing 121 changed files with 4,890 additions and 1,702 deletions.
5 changes: 0 additions & 5 deletions .changeset/blue-bees-begin.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/few-moles-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": minor
"@khanacademy/perseus-editor": minor
---

[Locked Figure Labels] View locked line labels
6 changes: 6 additions & 0 deletions .changeset/good-foxes-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": minor
"@khanacademy/perseus-editor": minor
---

[Locked Figure Labels] Add labels to locked lines' defining points in the graph and editor
5 changes: 5 additions & 0 deletions .changeset/hip-cameras-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Consolidate Measurer and DeprecatedStandin to use noopValidator
5 changes: 5 additions & 0 deletions .changeset/modern-dancers-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Move validation logic out of the Input Number widget
5 changes: 0 additions & 5 deletions .changeset/red-roses-brush.md

This file was deleted.

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

Custom Jest matchers for PerseusScore
5 changes: 0 additions & 5 deletions .changeset/small-pets-flow.md

This file was deleted.

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

Move validation logic out of the Categorizer widget
6 changes: 6 additions & 0 deletions .changeset/swift-parrots-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": minor
"@khanacademy/perseus-editor": minor
---

[Locked Figure Labels] Add/edit/delete locked line labels
5 changes: 5 additions & 0 deletions .changeset/violet-scissors-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Small tweak to validation logic for non-interactive widgets
107 changes: 79 additions & 28 deletions config/test/custom-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,78 +18,128 @@ type PerseusRenderer = {
guessAndScore: () => [Array<any>, PerseusScore];
};

type Answerable = PerseusRenderer | PerseusScore;

function isRenderer(obj: Answerable): obj is PerseusRenderer {
// @ts-expect-error - TS(2339) - TS is annoying
return obj?.guessAndScore !== undefined;
}

function check(answerable: Answerable) {
let widgetState: string = "";
let score: PerseusScore;

if (isRenderer(answerable)) {
const result = answerable.guessAndScore();
widgetState = JSON.stringify(result[0]);
score = result[1];
} else {
score = answerable;
}

return {widgetState, score};
}

function maybeAddState(message: string, widgetState: string): string {
if (!widgetState) {
return message;
}

return message + `; widget state: ${widgetState}`;
}

expect.extend({
toHaveBeenAnsweredCorrectly(renderer: PerseusRenderer) {
const [widgetState, score] = renderer.guessAndScore();
toHaveBeenAnsweredCorrectly(answerable: Answerable) {
const {widgetState, score} = check(answerable);

if (score.type === "invalid") {
const errMessage = maybeAddState(
`Invalid answer: ${score.message || "(no message)"}`,
widgetState,
);

return {
pass: false,
message: () =>
`Invalid answer: ${
score.message || "(no message)"
}; widget state ${JSON.stringify(widgetState)}`,
message: () => errMessage,
};
}

if (score.type !== "points") {
return {
pass: false,
message: () => `Problem was not fully answered`,
};
}

if (score.earned !== score.total) {
const errMessage = maybeAddState(
"Problem was answered incorrectly",
widgetState,
);

return {
pass: false,
message: () =>
`Problem was answered incorrectly. Widget state: ${JSON.stringify(
widgetState,
)}`,
message: () => errMessage,
};
}

return {pass: true, message: () => ""};
},

toHaveInvalidInput(renderer: PerseusRenderer, message: string | null) {
const [widgetState, score] = renderer.guessAndScore();
toHaveInvalidInput(answerable: Answerable, message: string | null) {
const {widgetState, score} = check(answerable);

if (score.type !== "invalid") {
const errMessage = maybeAddState(
`Answer state is not invalid. Score: ${JSON.stringify(score)}`,
widgetState,
);

return {
pass: false,
message: () =>
`Answer state is not invalid. Score: ${JSON.stringify(
score,
)}; ${JSON.stringify(widgetState)}`,
message: () => errMessage,
};
}

if (message && (!score.message || !score.message.includes(message))) {
const errMessage = maybeAddState(
`Message shown for invalid input did not include "${message}": ${
score.message || "(no message)"
}. Score: ${JSON.stringify(score)}`,
widgetState,
);

return {
pass: false,
message: () =>
`Message shown for invalid input did not include "${message}": ${
score.message || "(no message)"
}. ${JSON.stringify(score)} - ${JSON.stringify(
widgetState,
)}`,
message: () => errMessage,
};
}

return {pass: true, message: () => ""};
},

toHaveBeenAnsweredIncorrectly(renderer: PerseusRenderer) {
const [widgetState, score] = renderer.guessAndScore();
toHaveBeenAnsweredIncorrectly(answerable: Answerable) {
const {widgetState, score} = check(answerable);

if (score.type === "invalid") {
const errMessage = maybeAddState(
`Invalid answer: ${score.message || "(no message)"}`,
widgetState,
);

return {
pass: false,
message: () =>
`Invalid answer: ${
score.message || "(no message)"
}; widget state ${JSON.stringify(widgetState)}`,
message: () => errMessage,
};
}

if (score.type !== "points") {
return {
pass: false,
message: () => `Problem was not fully answered`,
};
}

if (score.earned !== 0) {
return {
pass: false,
Expand All @@ -99,6 +149,7 @@ expect.extend({
)}`,
};
}

return {pass: true, message: () => ""};
},

Expand Down
1 change: 1 addition & 0 deletions dev/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const questions: [PerseusRenderer, number][] = pairWithIndices([
interactiveGraph.polygonWithAnglesAndAnglesSnapToQuestion,
interactiveGraph.rayQuestion,
interactiveGraph.sinusoidQuestion,
interactiveGraph.noneQuestion,
grapher.absoluteValueQuestion,
grapher.exponentialQuestion,
grapher.linearQuestion,
Expand Down
28 changes: 28 additions & 0 deletions packages/perseus-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# @khanacademy/perseus-editor

## 14.3.0

### Minor Changes

- [#1630](https://github.com/Khan/perseus/pull/1630) [`fd474e58e`](https://github.com/Khan/perseus/commit/fd474e58edc39956b885fe1db323789c0db7e435) Thanks [@handeyeco](https://github.com/handeyeco)! - Convert some PropTypes to TS

* [#1638](https://github.com/Khan/perseus/pull/1638) [`973de7a65`](https://github.com/Khan/perseus/commit/973de7a653a5dd176a65cde35cfb3c0fb4efea69) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/Edit/Delete locked point labels in the editor

- [#1637](https://github.com/Khan/perseus/pull/1637) [`56166be34`](https://github.com/Khan/perseus/commit/56166be340c7c408767884be975ea157052e93df) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Locked points: Add the labels field to LockedPointType and the feature flag for locked point labels

### Patch Changes

- Updated dependencies [[`732a052f8`](https://github.com/Khan/perseus/commit/732a052f8966163768b9ee04fd6bbf504abf1902), [`fd474e58e`](https://github.com/Khan/perseus/commit/fd474e58edc39956b885fe1db323789c0db7e435), [`98eaad0d1`](https://github.com/Khan/perseus/commit/98eaad0d13fd778309fd69f8515c5d90e10d4880), [`973de7a65`](https://github.com/Khan/perseus/commit/973de7a653a5dd176a65cde35cfb3c0fb4efea69), [`ada946eac`](https://github.com/Khan/perseus/commit/ada946eac97610ffe3b5e52789bd64aaf5e08014), [`1b71657a0`](https://github.com/Khan/perseus/commit/1b71657a0b4494cdcac40ae7e232f645067894a8), [`56166be34`](https://github.com/Khan/perseus/commit/56166be340c7c408767884be975ea157052e93df), [`45bb43b92`](https://github.com/Khan/perseus/commit/45bb43b923a2498747fdf4a42388d3cda8354078), [`e910f9b80`](https://github.com/Khan/perseus/commit/e910f9b80558481dfbe4a2420935a98b32190d13)]:
- @khanacademy/perseus@34.0.0

## 14.2.0

### Minor Changes

- [#1605](https://github.com/Khan/perseus/pull/1605) [`ddc3f5d05`](https://github.com/Khan/perseus/commit/ddc3f5d057da2d2c96ba92c5f5784c245ce6f573) Thanks [@benchristel](https://github.com/benchristel)! - Add 'None' graph type, for graphs that should only display locked figures.

### Patch Changes

- [#1601](https://github.com/Khan/perseus/pull/1601) [`ef7b35bce`](https://github.com/Khan/perseus/commit/ef7b35bce082c2552cde2b3bca5edbbefbfa587a) Thanks [@benchristel](https://github.com/benchristel)! - Internal: Reorganize interactive graph editor files.

- Updated dependencies [[`51b6e1431`](https://github.com/Khan/perseus/commit/51b6e14319ec34ee0bf661f047f138f7b63034c1), [`cea62ad11`](https://github.com/Khan/perseus/commit/cea62ad11fa39234da56d1a0d7d876212a1be56a), [`ddc3f5d05`](https://github.com/Khan/perseus/commit/ddc3f5d057da2d2c96ba92c5f5784c245ce6f573), [`12b8e01bf`](https://github.com/Khan/perseus/commit/12b8e01bf89abbc88d6bfc9bf243d5a0e95b5ed3)]:
- @khanacademy/perseus@33.3.0

## 14.1.3

### Patch Changes
Expand Down
7 changes: 4 additions & 3 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.1.3",
"version": "14.3.0",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -38,8 +38,9 @@
"@khanacademy/keypad-context": "^1.0.1",
"@khanacademy/kmath": "^0.1.13",
"@khanacademy/math-input": "^21.0.2",
"@khanacademy/perseus": "^33.2.1",
"@khanacademy/perseus-core": "1.5.0"
"@khanacademy/perseus": "^34.0.0",
"@khanacademy/perseus-core": "1.5.0",
"mafs": "^0.19.0"
},
"devDependencies": {
"@khanacademy/wonder-blocks-accordion": "1.3.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ export const flags = {
"linear-system": true,
ray: true,
point: true,
none: true,

// Locked figures flags
"interactive-graph-locked-features-labels": true,
"locked-point-labels": true,
"locked-line-labels": true,
},
} satisfies APIOptions["flags"];

Expand Down
Loading

0 comments on commit 0c97879

Please sign in to comment.