From 393ab115458e095584427101ccd3139c4e20880e Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 16 Oct 2024 13:44:29 -0500 Subject: [PATCH 1/7] Update naming: state -> userInput --- .../src/widgets/label-image/label-image-validator.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/perseus/src/widgets/label-image/label-image-validator.ts b/packages/perseus/src/widgets/label-image/label-image-validator.ts index 9151ae6be9..c609a9d661 100644 --- a/packages/perseus/src/widgets/label-image/label-image-validator.ts +++ b/packages/perseus/src/widgets/label-image/label-image-validator.ts @@ -43,14 +43,15 @@ export function scoreMarker( return score; } +// TODO(LEMS-2440): Can possibly remove rubric parameter during 2440? function labelImageValidator( - state: PerseusLabelImageUserInput, + userInput: PerseusLabelImageUserInput, rubric?: PerseusLabelImageRubric, ): PerseusScore { let numAnswered = 0; let numCorrect = 0; - for (const marker of state.markers) { + for (const marker of userInput.markers) { const score = scoreMarker(marker); if (score.hasAnswers) { @@ -63,7 +64,7 @@ function labelImageValidator( } // We expect all question markers to be answered before grading. - if (numAnswered !== state.markers.length) { + if (numAnswered !== userInput.markers.length) { return { type: "invalid", message: null, @@ -74,7 +75,7 @@ function labelImageValidator( type: "points", // Markers with no expected answers are graded as correct if user // makes no answer selection. - earned: numCorrect === state.markers.length ? 1 : 0, + earned: numCorrect === userInput.markers.length ? 1 : 0, total: 1, message: null, }; From ce74fcaaa6212df43bc52684b14c954985e9617e Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 16 Oct 2024 13:45:04 -0500 Subject: [PATCH 2/7] Update rubric type and add TODO --- packages/perseus/src/widgets/label-image/label-image.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/perseus/src/widgets/label-image/label-image.tsx b/packages/perseus/src/widgets/label-image/label-image.tsx index 51a3803468..a228ac1cc2 100644 --- a/packages/perseus/src/widgets/label-image/label-image.tsx +++ b/packages/perseus/src/widgets/label-image/label-image.tsx @@ -30,7 +30,10 @@ import type {InteractiveMarkerType} from "./types"; import type {DependencyProps} from "../../dependencies"; import type {ChangeableProps} from "../../mixins/changeable"; import type {APIOptions, Widget, WidgetExports} from "../../types"; -import type {PerseusLabelImageUserInput} from "../../validation.types"; +import type { + PerseusLabelImageRubric, + PerseusLabelImageUserInput, +} from "../../validation.types"; import type {PropsFor} from "@khanacademy/wonder-blocks-core"; import type {CSSProperties} from "aphrodite"; @@ -317,7 +320,8 @@ export class LabelImage return {markers}; } - showRationalesForCurrentlySelectedChoices(rubric: LabelImageProps) { + // TODO(LEMS-2440): Can possibly remove rubric parameter during 2440? Or refactor + showRationalesForCurrentlySelectedChoices(rubric: PerseusLabelImageRubric) { const {markers} = this.props; const {onChange} = this.props; From c7798c72b9fdb670d41c2b7a4215714aca4651ed Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 16 Oct 2024 13:45:24 -0500 Subject: [PATCH 3/7] Rubric not used; refine to empty --- packages/perseus/src/validation.types.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/perseus/src/validation.types.ts b/packages/perseus/src/validation.types.ts index cb1e18ed3f..6adbcc1c8c 100644 --- a/packages/perseus/src/validation.types.ts +++ b/packages/perseus/src/validation.types.ts @@ -12,7 +12,6 @@ import type { PerseusImageWidgetOptions, PerseusInputNumberWidgetOptions, PerseusInteractionWidgetOptions, - PerseusLabelImageWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, @@ -111,7 +110,9 @@ export type PerseusInteractiveGraphRubric = { export type PerseusInteractiveGraphUserInput = PerseusGraphType; -export type PerseusLabelImageRubric = PerseusLabelImageWidgetOptions; +/* TODO(LEMS-2440): Should be removed or refactored. Grading info may need + to be moved to the rubric from userInput (mark. */ +export type PerseusLabelImageRubric = Empty; export type PerseusLabelImageUserInput = { markers: ReadonlyArray; From 60d007d54c42fc076b584774d4a9de84af9ccc5e Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 16 Oct 2024 14:27:02 -0500 Subject: [PATCH 4/7] Add changeset --- .changeset/red-points-call.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/red-points-call.md diff --git a/.changeset/red-points-call.md b/.changeset/red-points-call.md new file mode 100644 index 0000000000..bfd02d22ac --- /dev/null +++ b/.changeset/red-points-call.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Refine LabelImage's Rubric type From b4d3afca15f516d8f1f8decda4ba23fc519cf1f4 Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 16 Oct 2024 14:33:06 -0500 Subject: [PATCH 5/7] Fix comment --- packages/perseus/src/validation.types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/perseus/src/validation.types.ts b/packages/perseus/src/validation.types.ts index e29a49af96..f6885891e2 100644 --- a/packages/perseus/src/validation.types.ts +++ b/packages/perseus/src/validation.types.ts @@ -124,7 +124,7 @@ export type PerseusInteractiveGraphRubric = { export type PerseusInteractiveGraphUserInput = PerseusGraphType; /* TODO(LEMS-2440): Should be removed or refactored. Grading info may need - to be moved to the rubric from userInput (mark. */ + to be moved to the rubric from userInput. */ export type PerseusLabelImageRubric = Empty; export type PerseusLabelImageUserInput = { From 8938d99247f03e55d4f980f82f69456b23d6102b Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 17 Oct 2024 09:03:50 -0500 Subject: [PATCH 6/7] Update comment --- packages/perseus/src/widgets/label-image/label-image.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/perseus/src/widgets/label-image/label-image.tsx b/packages/perseus/src/widgets/label-image/label-image.tsx index a228ac1cc2..ef362d0370 100644 --- a/packages/perseus/src/widgets/label-image/label-image.tsx +++ b/packages/perseus/src/widgets/label-image/label-image.tsx @@ -320,7 +320,7 @@ export class LabelImage return {markers}; } - // TODO(LEMS-2440): Can possibly remove rubric parameter during 2440? Or refactor + // TODO(LEMS-2544): Investigate impact on scoring; possibly pull out &/or remove rubric parameter. showRationalesForCurrentlySelectedChoices(rubric: PerseusLabelImageRubric) { const {markers} = this.props; const {onChange} = this.props; From 2110e61278ae0f6b07250d18512b05525b805ffc Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 17 Oct 2024 09:10:27 -0500 Subject: [PATCH 7/7] Update comment --- .../perseus/src/widgets/label-image/label-image-validator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/perseus/src/widgets/label-image/label-image-validator.ts b/packages/perseus/src/widgets/label-image/label-image-validator.ts index c609a9d661..65b8bb40fa 100644 --- a/packages/perseus/src/widgets/label-image/label-image-validator.ts +++ b/packages/perseus/src/widgets/label-image/label-image-validator.ts @@ -43,7 +43,7 @@ export function scoreMarker( return score; } -// TODO(LEMS-2440): Can possibly remove rubric parameter during 2440? +// TODO(LEMS-2440): May need to pull answers out of PerseusLabelImageWidgetOptions[markers] for the rubric function labelImageValidator( userInput: PerseusLabelImageUserInput, rubric?: PerseusLabelImageRubric,