fix(lms): js timer form auto-submit and late POST saving
This commit is contained in:
@@ -125,6 +125,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
let timeLeft = {{ time_left_seconds }};
|
let timeLeft = {{ time_left_seconds }};
|
||||||
const display = document.getElementById('countdown-display');
|
const display = document.getElementById('countdown-display');
|
||||||
const form = document.getElementById('assignment-form');
|
const form = document.getElementById('assignment-form');
|
||||||
@@ -171,6 +172,7 @@
|
|||||||
if (timeLeft > 0) {
|
if (timeLeft > 0) {
|
||||||
updateTimer();
|
updateTimer();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ def assignment_detail(request, pk):
|
|||||||
elapsed = (now - submission.started_at).total_seconds()
|
elapsed = (now - submission.started_at).total_seconds()
|
||||||
allowed = assignment.time_limit * 60
|
allowed = assignment.time_limit * 60
|
||||||
if elapsed > allowed + 60: # 1 minute grace period for network latency
|
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
|
can_submit = False
|
||||||
submission.is_time_expired = True
|
submission.is_time_expired = True
|
||||||
submission.status = 'PENDING' # Or graded with 0
|
submission.status = 'PENDING' # Or graded with 0
|
||||||
|
|||||||
Reference in New Issue
Block a user