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

POC: score GradedGroup externally using callback #1981

Closed
wants to merge 22 commits into from
Closed

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Dec 11, 2024

Summary:

This adds a new dependency for scoring that GradedGroup can call when wanting to check answers in an Article

Issue: LEMS-2719

Test plan:

@handeyeco handeyeco self-assigned this Dec 11, 2024
@handeyeco handeyeco changed the title wip: add test and dep POC: score GradedGroup externally using callback Dec 11, 2024
Copy link
Contributor

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1981

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR1981

Copy link
Contributor

github-actions bot commented Dec 11, 2024

Size Change: +111 B (+0.01%)

Total Size: 1.27 MB

Filename Size Change
packages/perseus/dist/es/index.js 416 kB +111 B (+0.03%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/index.js 77.9 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus-editor/dist/es/index.js 688 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/strings.js 4.12 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

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 think the approach is good (using a callback for scoring), but there are likely some details around the callback that we need to suss out (regarding where the widget options come from and nesting inside graded-group-set specifically).

@@ -28,6 +28,7 @@ export type DependencyProps = Partial<

export const DependenciesContext = React.createContext<PerseusDependenciesV2>({
analytics: {onAnalyticsEvent: async () => {}},
gradingCallback: () => ({type: "invalid"}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
gradingCallback: () => ({type: "invalid"}),
scoringCallback: () => ({type: "invalid"}),


const userInput = this.rendererRef.current?.getUserInputMap();
const score: PerseusScore = this.props.gradingCallback(
this.props.widgetId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 This means that the handler of this callback will need to go through the article/item to find the widget config, plus it will need to deal with upgrading props before scoring.

What do you think of passing this.props instead of the widget ID so that the handler has everything it needs in the callback to call the scoring function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In thinking about this a bit more, I'm not sure that'll work. The props may not have the data to score. I do think it'll be slightly more complicated than just an id though. These widgets can show up inside hints, or the graded-group-set or articles. We'll need a way to uniquely identify where this widget lives so that the chrome can correctly identify which scoring data to use.

## Summary:
Remove `guessAndScore` from Renderer. This hasn't been used in learner-facing logic for a little bit now. The bulk of this PR is updating internal usage - tools for testing exercise correctness were using this (specifically in Cypress and our custom matchers for Jest); so most of the work was porting tests to use `scorePerseusItem` instead.

## Test plan:
From a learner's perspective, this is dead code. So while this is a major API change, it's mostly removing dead code and updating tests. Tests should continue to run successfully.

Author: handeyeco

Reviewers: handeyeco, Myranae, jeremywiebe

Required Reviewers:

Approved By: Myranae, jeremywiebe

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (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)

Pull Request URL: #1974
@handeyeco handeyeco changed the base branch from rm-renderer-scoring to remove-scoreinput2 December 11, 2024 20:55
An error occurred while trying to automatically change base from rm-renderer-scoring to remove-scoreinput2 December 11, 2024 20:55
Base automatically changed from remove-scoreinput2 to main December 12, 2024 13:33
@handeyeco handeyeco closed this Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants