fix(lms): js timer form auto-submit and late POST saving

This commit is contained in:
Dmitry Belan
2026-09-20 18:09:29 +03:00
parent f15a584ddc
commit 93a5ed9af7
2 changed files with 53 additions and 46 deletions
+9 -4
View File
@@ -82,10 +82,15 @@ def assignment_detail(request, pk):
elapsed = (now - submission.started_at).total_seconds()
allowed = assignment.time_limit * 60
if elapsed > allowed + 60: # 1 minute grace period for network latency
can_submit = False
submission.is_time_expired = True
submission.status = 'PENDING' # Or graded with 0
submission.save()
if request.method == 'POST':
# Allow saving this final POST, but mark it as expired
submission.is_time_expired = True
# We don't set can_submit = False here so the POST is processed
else:
can_submit = False
submission.is_time_expired = True
submission.status = 'PENDING' # Or graded with 0
submission.save()
else:
time_left_seconds = int(allowed - elapsed)
if time_left_seconds < 0: