fix: hide score on submit + total denominator + projector chart cleanup
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.
This commit is contained in:
25
app/room.py
25
app/room.py
@@ -586,7 +586,11 @@ class RoomManager:
|
||||
(sid, student_id, qidx, stored_answer, submitted_at, elapsed_ms, score),
|
||||
)
|
||||
await db.commit()
|
||||
await self.broadcast_instructors(sid, await self.live_histogram_message(sid, qidx))
|
||||
# Skip live histogram build when there's no instructor listening
|
||||
# — same rationale as broadcast_presence. Submit storm should not
|
||||
# be paying for DB work that nobody consumes.
|
||||
if self.instructor_clients.get(sid):
|
||||
await self.broadcast_instructors(sid, await self.live_histogram_message(sid, qidx))
|
||||
await self.broadcast_presence(sid)
|
||||
await self.broadcast_projectors(sid)
|
||||
return {"type": "submit_ack", "question_idx": qidx, "answer": stored_answer, "score": score, "elapsed_ms": elapsed_ms}
|
||||
@@ -719,7 +723,16 @@ class RoomManager:
|
||||
|
||||
async def ended_message(self, sid: str, identity: dict[str, Any] | None = None) -> dict[str, Any]:
|
||||
you_id = identity["student_id"] if identity else None
|
||||
msg = {"type": "session_ended", "final_top5": await self.leaderboard(sid, limit=5, you_student_id=you_id)}
|
||||
pool = await self.get_pool_for_session(sid)
|
||||
msg = {
|
||||
"type": "session_ended",
|
||||
"final_top5": await self.leaderboard(sid, limit=5, you_student_id=you_id),
|
||||
# Total questions in the pool — clients use this as the
|
||||
# denominator on the "Correct X / Y" display so missed
|
||||
# questions are visibly counted as wrong (X stays low),
|
||||
# rather than hiding behind a smaller denominator.
|
||||
"total_questions": question_count(pool),
|
||||
}
|
||||
if identity:
|
||||
student = identity["student_id"]
|
||||
msg.update(await self.student_summary(sid, student))
|
||||
@@ -941,6 +954,14 @@ class RoomManager:
|
||||
}
|
||||
|
||||
async def broadcast_presence(self, sid: str) -> None:
|
||||
# Skip the (DB-heavy) message build when no instructor is listening.
|
||||
# The presence_message touches participants + question_events +
|
||||
# student_events + submissions; on a 50-student submit storm
|
||||
# those queries ran for every submit even if no admin was on
|
||||
# the WS, eating budget that mattered to the time-limited
|
||||
# question close.
|
||||
if not self.instructor_clients.get(sid):
|
||||
return
|
||||
await self.broadcast_instructors(sid, await self.presence_message(sid))
|
||||
|
||||
# ---- Projector (public big-screen view) -------------------------------
|
||||
|
||||
Reference in New Issue
Block a user