-
Notifications
You must be signed in to change notification settings - Fork 350
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
Move main Scorer and Validator to PerseusScore #2165
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8aa4028
[LEMS-2737/move-scoring-logic] WIP: start the move
handeyeco b25fb6c
[LEMS-2737/move-scoring-logic] WIP: scoring registry
handeyeco d2387fc
[LEMS-2737/move-scoring-logic] WIP: handle noop scorer
handeyeco 3523c8f
[LEMS-2737/move-scoring-logic] WIP: move group scorer
handeyeco 8fc194e
[LEMS-2737/move-scoring-logic] WIP: move alignments
handeyeco 15c03e5
[LEMS-2737/move-scoring-logic] WIP: Perseus Core registry
handeyeco 39efebe
[LEMS-2737/move-scoring-logic] WIP: getSupportedAlignments
handeyeco 0934f34
[LEMS-2737/move-scoring-logic] WIP: add registry helpers
handeyeco f764d86
[LEMS-2737/move-scoring-logic] WIP: mock widget
handeyeco 5348013
[LEMS-2737/move-scoring-logic] WIP: lint/tsc happy, tests sad
handeyeco 14450db
[LEMS-2737/move-scoring-logic] WIP: fix some tests
handeyeco 38ea7b6
[LEMS-2737/move-scoring-logic] fix tests
handeyeco de0e4ae
[LEMS-2737/move-scoring-logic] convert Log to Error
handeyeco e894520
[LEMS-2737/move-scoring-logic] remove validation checks in scorers
handeyeco 7d73db2
[LEMS-2737/move-scoring-logic] fix test util file placement
handeyeco f231ad4
[LEMS-2737/move-scoring-logic] docs(changeset): Move scorePerseusItem…
handeyeco 4216e8a
[LEMS-2737/move-scoring-logic] more cleanup
handeyeco d7f2607
[LEMS-2737/move-scoring-logic] fix conflicts
handeyeco 83080a4
[LEMS-2737/move-scoring-logic] add grapher to core registry
handeyeco 34055a0
[LEMS-2737/move-scoring-logic] rename WidgetLogic to CoreWidgetRegistry
handeyeco 19a5d84
[LEMS-2737/move-scoring-logic] add oldWidgetInfo to error metadata
handeyeco d9a6699
[LEMS-2737/move-scoring-logic] secure getSupportedAlignments a little
handeyeco 488f663
[LEMS-2737/move-scoring-logic] remove underscore extends
handeyeco a916f59
[LEMS-2737/move-scoring-logic] cleanup getSupportedAlignments more
handeyeco 852109c
[LEMS-2737/move-scoring-logic] cleanup getDefaultAlignment
handeyeco 8fed47e
[LEMS-2737/move-scoring-logic] merge main, resolve conflicts
handeyeco 47569f0
[LEMS-2737/move-scoring-logic] fix conflicts
handeyeco de42db3
[LEMS-2737/move-scoring-logic] restore external API
handeyeco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,9 @@ | ||
--- | ||
"@khanacademy/perseus": major | ||
"@khanacademy/perseus-core": minor | ||
"@khanacademy/perseus-score": minor | ||
"@khanacademy/perseus-dev-ui": patch | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Move scorePerseusItem logic to PerseusScore |
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
135 changes: 135 additions & 0 deletions
135
packages/perseus-core/src/widgets/core-widget-registry.ts
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,135 @@ | ||
import categorizerWidgetLogic from "./categorizer"; | ||
import csProgramWidgetLogic from "./cs-program"; | ||
import definitionWidgetLogic from "./definition"; | ||
import dropdownWidgetLogic from "./dropdown"; | ||
import explanationWidgetLogic from "./explanation"; | ||
import expressionWidgetLogic from "./expression"; | ||
import gradedGroupWidgetLogic from "./graded-group"; | ||
import gradedGroupSetWidgetLogic from "./graded-group-set"; | ||
import grapherWidgetLogic from "./grapher"; | ||
import groupWidgetLogic from "./group"; | ||
import iframeWidgetLogic from "./iframe"; | ||
import imageWidgetLogic from "./image"; | ||
import inputNumberWidgetLogic from "./input-number"; | ||
import interactionWidgetLogic from "./interaction"; | ||
import interactiveGraphWidgetLogic from "./interactive-graph"; | ||
import labelImageWidgetLogic from "./label-image"; | ||
import matcherWidgetLogic from "./matcher"; | ||
import matrixWidgetLogic from "./matrix"; | ||
import measurerWidgetLogic from "./measurer"; | ||
import numberLineWidgetLogic from "./number-line"; | ||
import numericInputWidgetLogic from "./numeric-input"; | ||
import ordererWidgetLogic from "./orderer"; | ||
import passageWidgetLogic from "./passage"; | ||
import passageRefWidgetLogic from "./passage-ref"; | ||
import passageRefTargetWidgetLogic from "./passage-ref-target"; | ||
import phetSimulationWidgetLogic from "./phet-simulation"; | ||
import plotterWidgetLogic from "./plotter"; | ||
import pythonProgramWidgetLogic from "./python-program"; | ||
import radioWidgetLogic from "./radio"; | ||
import sorterWidgetLogic from "./sorter"; | ||
import tableWidgetLogic from "./table"; | ||
import videoWidgetLogic from "./video"; | ||
|
||
import type {WidgetLogic} from "./logic-export.types"; | ||
import type {Alignment} from "../types"; | ||
|
||
const widgets = {}; | ||
|
||
function registerWidget(type: string, logic: WidgetLogic) { | ||
widgets[type] = logic; | ||
} | ||
|
||
export function isWidgetRegistered(type: string) { | ||
const widgetLogic = widgets[type]; | ||
return !!widgetLogic; | ||
} | ||
|
||
export function getCurrentVersion(type: string) { | ||
const widgetLogic = widgets[type]; | ||
return widgetLogic?.version || {major: 0, minor: 0}; | ||
} | ||
|
||
export function getWidgetOptionsUpgrades(type: string) { | ||
const widgetLogic = widgets[type]; | ||
return widgetLogic?.widgetOptionsUpgrades || {}; | ||
} | ||
|
||
export function getDefaultWidgetOptions(type: string) { | ||
const widgetLogic = widgets[type]; | ||
return widgetLogic?.defaultWidgetOptions || {}; | ||
} | ||
|
||
/** | ||
* Handling for the optional alignments for widgets | ||
* See widget-container.jsx for details on how alignments are implemented. | ||
*/ | ||
|
||
/** | ||
* Returns the list of supported alignments for the given (string) widget | ||
* type. This is used primarily at editing time to display the choices | ||
* for the user. | ||
* | ||
* Supported alignments are given as an array of strings in the exports of | ||
* a widget's module. | ||
*/ | ||
export const getSupportedAlignments = ( | ||
type: string, | ||
): ReadonlyArray<Alignment> => { | ||
const widgetLogic = widgets[type]; | ||
if (!widgetLogic?.supportedAlignments?.[0]) { | ||
// default alignments | ||
return ["default"]; | ||
} | ||
return widgetLogic?.supportedAlignments; | ||
}; | ||
|
||
/** | ||
* For the given (string) widget type, determine the default alignment for | ||
* the widget. This is used at rendering time to go from "default" alignment | ||
* to the actual alignment displayed on the screen. | ||
* | ||
* The default alignment is given either as a string (called | ||
* `defaultAlignment`) or a function (called `getDefaultAlignment`) on | ||
* the exports of a widget's module. | ||
*/ | ||
export const getDefaultAlignment = (type: string): Alignment => { | ||
const widgetLogic = widgets[type]; | ||
if (!widgetLogic?.defaultAlignment) { | ||
return "block"; | ||
} | ||
return widgetLogic.defaultAlignment; | ||
}; | ||
|
||
registerWidget("categorizer", categorizerWidgetLogic); | ||
registerWidget("cs-program", csProgramWidgetLogic); | ||
registerWidget("definition", definitionWidgetLogic); | ||
registerWidget("dropdown", dropdownWidgetLogic); | ||
registerWidget("explanation", explanationWidgetLogic); | ||
registerWidget("expression", expressionWidgetLogic); | ||
registerWidget("graded-group", gradedGroupWidgetLogic); | ||
registerWidget("graded-group-set", gradedGroupSetWidgetLogic); | ||
registerWidget("grapher", grapherWidgetLogic); | ||
registerWidget("group", groupWidgetLogic); | ||
registerWidget("iframe", iframeWidgetLogic); | ||
registerWidget("image", imageWidgetLogic); | ||
registerWidget("input-number", inputNumberWidgetLogic); | ||
registerWidget("interaction", interactionWidgetLogic); | ||
registerWidget("interactive-graph", interactiveGraphWidgetLogic); | ||
registerWidget("label-image", labelImageWidgetLogic); | ||
registerWidget("matcher", matcherWidgetLogic); | ||
registerWidget("matrix", matrixWidgetLogic); | ||
registerWidget("measurer", measurerWidgetLogic); | ||
registerWidget("number-line", numberLineWidgetLogic); | ||
registerWidget("numeric-input", numericInputWidgetLogic); | ||
registerWidget("orderer", ordererWidgetLogic); | ||
registerWidget("passage", passageWidgetLogic); | ||
registerWidget("passage-ref", passageRefWidgetLogic); | ||
registerWidget("passage-ref-target", passageRefTargetWidgetLogic); | ||
registerWidget("phet-simulation", phetSimulationWidgetLogic); | ||
registerWidget("plotter", plotterWidgetLogic); | ||
registerWidget("python-program", pythonProgramWidgetLogic); | ||
registerWidget("radio", radioWidgetLogic); | ||
registerWidget("sorter", sorterWidgetLogic); | ||
registerWidget("table", tableWidgetLogic); | ||
registerWidget("video", videoWidgetLogic); |
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
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 |
---|---|---|
|
@@ -10,9 +10,9 @@ const defaultWidgetOptions: GradedGroupSetDefaultWidgetOptions = { | |
gradedGroups: [], | ||
}; | ||
|
||
const GradedGroupSetWidgetLogic: WidgetLogic = { | ||
const gradedGroupSetWidgetLogic: WidgetLogic = { | ||
name: "graded-group-set", | ||
defaultWidgetOptions, | ||
}; | ||
|
||
export default GradedGroupSetWidgetLogic; | ||
export default gradedGroupSetWidgetLogic; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This were just mistakes from previous PRs. |
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 |
---|---|---|
|
@@ -26,6 +26,8 @@ const defaultWidgetOptions: ImageDefaultWidgetOptions = { | |
const imageWidgetLogic: WidgetLogic = { | ||
name: "image", | ||
defaultWidgetOptions, | ||
supportedAlignments: ["block", "full-width"], | ||
defaultAlignment: "block", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alignment is used during the upgrade process, that's why I moved all of these. |
||
}; | ||
|
||
export default imageWidgetLogic; |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now all validators and scorers should be sending error codes instead of error messages, so we don't need strings anymore.