From 42d209af5a3ac7d80bfb1893d59c361986a66a0a Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 5 Jan 2026 14:19:01 +0000 Subject: [PATCH] Expose current question index for global listeners and update browser URL to reflect the current question position --- .../templates/physics/partials/exam_take_fragment.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/physics/templates/physics/partials/exam_take_fragment.html b/physics/templates/physics/partials/exam_take_fragment.html index f6ade5d7..8a667cb2 100644 --- a/physics/templates/physics/partials/exam_take_fragment.html +++ b/physics/templates/physics/partials/exam_take_fragment.html @@ -93,6 +93,14 @@ } catch (err) { console.warn('Could not update global question header from fragment', err); } + // expose current question index for global listeners + window.currentQuestionPos = {{ pos }}; + // Update the browser URL to reflect the current question (so Prev/Next/Skip update URL) + try { + const pageUrlTemplate = `{% if cid %}{% url 'physics:exam_take' pk=exam.pk sk=0 cid=cid passcode=passcode %}{% else %}{% url 'physics:exam_take_user' pk=exam.pk sk=0 %}{% endif %}`; + const pageUrl = pageUrlTemplate.replace('/0/', '/' + window.currentQuestionPos + '/'); + history.replaceState(null, '', pageUrl); + } catch (e) { /* ignore */ } {% if not exam.publish_results and not cid_user_exam.completed %} let time_limit = '{{ exam.time_limit }}'; if (time_limit != 'None') {