Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverting all Server Side Scoring and Input Number conversion Project logic #1905

Merged
merged 9 commits into from
Nov 22, 2024
Merged
7 changes: 7 additions & 0 deletions .changeset/stupid-pillows-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@khanacademy/perseus-dev-ui": major
"@khanacademy/perseus": major
"@khanacademy/perseus-editor": major
---

We're reverting work done for the Server Side Scoring and Input Number Conversion projects.
11 changes: 1 addition & 10 deletions dev/flipbook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {useEffect, useMemo, useReducer, useRef, useState} from "react";

import {Renderer} from "../packages/perseus/src";
import {SvgImage} from "../packages/perseus/src/components";
import {scorePerseusItem} from "../packages/perseus/src/renderer-util";
import {mockStrings} from "../packages/perseus/src/strings";
import {isCorrect} from "../packages/perseus/src/util";
import {trueForAllMafsSupportedGraphTypes} from "../packages/perseus/src/widgets/interactive-graphs/mafs-supported-graph-types";
Expand Down Expand Up @@ -320,15 +319,7 @@ function GradableRenderer(props: QuestionRendererProps) {
leftContent={
<Button
onClick={() => {
if (rendererRef.current) {
const score = scorePerseusItem(
question,
rendererRef.current.getUserInputMap(),
mockStrings,
"en",
);
setScore(score);
}
setScore(rendererRef.current?.score());
clearScoreTimeout.set();
}}
>
Expand Down
40 changes: 2 additions & 38 deletions packages/perseus-editor/src/__stories__/article-editor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,14 @@ import {useRef, useState} from "react";
import ArticleEditor from "../article-editor";
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing";

import type {PerseusRenderer} from "@khanacademy/perseus";

registerAllWidgetsAndEditorsForTesting();

export default {
title: "PerseusEditor/ArticleEditor",
};
const articleSectionWithInputNumber: PerseusRenderer = {
content:
"### Practice Problem\n\n$8\\cdot(11i+2)=$ [[☃ input-number 1]]. Also [[☃ input-number 2]] \n*.*",
images: {},
widgets: {
"input-number 1": {
type: "input-number",
graded: true,
alignment: "default",
options: {
maxError: 0.1,
inexact: false,
value: 0.4,
simplify: "optional",
answerType: "rational",
size: "normal",
},
version: {major: 1, minor: 0},
},
"input-number 2": {
type: "input-number",
graded: true,
alignment: "default",
options: {
maxError: 0.1,
inexact: false,
value: 0.5,
simplify: "optional",
answerType: "rational",
size: "normal",
},
version: {major: 1, minor: 0},
},
},
};

export const Base = (): React.ReactElement => {
const [state, setState] = useState(articleSectionWithInputNumber);
const [state, setState] = useState();
const articleEditorRef = useRef();

function handleChange(value) {
Expand Down
38 changes: 0 additions & 38 deletions packages/perseus-editor/src/__stories__/editor-page.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,12 @@ import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widge

import EditorPageWithStorybookPreview from "./editor-page-with-storybook-preview";

import type {InputNumberWidget, PerseusRenderer} from "@khanacademy/perseus";

registerAllWidgetsAndEditorsForTesting(); // SIDE_EFFECTY!!!! :cry:

export default {
title: "PerseusEditor/EditorPage",
};

const question1: PerseusRenderer = {
content:
"Denis baked a peach pie and cut it into $3$ equal-sized pieces. Denis's dad eats $1$ section of the pie. \n\n**What fraction of the pie did Denis's dad eat?** \n![](https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png) \n[[\u2603 input-number 1]] \n\n\n\n",
images: {
"https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png":
{
width: 200,
height: 200,
},
},
widgets: {
"input-number 1": {
version: {
major: 0,
minor: 0,
},
type: "input-number",
graded: true,
alignment: "default",
options: {
maxError: 0.1,
inexact: false,
value: 0.5,
simplify: "optional",
answerType: "rational",
size: "normal",
},
} as InputNumberWidget,
},
};

export const Demo = (): React.ReactElement => {
return <EditorPageWithStorybookPreview />;
};

// Used to test that Input Numbers are being automatically converted to Numeric Inputs
export const InputNumberDemo = (): React.ReactElement => {
return <EditorPageWithStorybookPreview question={question1} />;
};
37 changes: 15 additions & 22 deletions packages/perseus-editor/src/__tests__/traversal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,24 @@ const missingOptions = {
const clonedMissingOptions = JSON.parse(JSON.stringify(missingOptions));

const sampleOptions = {
content: "[[☃ numeric-input 1]]",
content: "[[☃ input-number 1]]",
images: {},
widgets: {
"numeric-input 1": {
type: "numeric-input",
"input-number 1": {
type: "input-number",
graded: true,
static: false,
options: {
answers: [
{
value: 0,
status: "correct",
message: "",
simplify: "required",
strict: true,
maxError: 0.1,
},
],
value: "0",
simplify: "required",
size: "normal",
coefficient: false,
labelText: "",
inexact: false,
maxError: 0.1,
answerType: "number",
rightAlign: false,
},
static: false,
version: {
major: 1,
major: 0,
minor: 0,
},
alignment: "default",
Expand Down Expand Up @@ -265,7 +258,7 @@ describe("Traversal", () => {
readContent = content;
});

expect(readContent).toBe("[[☃ numeric-input 1]]");
expect(readContent).toBe("[[☃ input-number 1]]");
assertNonMutative();
});

Expand All @@ -287,7 +280,7 @@ describe("Traversal", () => {
widgetMap[widgetInfo.type] = (widgetMap[widgetInfo.type] || 0) + 1;
});
expect(widgetMap).toEqual({
"numeric-input": 1,
"input-number": 1,
});
assertNonMutative();
});
Expand All @@ -301,9 +294,9 @@ describe("Traversal", () => {
expect(newOptions).toEqual(
_.extend({}, sampleOptions, {
widgets: {
"numeric-input 1": _.extend(
"input-number 1": _.extend(
{},
sampleOptions.widgets["numeric-input 1"],
sampleOptions.widgets["input-number 1"],
{graded: false},
),
},
Expand All @@ -319,7 +312,7 @@ describe("Traversal", () => {
});
});
expect(newOptions.content).toBe(
"[[☃ numeric-input 1]]\n\nnew content!",
"[[☃ input-number 1]]\n\nnew content!",
);
expect(newOptions.widgets).toEqual(sampleOptions.widgets);
assertNonMutative();
Expand Down
Loading
Loading