You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expose a way to get user input from ServerItemRenderer (#1753)
## Summary:
[Webapp PR](Khan/webapp#27079)
I'm trying to tread lightly, maybe being overly cautious at the expense of keeping too much old code around. I tried to make everything we can get rid of after the move with `@deprecated`.
Basically this should expose everything we need to move the actual scoring process out of ServerItemRenderer and the React tree. We now have `getUserInput` on `ServerItemRenderer` and `scorePerseusItem` which is a non-React, pure function that returns a score.
Next step is to replace uses of `scoreInput` in Webapp with `scorePerseusItem`; then we can come back and delete a lot of this legacy code 🤞
Issue: [LEMS-XXXX](https://khanacademy.atlassian.net/browse/LEMS-XXXX)
## Test plan:
After the swap in Webapp, we should be able to complete an exercise with `scorePerseusItem` and everything else will work the same.
[LEMS-2389]: https://khanacademy.atlassian.net/browse/LEMS-2389?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Author: handeyeco
Reviewers: jeremywiebe
Required Reviewers:
Approved By: jeremywiebe
Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ gerald
Pull Request URL: #1753
Copy file name to clipboardExpand all lines: packages/perseus/src/renderer.tsx
+17-21
Original file line number
Diff line number
Diff line change
@@ -1124,7 +1124,7 @@ class Renderer
1124
1124
// /cry(aria)
1125
1125
this._foundTextNodes=true;
1126
1126
1127
-
if(_.contains(this.widgetIds,node.id)){
1127
+
if(this.widgetIds.includes(node.id)){
1128
1128
// We don't want to render a duplicate widget key/ref,
1129
1129
// as this causes problems with react (for obvious
1130
1130
// reasons). Instead we just notify the
@@ -1510,15 +1510,15 @@ class Renderer
1510
1510
1511
1511
getInputPaths: ()=>ReadonlyArray<FocusPath>=()=>{
1512
1512
constinputPaths: Array<FocusPath>=[];
1513
-
_.each(this.widgetIds,(widgetId: string)=>{
1513
+
this.widgetIds.forEach((widgetId: string)=>{
1514
1514
constwidget=this.getWidgetInstance(widgetId);
1515
1515
if(widget&&widget.getInputPaths){
1516
1516
// Grab all input paths and add widgetID to the front
1517
1517
constwidgetInputPaths=widget.getInputPaths();
1518
1518
// Prefix paths with their widgetID and add to collective
1519
1519
// list of paths.
1520
1520
// @ts-expect-error - TS2345 - Argument of type '(inputPath: string) => void' is not assignable to parameter of type 'CollectionIterator<FocusPath, void, readonly FocusPath[]>'.
0 commit comments