From 39e1292a9d93453037b77c157ee5421ed23b88ad Mon Sep 17 00:00:00 2001 From: Tamara <60857422+Myranae@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:55:56 -0500 Subject: [PATCH] Refine iFrame's Rubric type (#1766) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary: As part of the Server Side Scoring project, this refactors iFrame's Rubric type to show it is not needed for scoring. A TODO note is added to possibly remove this as part of LEMS-2440. Issue: LEMS-2542 ## Test plan: - Confirm all checks pass Author: Myranae Reviewers: handeyeco Required Reviewers: Approved By: handeyeco Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/1766 --- .changeset/angry-foxes-cough.md | 5 +++++ packages/perseus/src/validation.types.ts | 4 ++-- .../perseus/src/widgets/iframe/iframe-validator.ts | 12 +++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .changeset/angry-foxes-cough.md diff --git a/.changeset/angry-foxes-cough.md b/.changeset/angry-foxes-cough.md new file mode 100644 index 0000000000..fb6348befc --- /dev/null +++ b/.changeset/angry-foxes-cough.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Refine iFrame's Rubric type diff --git a/packages/perseus/src/validation.types.ts b/packages/perseus/src/validation.types.ts index 28fbf5c7f0..d8f6c4c068 100644 --- a/packages/perseus/src/validation.types.ts +++ b/packages/perseus/src/validation.types.ts @@ -6,7 +6,6 @@ import type { PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, - PerseusIFrameWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, @@ -69,7 +68,8 @@ export type PerseusGrapherRubric = { export type PerseusGrapherUserInput = PerseusGrapherRubric["correct"]; -export type PerseusIFrameRubric = PerseusIFrameWidgetOptions; +// TODO(LEMS-2440): Can possibly be removed during 2440; only userInput used +export type PerseusIFrameRubric = Empty; export type PerseusIFrameUserInput = { status: UserInputStatus; diff --git a/packages/perseus/src/widgets/iframe/iframe-validator.ts b/packages/perseus/src/widgets/iframe/iframe-validator.ts index 6dcdf8088b..e2d1157ef7 100644 --- a/packages/perseus/src/widgets/iframe/iframe-validator.ts +++ b/packages/perseus/src/widgets/iframe/iframe-validator.ts @@ -1,23 +1,25 @@ import type {PerseusScore} from "../../types"; import type {PerseusIFrameUserInput} from "../../validation.types"; -export function iframeValidator(state: PerseusIFrameUserInput): PerseusScore { +export function iframeValidator( + userInput: PerseusIFrameUserInput, +): PerseusScore { // The iframe can tell us whether it's correct or incorrect, // and pass an optional message - if (state.status === "correct") { + if (userInput.status === "correct") { return { type: "points", earned: 1, total: 1, - message: state.message || null, + message: userInput.message || null, }; } - if (state.status === "incorrect") { + if (userInput.status === "incorrect") { return { type: "points", earned: 0, total: 1, - message: state.message || null, + message: userInput.message || null, }; } return {