diff --git a/physics/templates/physics/exam_take.html b/physics/templates/physics/exam_take.html index e3f25368..44c1661e 100755 --- a/physics/templates/physics/exam_take.html +++ b/physics/templates/physics/exam_take.html @@ -245,4 +245,43 @@ }); })(); + {% endblock %} diff --git a/physics/views.py b/physics/views.py index b3a5511e..7f4c26db 100644 --- a/physics/views.py +++ b/physics/views.py @@ -287,7 +287,15 @@ def exam_take(request, pk: int, sk: int, cid: str | None = None, passcode: str | # Save action should not trigger a full-page load for HTMX clients. if is_htmx: # Re-render the same fragment so the client can swap it in-place - return exam_take_fragment(request, pk=pk, sk=pos, cid=cid, passcode=passcode) + # and set an HX-Trigger header so the client can show a confirmation + resp = exam_take_fragment(request, pk=pk, sk=pos, cid=cid, passcode=passcode) + try: + # Use a small JSON payload so client listeners can access details if needed + resp['HX-Trigger'] = json.dumps({'saved': True}) + except Exception: + # Fallback to a simple event name + resp['HX-Trigger'] = 'saved' + return resp # Non-HTMX clients get redirected back to the same question page return redirect(take_url, sk=pos, **kwargs) elif "goto" in request.POST: