forge
Explore
Log in

Don't you dare go Hollow

🐛 auto-expire exam attempt when countdown hits 0

Browse files at this commit

c8ee30d12a2fb043af3d6ce2ee40223ac30a2e65Burak BoduroğluParent: 8f18549
  • fix
    • 🐛 auto-expire exam attempt when countdown hits 0
Show full message
fix: 🐛 auto-expire exam attempt when countdown hits 0
- set attempt status to expired + clear timer when remainingMs <= 0
- close finish dialog on expiry
src/components/exams/exam-room-ws.tsxmodified+7 -1
@@ -229,7 +229,13 @@ export function ExamRoomWS(props: { exam: Exam }) {
229 const startedAt = Date.now();229 const startedAt = Date.now();
230 const initial = remaining;230 const initial = remaining;
231 const timer = window.setInterval(() => {231 const timer = window.setInterval(() => {
232- setRemainingMs(Math.max(0, initial - (Date.now() - startedAt)));232+ const next = Math.max(0, initial - (Date.now() - startedAt));
233+ setRemainingMs(next);
234+ if (next <= 0) {
235+ setAttempt((prev) => (prev && prev.status === "in_progress" ? { ...prev, status: "expired" as any, remaining_ms: 0 } : prev));
236+ setFinishOpen(false);
237+ window.clearInterval(timer);
238+ }
233 }, 1000);239 }, 1000);
234 onCleanup(() => window.clearInterval(timer));240 onCleanup(() => window.clearInterval(timer));
235 });241 });