Skip to content

Commit

Permalink
Refine iFrame's Rubric type (#1766)
Browse files Browse the repository at this point in the history
## 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: #1766
  • Loading branch information
Myranae authored Oct 28, 2024
1 parent 5ea5d59 commit 39e1292
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-foxes-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Refine iFrame's Rubric type
4 changes: 2 additions & 2 deletions packages/perseus/src/validation.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
PerseusGradedGroupWidgetOptions,
PerseusGraphType,
PerseusGroupWidgetOptions,
PerseusIFrameWidgetOptions,
PerseusMatcherWidgetOptions,
PerseusMatrixWidgetOptions,
PerseusNumberLineWidgetOptions,
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions packages/perseus/src/widgets/iframe/iframe-validator.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 39e1292

Please sign in to comment.