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:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user