-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SSS: Move group scoring into group scorer (#1946)
## Summary: This PR refactors the scoring around `group` so that it follows the same pattern as all the other widgets. This means that our main `scoreWidgetsFunctional` can be simplified to remove the special case for the `group` widget. All tests still pass! Issue: LEMS-2561 ## Test plan: `yarn test` `yarn typecheck` Author: jeremywiebe Reviewers: Myranae, handeyeco, jeremywiebe Required Reviewers: Approved By: handeyeco Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1946
- Loading branch information
1 parent
b8926e3
commit f355127
Showing
7 changed files
with
60 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus": patch | ||
--- | ||
|
||
Refactor scoring for `group` widget to follow the same pattern as all other widgets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Remove debugging call in GraphSettings component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {scoreWidgetsFunctional} from "../../renderer-util"; | ||
import Util from "../../util"; | ||
|
||
import type {PerseusStrings} from "../../strings"; | ||
import type {PerseusScore} from "../../types"; | ||
import type { | ||
PerseusGroupRubric, | ||
PerseusGroupUserInput, | ||
} from "../../validation.types"; | ||
|
||
// The `group` widget is basically a widget hosting a full Perseus system in | ||
// it. As such, scoring a group means scoring all widgets it contains. | ||
function scoreGroup( | ||
userInput: PerseusGroupUserInput, | ||
options: PerseusGroupRubric, | ||
strings: PerseusStrings, | ||
locale: string, | ||
): PerseusScore { | ||
const scores = scoreWidgetsFunctional( | ||
options.widgets, | ||
Object.keys(options.widgets), | ||
userInput, | ||
strings, | ||
locale, | ||
); | ||
|
||
return Util.flattenScores(scores); | ||
} | ||
|
||
export default scoreGroup; |