[Interactive Graph] Add logarithm graph scoring#3424
[Interactive Graph] Add logarithm graph scoring#3424ivyolamit wants to merge 2 commits intoLEMS-3953/pr4-logarithm-graph-componentfrom
Conversation
🗄️ Schema Change: No Changes ✅ |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (680fbf2) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3424If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3424If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3424 |
|
Size Change: +42 B (+0.01%) Total Size: 496 kB
ℹ️ View Unchanged
|
🛠️ Item Splitting: No Changes ✅ |
57320af to
7c67738
Compare
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
@claude review once |
There was a problem hiding this comment.
LGTM — straightforward addition that mirrors the exponential scoring pattern exactly, with solid test coverage.
Extended reasoning...
Overview
The PR adds logarithm graph scoring to score-interactive-graph.ts by importing getLogarithmCoefficients from kmath and inserting a new else if block following the existing exponential scoring block verbatim. A changeset file and 6 new test cases (invalid/correct/incorrect/equivalent-curve) are also included.
Security risks
None. This is pure scoring logic — no auth, no I/O, no user-controlled code paths beyond the already-gated coefficient computation.
Level of scrutiny
Low. The change is mechanical and self-contained: it adds ~30 lines of logic that are a direct copy of the adjacent exponential scoring block, only substituting getLogarithmCoefficients for getExponentialCoefficients. The pattern is already well-established and tested throughout the file.
Other factors
Test coverage is thorough for the new path (undefined guess, missing coords, missing asymptote, correct match, wrong match, and equivalent-curve normalization). Bundle size impact is negligible (+42 B). No CODEOWNERS concerns for this file.
76ec318 to
665cffd
Compare
7c67738 to
8976066
Compare
665cffd to
4574cb7
Compare
…h scoring to support the Logarithm graph in Interactive Graph
8976066 to
680fbf2
Compare
Summary:
PR series to add logarithm graph support to the Interactive Graph widget:
Add logarithm graph scoring to support the Logarithm graph in Interactive Graph
score-interactive-graph.tsusing direct coefficient comparisonDetails
Follows the exponential scoring pattern exactly. Computes
{a, b, c}coefficients for both the user's answer and the rubric usinggetLogarithmCoefficientsfrom kmath, then compares withapproximateDeepEqual.Scoring logic:
invalidif guess coords or asymptote are missing, or if coefficient computation fails for either sideearned: 1if[a, b, c]coefficients approximately matchearned: 0otherwiseThis means two different sets of control points that define the same logarithmic curve will score as correct — the comparison is on the mathematical function, not the specific points chosen.
Co-Authored by Claude Code (Opus)
Issue: LEMS-3953
Test plan:
pnpm tscpassespnpm knippassespnpm lintpassespnpm prettier . --checkpassesy = ln(x)coefficients → correct