← Back to Pull requests

feat(learn): mascot, 25 sound effects, coins + shop, two leaderboards, sentence translation and tap-to-look-up #17

Open
unknown opened this pull request with 547 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 04, 2026 01:24 UTC
Author

Reworks the Learn path around one idea: every answer should say something back.

What is in it

The path (/learn) opens on an arena card — mascot, streak, total XP, coin balance and the daily-goal ring — with the shop, the board and the next lesson one press away.

Bơ, the mascot — an original SVG creature with seven moods (idle, happy, sad, wow, think, wave, sleep). It hops on a right answer, droops on a wrong one, thinks while a question waits. One function maps a verdict to a mood and a line, so the lesson and the review describe a verdict the same way.

One sound per event — 25 synthesised WebAudio effects (src/client/lib/sfx.ts), no audio files: tap, select, match, correct, combo, almost, wrong, heart lost, out of hearts, hint, reveal, coin, buy, boost, freeze, streak, daily goal, level up, lesson start, complete, perfect, fail, unlock, error, whoosh. A soundboard in the shop auditions them; muted before the first gesture, off under a mute switch, silent on a browser without WebAudio.

Effects — confetti (28/60/120 pieces by occasion), floating XP / heart / coin numbers, combo badge, reaction flash, streak ring; all aria-hidden, all switched off under prefers-reduced-motion.

Coins, quests and a shop (/learn/shop) — lessons, reviews, the first activity of a day and three daily quests pay coins; coins buy a hint (removes two wrong options / starts a typed answer), a heart refill, 30 minutes of double XP, or a streak freeze that carries a streak across exactly one missed day. Prices and caps are server-side (src/shared/shop.ts), purchases are conditional UPDATEs so racing calls cannot double-spend, and every movement is logged (learn_coin_log, learn_shop_orders). A coin chip in the shell keeps the wallet visible outside the shop.

Two leaderboards (/learn/leaderboard) — one endpoint, two scopes: XP on the path, submitted tests on the practice side; this week (Monday start, in the reader's own day) or all time; top 50 plus the reader's own rank even when it is outside the list. Practice is ranked on attempts with the best band beside it, never on band alone. Staff accounts never appear, and only display names are returned.

Understanding the answer — after every question the footer shows the whole sentence (blank filled, model answer, or line of evidence) with the taught word underlined, a Vietnamese rendering of the sentence (cached per sentence in learn_translations, so the provider is paid once platform-wide; with no provider configured the word's gloss is still shown and the copy says why), and the word's English + Vietnamese meanings.

Tap a word to look it up — every word of a prompt, sentence, passage or model answer opens the dictionary in a bottom sheet (the same DictionaryPanel the exam uses, so a saved word lands in the notebook). Legendary lessons keep look-ups off; words are tabIndex={-1} so the tab order of a question stays sane.

Data


Migration 0017_learn_shop_and_quests.sql adds learn_profiles.coins / xp_boost_until and the tables learn_inventory, learn_shop_orders, learn_coin_log, learn_quest_rewards, learn_translations. The runtime schema is regenerated. Rate limits: 60 buys/h, 90 item uses/h, 240 translations/h, per user.

Dev ergonomics


scripts/demo-accounts.mjs now plays two lessons as the demo student on an untouched profile (75 coins, streak 1) so a fresh checkout has something in the shop; it is guarded by "profile has never earned XP", so re-running does not mint coins.

Verification


  • npm run typecheck clean (worker, client, node) · npm run lint 0 errors · npm test 378 tests / 29 files · npm run build clean.

  • npm run test:integration → 85 checks passed, 0 failed.

  • Manual, against the local Worker: completed lessons, quest settlement, buying with coins, switching the boost on (a lesson paid 13 XP → 26), the streak freeze across a missed day (streak 7 → 8, one freeze consumed), both boards with real rows, and the translation fallback with no AI provider (available: false, no error).
  • Notes


  • The sentence translation needs an AI provider. Without one the panel shows the word's own gloss and a line explaining where to configure a provider — never a blank box or an error.

  • "Two leaderboards" is implemented as one page with two scopes (Learn / Practice) rather than two routes.
  • Diff: 547 lines (+410 / -137) across 6 files Reviewer: chatgpt-codex-connector[bot] Review duration: 6m
    All Vouch review confidence checks passed
    Residual risk 0.36 = Change Risk (0.48) × (1 − Review Confidence (0.26)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 547 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 48% · Reviewer familiarity: 35%
    25%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.377
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #17"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 25.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48% (MEDIUM) · Higher = larger blast radius
    48%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 25.6% · Lower = rushed or shallow review
    25.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 35.7% · Moderate risk
    35.7%