Add functionality to create personal exams from filtered questions and update exam overview with edit option
This commit is contained in:
@@ -12,6 +12,21 @@
|
||||
{% include "exam_clock.html" %}
|
||||
<h2>Exam: {{exam}}</h2>
|
||||
|
||||
{% if can_edit %}
|
||||
<div class="card mb-3">
|
||||
<div class="card-body d-flex flex-column flex-md-row justify-content-between align-items-start align-items-md-center">
|
||||
<div class="mb-2 mb-md-0">
|
||||
{% include "generic/partials/exams/exam_status.html#publish-results" %}
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'sbas:exam_update' pk=exam.id %}" class="btn btn-outline-primary btn-sm">
|
||||
Edit exam
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if exam.publish_results %}
|
||||
<div class="alert alert-primary review-mode-alert" role="alert">
|
||||
Exam is in review mode. Score are available
|
||||
|
||||
@@ -59,4 +59,37 @@
|
||||
})();
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="mt-3">
|
||||
<h5>Create your personal exam</h5>
|
||||
<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' %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="category" id="create-category" />
|
||||
<input type="hidden" name="status" id="create-status" />
|
||||
<div class="mb-2">
|
||||
<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" />
|
||||
</div>
|
||||
<button id="create-exam-btn" type="button" class="btn btn-success">Create my exam</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
const createBtn = document.getElementById('create-exam-btn');
|
||||
createBtn.addEventListener('click', function(){
|
||||
const categoryEl = document.getElementById('id_category');
|
||||
const statusEl = document.getElementById('id_status');
|
||||
const createCat = document.getElementById('create-category');
|
||||
const createStatus = document.getElementById('create-status');
|
||||
if (categoryEl) createCat.value = categoryEl.value || '';
|
||||
if (statusEl) createStatus.value = statusEl.value || '';
|
||||
document.getElementById('create-exam-form').submit();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user