diff --git a/physics/templates/physics/exam_take.html b/physics/templates/physics/exam_take.html index 83d820fe..dc02a5c3 100755 --- a/physics/templates/physics/exam_take.html +++ b/physics/templates/physics/exam_take.html @@ -53,6 +53,21 @@ // Minimal per-question status injected by view: answered/flagged arrays window.examQuestionAnswered = {{ answered_json|safe }}; window.examQuestionFlagged = {{ flagged_json|safe }}; + // Update the visual state of the question menu based on global arrays + window.updateQuestionMenu = function(){ + try{ + const answered = window.examQuestionAnswered || []; + const flagged = window.examQuestionFlagged || []; + const pos = (typeof window.currentQuestionPos === 'number') ? window.currentQuestionPos : NaN; + document.querySelectorAll('#menu-list .question-menu-item').forEach(btn => { + const idx = parseInt(btn.dataset.qn, 10); + btn.classList.toggle('answered', !!answered[idx]); + btn.classList.toggle('flagged', !!flagged[idx]); + btn.classList.toggle('current-question', idx === pos); + // ensure text colour remains white (use CSS var) - no-op if CSS already set + }); + }catch(e){ console && console.error && console.error(e); } + }; {% include "physics/exam_take_help.html" %} @@ -298,14 +313,18 @@ requestAnimationFrame(function(){ el.style.opacity = '1'; }); // hide after 1.6s setTimeout(function(){ el.style.opacity = '0'; }, 1600); - // Update the question list state locally so the menu reflects answered questions + // Update the question list state locally so the menu reflects answered questions try { var pos = (typeof window.currentQuestionPos === 'number') ? window.currentQuestionPos : (document.getElementById('question-number') ? parseInt(document.getElementById('question-number').textContent, 10) - 1 : NaN); if (!isNaN(pos)) { window.examQuestionAnswered = window.examQuestionAnswered || new Array({{ exam_length }}).fill(false); window.examQuestionAnswered[pos] = true; - var btn = document.querySelector('#menu-list [data-qn="' + pos + '"]'); - if (btn) btn.classList.add('answered'); + if(typeof window.updateQuestionMenu === 'function'){ + window.updateQuestionMenu(); + } else { + var btn = document.querySelector('#menu-list [data-qn="' + pos + '"]'); + if (btn) btn.classList.add('answered'); + } } } catch (e) { console && console.error && console.error(e); } } catch (e) { console && console.error && console.error(e); } diff --git a/physics/templates/physics/exam_take_overview.html b/physics/templates/physics/exam_take_overview.html index 8780ee71..468de6d8 100644 --- a/physics/templates/physics/exam_take_overview.html +++ b/physics/templates/physics/exam_take_overview.html @@ -2,11 +2,11 @@ {% block content %} - {% if not cid %} - User: {{request.user}} - {% else %} - CID: {{cid}} - {% endif %} + {% if not cid %} + User: {{request.user}} + {% else %} + CID: {{cid}} + {% endif %} {% include "exam_clock.html" %} @@ -14,7 +14,7 @@ {% if exam.publish_results %}