Enhance exam take fragment to update global question header with current question number and stem, improving synchronization and user experience.

This commit is contained in:
Ross
2025-11-10 22:04:46 +00:00
parent 94d5771a26
commit 5a4792ea43
@@ -6,6 +6,8 @@
{{ form.non_field_errors }}
<div class="form-contents">
<!-- Mobile/fragment-visible copy of the question stem (kept hidden on md+ because main page shows it) -->
<div class="question-stem-fragment d-md-none mb-2">{{ question.stem|safe }}</div>
<ol class="physics-answer-list">
<li data-ans="a">
<div class="fieldWrapper flex-container">
@@ -74,6 +76,15 @@
<script>
(function () {
/* run after fragment is loaded */
// Update the global page header question number and stem so the top of the page stays in sync
try {
var qnum = document.getElementById('question-number');
if (qnum) { qnum.textContent = '{{ pos|add:"1" }}'; }
var qstem = document.getElementById('question-stem');
if (qstem) { qstem.innerHTML = '{{ question.stem|escapejs }}'; }
} catch (err) {
console.warn('Could not update global question header from fragment', err);
}
{% if not exam.publish_results and not cid_user_exam.completed %}
let time_limit = '{{ exam.time_limit }}';
if (time_limit != 'None') {