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

[Feature] Client Validation #2031

Merged
merged 19 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
99cd254
Swap out deprecated input-number with numeric-input in some tests (#1…
jeremywiebe Dec 13, 2024
0db68d2
SSS: Hook emptyWidgets() up to validation functions (#2000)
jeremywiebe Dec 14, 2024
193d913
Add test to document empty expression can be a correct answer (#2003)
jeremywiebe Dec 16, 2024
0464a76
Remove unused rubric type for CS Program (#1997)
Myranae Dec 17, 2024
b6623bb
Remove unused rubric type for iFrame (#1996)
Myranae Dec 17, 2024
0f2bec3
Refactor LabelImage to separate out answers from userInput into scori…
Myranae Dec 17, 2024
55ad836
Label-image: Extract validation out of scoring (#2016)
Myranae Dec 18, 2024
879d2a5
Rename usages of rubric to scoringData (#2006)
Myranae Dec 18, 2024
e6f7cc9
Fix some naming discrepancies and simplify Matcher scoring type (#2038)
Myranae Dec 19, 2024
a1e22a4
SSS: Improve types for validation (#2002)
jeremywiebe Dec 20, 2024
a423410
Merge branch 'main' into feature/client-validation
Myranae Dec 20, 2024
9c3e02e
Merge branch 'main' into feature/client-validation
jeremywiebe Jan 7, 2025
0a4163a
Merge branch 'main' into feature/client-validation
jeremywiebe Jan 7, 2025
5f79a67
Merge branch 'main' into feature/client-validation
jeremywiebe Jan 15, 2025
1a75ca6
[Client Validation] Fixes after merging main (#2122)
jeremywiebe Jan 21, 2025
4c10af1
[Client Validation] Use emptyWidgetsFunctional in scoring (#2083)
jeremywiebe Jan 21, 2025
39da8f0
Merge branch 'main' into feature/client-validation
jeremywiebe Jan 21, 2025
1105fa5
Remove unused parameter in `validateMatrix`
jeremywiebe Jan 21, 2025
cd0e130
Merge branch 'main' into feature/client-validation
jeremywiebe Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'main' into feature/client-validation
jeremywiebe committed Jan 22, 2025
commit cd0e130e84ef6bb62a7b742fce16a6521a9269f6
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ describe("scoreMatrix", () => {
const score = scoreMatrix(userInput, scoringData);

// Assert
expect(mockValidator).toHaveBeenCalledWith(userInput, scoringData);
expect(mockValidator).toHaveBeenCalledWith(userInput);
expect(score).toHaveBeenAnsweredCorrectly();
});

@@ -55,7 +55,7 @@ describe("scoreMatrix", () => {
const score = scoreMatrix(userInput, scoringData);

// Assert
expect(mockValidator).toHaveBeenCalledWith(userInput, scoringData);
expect(mockValidator).toHaveBeenCalledWith(userInput);
expect(score).toHaveInvalidInput();
});

2 changes: 1 addition & 1 deletion packages/perseus-score/src/widgets/matrix/score-matrix.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ function scoreMatrix(
userInput: PerseusMatrixUserInput,
scoringData: PerseusMatrixScoringData,
): PerseusScore {
const validationError = validateMatrix(userInput, scoringData);
const validationError = validateMatrix(userInput);
if (validationError != null) {
return validationError;
}
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ describe("matrixValidator", () => {
};

// Act
const result = validateMatrix(userInput, {});
const result = validateMatrix(userInput);

// Assert
expect(result).toHaveInvalidInput();
@@ -23,7 +23,7 @@ describe("matrixValidator", () => {
};

// Act
const result = validateMatrix(userInput, {});
const result = validateMatrix(userInput);

// Assert
expect(result).toHaveInvalidInput();
@@ -40,7 +40,7 @@ describe("matrixValidator", () => {
};

// Act
const result = validateMatrix(userInput, {});
const result = validateMatrix(userInput);

// Assert
expect(result).toBeNull();
17 changes: 8 additions & 9 deletions packages/perseus/src/renderer-util.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {
mapObject,
type PerseusRenderer,
type PerseusWidgetsMap,
} from "@khanacademy/perseus-core";
import {getWidgetIdsFromContent, mapObject} from "@khanacademy/perseus-core";

import {scoreIsEmpty, flattenScores} from "./util/scoring";
import {getWidgetIdsFromContent} from "./widget-type-utils";
import {
getWidgetScorer,
getWidgetValidator,
@@ -14,15 +9,18 @@ import {

import type {PerseusStrings} from "./strings";
import type {
ValidationDataMap,
PerseusRenderer,
PerseusWidgetsMap,
} from "@khanacademy/perseus-core";
import type {
UserInputMap,
PerseusScore,
ValidationDataMap,
} from "@khanacademy/perseus-score";

export function getUpgradedWidgetOptions(
oldWidgetOptions: PerseusWidgetsMap,
): PerseusWidgetsMap {
// @ts-expect-error - TS2322 - Type '(props: Props) => Partial<Record<string, CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ... 35 more ... | VideoWidget>>' is not assignable to type '(props: Props) => { [key: string]: PerseusWidget; }'.
return mapObject(oldWidgetOptions, (widgetInfo, widgetId) => {
if (!widgetInfo.type || !widgetInfo.alignment) {
const newValues: Record<string, any> = {};
@@ -40,7 +38,8 @@ export function getUpgradedWidgetOptions(

widgetInfo = {...widgetInfo, ...newValues};
}
return upgradeWidgetInfoToLatestVersion(widgetInfo);
// TODO(LEMS-2656): remove TS suppression
return upgradeWidgetInfoToLatestVersion(widgetInfo) as any;
});
}

You are viewing a condensed version of this merge commit. You can view the full changes here.