Skip to content

Conversation

@handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Dec 8, 2025

Summary:

I was looking at the score prop for ServerItemRenderer. It seemed a little sus to me. It was setting two things:

  • questionCompleted: this was only consumed in Radio, but I couldn't really understand what it's for. Didn't seem like we really needed it?
  • questionHighlightedWidgets: this seemed to be highlighting empty widgets, but that didn't make a lot of sense to me. We only allow learners to click "Check" when the user input is deemed "answerable" but answerable is based on whether there's an empty widget or not. So it's impossible to highlight empty widgets after an attempt because an attempt is impossible with empty widgets?

It would benefit SSS if it didn't need the score, so I pulled some threads.

TODOs are for LEMS-3783

@handeyeco handeyeco self-assigned this Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Size Change: -245 B (-0.05%)

Total Size: 498 kB

Filename Size Change
packages/perseus/dist/es/index.js 200 kB -245 B (-0.12%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.8 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/index.js 99.2 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 13.1 kB
packages/perseus-core/dist/es/index.js 24.9 kB
packages/perseus-editor/dist/es/index.js 97.9 kB
packages/perseus-linter/dist/es/index.js 8.64 kB
packages/perseus-score/dist/es/index.js 9.2 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 7.73 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.72 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (bed332a) and published it to npm. You
can install it using the tag PR3101.

Example:

pnpm add @khanacademy/perseus@PR3101

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3101

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3101

problemNum?: number;
questionCompleted?: boolean;
reviewMode?: boolean | null | undefined;
highlightEmptyWidgets?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not sure we ever highlight empty widgets at all. We only enable the "Check" button when we're "answerable" but we're only answerable when there are no empty widgets...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that not all frontends want to behave this way (requiring everything filled in before "Check Answer" is enabled).

However, I don't think that should block this PR. Rather, we probably want to have a prop that we set to enable empty widget highlighting. Then the frontend could allow the "Check Answer" button and if the learner clicks it, the frontend could validate the user input and if it sees that client validation fails, it could turn on the empty widget highlighting.

Comment on lines -165 to -173
if (this.props.score && this.props.score !== prevProps.score) {
const emptyQuestionAreaWidgets =
this.questionRenderer.emptyWidgets();

this.setState({
questionCompleted: this.props.score.correct,
questionHighlightedWidgets: emptyQuestionAreaWidgets,
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to get rid of this because I don't think we really need score. I think this was really just a "did we attempt a problem?" flag. Then the things we did with that didn't really seem used?

@handeyeco handeyeco changed the title Remove score from SIR Remove score prop from ServerItemRenderer Dec 8, 2025
@handeyeco handeyeco requested a review from jeremywiebe December 9, 2025 15:45
@handeyeco handeyeco marked this pull request as ready for review December 9, 2025 15:45
Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very in favour of this!

Question: how do widgets show rationale's after these changes? Is that still supported?

problemNum?: number;
questionCompleted?: boolean;
reviewMode?: boolean | null | undefined;
highlightEmptyWidgets?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that not all frontends want to behave this way (requiring everything filled in before "Check Answer" is enabled).

However, I don't think that should block this PR. Rather, we probably want to have a prop that we set to enable empty widget highlighting. Then the frontend could allow the "Check Answer" button and if the learner clicks it, the frontend could validate the user input and if it sees that client validation fails, it could turn on the empty widget highlighting.

widgetsEmpty,
);
this.props.onInteractWithWidget(widgetId);
this.props.apiOptions?.interactionCallback?.(updatedUserInput);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I wonder... with the UserInputManager, would that fully replace the need for interaction callbacks today? (Not asking you to do that in this PR, but I wonder...)

// finished rendering.
// TODO(jeff, CP-3128): Use Wonder Blocks Timing API
// eslint-disable-next-line no-restricted-syntax
setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These setTimeout()s throughout Perseus made/make testing annoying. Thanks for removing this unused function!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants