Three small UX/fairness tweaks from manual live testing: 1. Post-submit "wait for reveal" screen: show only the response time, no score. The +score reveal leaked correctness — any positive number = correct, zero = wrong — short-circuiting the "stop and think" beat the reveal pause was supposed to enforce. Time stays as the engagement signal; score now waits for the instructor reveal. 2. Final-screen "Correct X / Y" denominator is now total_questions instead of questions_answered. Missed questions are scored zero, so they belong in the denominator visibly. Server adds total_questions to the session_ended payload. 3. Projector score-distribution: drop the in-chart count labels (they collided with each other and with the median tag at small N), restore the previously-computed-but-not-rendered x-axis tick labels at the bottom. Stats line at the foot keeps n / mean / max. Also: short-circuit the per-submit instructor + presence broadcasts when no instructor / projector is connected (no listener, no DB work). The 50-student load test was tight on margin against its 2 s time_limit; with the new presence_message / live_histogram_message DB queries firing on every submit, the margin disappeared on busy boxes. Conftest fixture also bumped to 8 s per question for the same reason — gives breathing room for sequential WS submits in the load test. 71/71 pytest green.
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import pytest
|
|
|
|
from app.pool import PoolValidationError, get_question, parse_pool_json, public_question_payload, question_time_limit
|
|
|
|
|
|
def test_pool_validation_accepts_well_formed_pool(sample_pool):
|
|
pool = parse_pool_json(sample_pool)
|
|
assert pool["title"] == "Sample Quiz"
|
|
assert pool["score_fn"] == "linear_decay"
|
|
assert question_time_limit(pool, 0) == 8
|
|
assert get_question(pool, 0)["correct"] == "B"
|
|
public = public_question_payload(pool, 0)
|
|
assert "correct" not in public
|
|
assert public["options"]["A"] == "Alpha"
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"mutator, message",
|
|
[
|
|
(lambda p: p.pop("title"), "title"),
|
|
(lambda p: p.update({"questions": []}), "at least one"),
|
|
(lambda p: p["questions"][0].pop("text"), "text"),
|
|
(lambda p: p["questions"][0].update({"options": {"A": "x"}}), "options"),
|
|
(lambda p: p["questions"][0].update({"correct": "E"}), "correct"),
|
|
(lambda p: p.update({"score_fn": "missing"}), "Unknown"),
|
|
(lambda p: p.update({"time_limit_default": 0}), "positive"),
|
|
],
|
|
)
|
|
def test_pool_validation_rejects_invalid_shapes(sample_pool, mutator, message):
|
|
mutator(sample_pool)
|
|
with pytest.raises(PoolValidationError, match=message):
|
|
parse_pool_json(sample_pool)
|
|
|
|
|
|
def test_pool_validation_rejects_invalid_json():
|
|
with pytest.raises(PoolValidationError, match="Invalid JSON"):
|
|
parse_pool_json("{bad")
|