feat(scoring): rescale scores to 0.0-1.0 with 0.05 resolution

Per-question score is now a float in [0.0, 1.0] snapped to a 21-level
0.05 grid, replacing the previous 0-1000 integer scale. Easier to read
on a leaderboard, ties become acceptable rather than vanishingly rare,
and small clock-skew differences no longer split rankings.

DB schema: score is REAL now (SQLite type affinity is loose enough that
existing rows still read fine, but new inserts go in as floats).

Frontend: added fmtScore() helpers in admin.js and quiz.js to render
two decimal places consistently (0.85, 1.20, 5.00) so float-arithmetic
sums never display as 0.8500000000000001.

Tests: linear_decay/flat/exponential_decay assertions updated; added
a snap-to-grid invariant test.
This commit is contained in:
ameer
2026-05-03 00:09:35 +08:00
parent 8e8d5cfff0
commit 7a483ad3ee
6 changed files with 87 additions and 35 deletions

View File

@@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS submissions (
answer TEXT,
submitted_at TIMESTAMP,
elapsed_ms INTEGER,
score INTEGER NOT NULL DEFAULT 0,
score REAL NOT NULL DEFAULT 0,
status TEXT NOT NULL DEFAULT 'submitted',
PRIMARY KEY (sid, student_id, question_idx)
);