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') {