- HTML 89.1%
- JavaScript 10.9%
| .gitignore | ||
| check.mjs | ||
| index.html | ||
| README.md | ||
ableitungen-quiz
Five chain- and product-rule exercises that check the answer you type, not a multiple
choice. One index.html, no build step, no backend.
Why
Derivatives are learned by writing them, and "is 15(3x+2)^4 the same as
5(3x+2)^4·3?" is exactly the question a tutor answers twenty times. The page types the
answer, evaluates it, and says what went wrong: still f(x) itself, a known mistake
(missing inner derivative, missing factor ½, one product-rule term dropped), or the first
x where the typed term and the correct one disagree, with both values.
The second constraint was the device: it has to be readable on an iPad from QuickLook or
an Element preview, where no JavaScript runs. So the page carries a <details> copy of
all five tasks with hints and solutions, and the no-JS view is what you see there.
Run
Open index.html in a browser — file:// is enough:
xdg-open index.html
Math is typeset by MathJax 3 from a CDN; offline the formulas show as raw \( … \).
State (index, tries, hints used, solutions seen) is kept in localStorage under
kgpr-v1, so a reload continues where you stopped. "Nochmal von vorn" resets it.
How an answer is checked
The page contains a small expression parser, not a CAS:
- Normalise — drop a leading
f(x) =/f'(x) =, map− – —to-,· × ⋅to*,÷to/,²/³to^2/^3,√tosqrt,,to., lowercase. - Tokenise / parse — recursive descent over
+ - * / ^, parentheses, implicit multiplication (2x,3(x+1),x sin(x)), right-associative^, unary minus, functionssin cos tan ln log exp sqrt, constantspi,e, andsin xwithout brackets. Unknown characters and unterminated terms throw a readable error. - Compare numerically — both terms are evaluated at nine fixed points
(
-1.7, -0.83, 0.31, 0.77, 1.13, 1.69, 2.41, 3.07, 3.71) and accepted if they agree within1e-7 · (1 + |a| + |b|)on at least three finite points.
Wrong answers are then diagnosed in order: equal to f(x) → "that is still the function";
equal to one of the 21 curated wrong answers → its specific explanation; otherwise the
first differing point is printed with both values.
Tests
node check.mjs # 51 assertions, exit 0 = all pass
Node 18+ (ESM, top-level await), no dependencies. The script cuts the <script> block
between const TASKS and /* ---------- Zustand out of index.html and evaluates it, so
the test runs the same parser and task data the page runs — no copy to drift. Renaming
either marker makes it fail with "Marker in index.html nicht gefunden".
What the 51 assertions cover:
- 5 — each task's stored answer matches the central difference
(f(x+h)-f(x-h))/2hof its ownf(h = 1e-6, rel < 1e-4). - 5 —
f(x)itself is not accepted as its derivative (the "not derived yet" hint). - 21 — every wrong answer listed for a task is genuinely wrong.
- 10 — parser edge cases: implicit multiplication,
f'(x)=prefix,√,-x^2,2^3^2 = 512, sign errors detected,eas Euler's number,sin x. - 4 — malformed terms (
x+,sin,2*,(x+1) throw instead of silently evaluating to nonsense. - 6 — the no-JS copy lists 5 tasks and each
data-answerequals the task's answer.
Measurements
$ node check.mjs | tail -3
ok statische Aufgabe 5 trägt dieselbe Antwort wie TASKS
alle Prüfungen bestanden
$ node check.mjs | grep -c '^ok' ; node check.mjs | grep -c '^FAIL'
51
0
Worst relative deviation between a stored answer and the numeric derivative, across the
five tasks: 7.6e-11 (the check allows 1e-4). index.html is 25 KB.
Deviations
- Numeric equivalence, not symbolic. Two terms that agree on the nine sample points count as equal — a term that is wrong only between them (or zero at all nine) passes. Sampling nine points is the price for not shipping a CAS.
- The no-JS copy duplicates the task text. It has to: it is what iPad QuickLook shows.
check.mjskeeps the answers in sync; the prose is maintained by hand. - German only, and the feedback text assumes a student reading German.
- MathJax from a CDN. No vendored copy, so the page needs network for typeset math; the quiz itself works without it (raw LaTeX instead of formulas).
- Revealing a solution counts as done. The summary distinguishes "selbst gelöst" from "Lösung angesehen", but both advance.
- Answers must be typed in the notation the parser knows;
\frac,log_2, absolute values and|x|are not supported.