Refactor personal exam creation section for improved readability and structure

This commit is contained in:
Ross
2025-10-27 12:42:34 +00:00
parent 3f56af4881
commit ef26182b1a
+29 -29
View File
@@ -59,37 +59,37 @@
})(); })();
</script> </script>
<hr/> <hr/>
<div class="mt-3"> <div class="mt-3">
<h5>Create your personal exam</h5> <h5>Create your personal exam</h5>
<p>Generate a personal SBA exam from the filtered question bank. Optionally limit the number of questions.</p> <p>Generate a personal SBA exam from the filtered question bank. Optionally limit the number of questions.</p>
<form id="create-exam-form" method="post" action="{% url 'sbas:exam_create_from_filters' %}"> <form id="create-exam-form" method="post" action="{% url 'sbas:exam_create_from_filters' %}">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="category" id="create-category" /> <input type="hidden" name="category" id="create-category" />
<input type="hidden" name="status" id="create-status" /> <input type="hidden" name="status" id="create-status" />
<div class="mb-2"> <div class="mb-2">
<label for="create-count" class="form-label">Number of questions (0 = all)</label> <label for="create-count" class="form-label">Number of questions (0 = all)</label>
<input type="number" name="count" id="create-count" class="form-control" min="0" value="0" /> <input type="number" name="count" id="create-count" class="form-control" min="0" value="0" />
</div> </div>
<button id="create-exam-btn" type="button" class="btn btn-success">Create my exam</button> <button id="create-exam-btn" type="button" class="btn btn-success">Create my exam</button>
</form> </form>
</div> </div>
<script> <script>
(function(){ (function(){
const createBtn = document.getElementById('create-exam-btn'); const createBtn = document.getElementById('create-exam-btn');
createBtn.addEventListener('click', function(){ createBtn.addEventListener('click', function(){
const categoryEl = document.getElementById('id_category'); const categoryEl = document.getElementById('id_category');
const statusEl = document.getElementById('id_status'); const statusEl = document.getElementById('id_status');
const createCat = document.getElementById('create-category'); const createCat = document.getElementById('create-category');
const createStatus = document.getElementById('create-status'); const createStatus = document.getElementById('create-status');
if (categoryEl) createCat.value = categoryEl.value || ''; if (categoryEl) createCat.value = categoryEl.value || '';
if (statusEl) createStatus.value = statusEl.value || ''; if (statusEl) createStatus.value = statusEl.value || '';
document.getElementById('create-exam-form').submit(); document.getElementById('create-exam-form').submit();
}); });
})(); })();
</script> </script>
{% endblock %} {% endblock %}