Repository navigation
feat(labs): implement Water Jug and Equation Crafting lab features - #131
Conversation
e870c6d to
246a5b1
Compare
…3-level difficulty progression, and UI layout refinements
246a5b1 to
6d8c96f
Compare
Vaibhav-sa30
left a comment
There was a problem hiding this comment.
Update your PR after doing suggested changes
| } catch (e) { | ||
| return NaN; | ||
| } | ||
| }; |
There was a problem hiding this comment.
The input being not validated is a critical security issue. an attacker can send a crafted HTTP POST request containing arbitrary JavaScript to execute commands directly on the server. Sanitize userExpression (and target)
There was a problem hiding this comment.
No /jug-api routes are defined in server/index.js or elsewhere on the server. Either implement the backend /jug-api routes to match the client's design, or remove the network request block and mark the Water Jug Lab as a client-side-only feature to prevent console error spam.
…ility and implement /jug-api endpoints
|
Hi @Vaibhav-sa30, thanks for the review! I've pushed the fixes: Security: Added strict input regex sanitization on userExpression & target to block code execution vulnerabilities in /alchemy-api/check. |
a441ed9 to
b645499
Compare
|
Thank you for this work, and apologies for the delayed response. We have now reviewed the security concern raised during the earlier review on 31 July, and it can be confirmed that the issue is addressed. The validation added in this PR is: const SAFE_MATH_REGEX = /^[\d\s\+\-\*\/\^\(\)\.xab]*$/;Because this permits only digits, arithmetic operators, and the letters The concern raised in review is therefore resolved. Responding to review feedback with a proper fix rather than a partial one is appreciated. There are two follow up points we would like to address before merging. 1. It may be preferable to use a mathematical expression parser rather than
|
|
Thank you for this, Krishna. I ran both labs locally from 1. It is not clear what I am supposed to do. In the Equation Crafting Lab I am shown a target of 2. The Home button is in the centre of the screen. In the Equation Crafting Lab, 3. I can skip the entire Water Jug module without learning anything. I verified this: from Level 1, clicking Each step needs a gate: the student must complete the interaction before 4. The instructions are not self-explanatory. Lines like "Water is a liquid you can touch and splash!" and "Containers hold water safely inside." describe the object but never connect to the actual mathematics — this lab is meant to teach GCD discovery. A student cannot tell what the concept is, what they did wrong, or how to correct it. Please make each step state what is being taught and give feedback when the answer is wrong, not just when it is right. One small inconsistency: the home tile describes this as a "13-level progression" but the lab itself shows "LEVEL 1 OF 22". Please make these agree. The engineering is sound and the features are genuinely a good idea. What needs another pass is the pedagogy — a student should not be able to finish a module without understanding it. Please address these and I will re-review. |
|
Hi @jgupta05072003-code and @Vaibhav-sa30 👋 Thank you so much for the detailed review and guidance! I have addressed all 4 points along with the mathjs security refactoring:
Detailed Implementation Overview💧 1. Water Jug Lab: Component-by-Component Intuition Journey
🧪 2. Equation Crafting Lab: Minimal, Intuitive UI for Kids
🛡️ 3. Security & Code Refactoring
All updates have been tested locally ( |
|
Hi @jgupta05072003-code mam, just checking in to see if the recent updates in ae66425 look good on your end, or if any further adjustments are needed before merge order 1. Thank you! |
|
Thank you, @jgupta05072003-code mam, for your support and mentorship throughout this contribution. The PR has been successfully merged. I really appreciate your guidance and support. |
Summary
Tenali is a larger learning platform with a number of interactive STEM modules already in place. This PR covers my contribution to it: a rework of two specific modules, the Water Jug Lab and the Equation Crafting Lab.
The main goal was to make both labs easier for younger kids (5+) to actually learn from, without dumbing down the underlying math. That meant breaking the Water Jug problem into a much gentler difficulty curve and cleaning up a bunch of UI clutter in Equation Crafting.
Neither lab is a small, cosmetic touch-up — the Water Jug Lab in particular went from a single undifferentiated difficulty setting to an actual 22-step curriculum with a real onboarding path. Equation Crafting was more of a layout and polish pass, but it fixes a genuinely annoying scrolling problem and removes duplicate heading text that had built up over a few iterations.
Why
Water Jug Lab is really teaching linear Diophantine equations ($ax + by = c$ ), where a solution only exists if $c$ is a multiple of $\gcd(a, b)$ . That's a genuinely subtle number theory idea, and the old version had no middle ground between trivial one-pour problems and puzzles requiring five or more non-obvious steps, with no scaffolding in between.
This PR adds a 13-level curve (Level 0–12) plus a slower 22-step "intuition journey" so kids can build a feel for remainders, GCD limits, and unsolvable cases before tackling the real puzzles. The intuition journey is meant to be almost impossible to fail — it's less a puzzle and more a guided tour of the mechanic, so that by the time a kid hits the actual leveled puzzles they already understand what pouring and emptying do.
Equation Crafting Lab teaches expression-building, brackets, and operator precedence via a "mixing pot" metaphor. The old layout had a duplicate title, an oversized crucible container with a lot of dead space, and enough vertical padding stacked up across cards that the whole thing didn't fit on a laptop screen without scrolling. This PR tightens that up into one screen that fits on anything 1366×768 or larger.
What changed
Water Jug Lab
13-level difficulty progression (Level 0–12)
The levels are grouped into four tiers, verified directly from
WaterJugLab.jsx:(2,3)→1,(3,5)→3,(3,5)→2,(3,5)→4,(4,7)→3,(5,8)→2. BFS-based hints are available if a kid gets stuck.(4,6)→2with GCD=2,(6,9)→3with GCD=3, and(7,11)→4with GCD=1. These require multiple drain-and-fill cycles rather than a single pour sequence. This is where the underlying algorithm really has to click.(4,6)→3— GCD is 2, and 3 is not divisible by 2, so this is genuinely impossible.(6,9)→5— GCD is 3, and 5 is not divisible by 3, also impossible. Kids can pour and empty as much as they like and eventually conclude for themselves that no sequence of moves reaches the target.(9,13)→7— GCD = 1, fully solvable but requires up to 16 moves. A fitting final challenge.On Levels 10 and 11 specifically, the Pour/Empty buttons are no longer disabled the way they were at lower difficulties. Previously a
difficulty < 11guard was preventing interaction at the wrong point. Now kids can keep interacting with the jugs indefinitely on the unsolvable levels, which matters pedagogically: the "aha" moment is supposed to come from exhausting the possibilities themselves, not from the UI telling them it's impossible.The level selector itself was simplified too — instead of verbose difficulty descriptions, it's now just clean "Level 0" through "Level 12" badges in a row.
Intuition journey (steps 1–22)
This is a separate, gentler track that sits before the main leveled puzzles — think of it as a tutorial mode rather than a difficulty tier.
The 22 steps build concepts one at a time in a deliberate order:
transition: height 0.4s ease), so pouring and filling look like something physically happening.Level {n} of 22 • {concept name}, flex-start aligned with an 8px gap.Offline support
Added a local
generateLevelData(difficulty)fallback generator (lines 582–612 inWaterJugLab.jsx), so the lab runs entirely without a working backend. Previously the lab depended on a/jug-api/questionendpoint that doesn't reliably exist in all environments. Now it falls back silently.Equation Crafting Lab
<QuizLayout>now receivestitle=""whilephase === 'playing', which removes the large centered "Equation Crafting (Level 1)" heading that was crowding the top of the gameplay screen. The title is still shown on the setup screen.position: absolute; top: 24px; left: 24px) to a proper flex container (display: flex; justify-content: flex-start).width: 100%was added to.header-rowinApp.cssso the "← Home" / "← Menu" back buttons sit flush against the top-left padding boundary..crucible-innermin-height went from150pxto90px, and.crucible-pot-wrapperpadding went from25pxto14px 20px. The section title was simplified to plain "Your Mixing Pot (Crucible)" text..gameplay-areagap went from25pxto14px, and.alchemy-cardpadding was reduced to14px 20px. Combined, the lab now fits on a standard 1080p or laptop screen without scrolling.Solve:
Design tokens used
Nothing new — everything pulls from the existing token set:
var(--clr-bg)var(--clr-card)var(--clr-border)var(--clr-accent)var(--clr-text-soft)Files touched
client/src/
├── App.css # width: 100% on .header-row for left-aligned nav
├── App.jsx # QuizLayout only renders title when non-empty
├── WaterJugLab.jsx # 13 levels, 22-step intuition journey, bug fixes
├── WaterJugLab.css # jug visuals, water animation, step badges
├── EquationCraftingLab.jsx # equation crafting page
└── EquationCraftingLab.css # equation crafting page css
Testing
npm run build # ✓ built in 4.46s — 0 errors, 475 modules transformedManually checked: