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
@@ -125,6 +125,7 @@
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
let timeLeft = {{ time_left_seconds }};
const display = document.getElementById('countdown-display');
const form = document.getElementById('assignment-form');
@@ -171,6 +172,7 @@
if (timeLeft > 0) {
updateTimer();
}
});
</script>
{% endif %}
+5
View File
@@ -82,6 +82,11 @@ 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
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