Add exam generation functionality with customizable name and filters
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="sbasQuestionsDropdown">
|
||||
<li><a class="dropdown-item" href="{% url 'sbas:question_view' %}"><i class="bi bi-list-ul"></i> All Questions</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'sbas:question_review_start' %}"><i class="bi bi-bookmarks-fill"></i> Review Questions</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'sbas:generate_exam' %}"><i class="bi bi-journal-plus"></i> Generate Exam</a></li>
|
||||
<!-- Additional items can be added here -->
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
{% extends 'sbas/base.html' %}
|
||||
|
||||
{% block title %}Generate Exam{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-3">
|
||||
<h2>Generate Personal SBA Exam</h2>
|
||||
<p>Choose filters and provide a name for your exam. The created exam will be active and available for you to take.</p>
|
||||
|
||||
<form method="post" action="{% url 'sbas:exam_create_from_filters_with_name' %}">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3">
|
||||
<label for="exam-name" class="form-label">Exam name</label>
|
||||
<input type="text" class="form-control" id="exam-name" name="name" placeholder="My personal SBA exam">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="id_category" class="form-label">Category</label>
|
||||
<select id="id_category" name="category" class="form-select">
|
||||
<option value="">Any</option>
|
||||
{% for c in categories %}
|
||||
<option value="{{ c.id }}">{{ c.category }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<p class="small text-muted">Only questions with an "Accepted" review will be used to build the exam.</p>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="create-count" class="form-label">Number of questions (0 = all)</label>
|
||||
<input type="number" id="create-count" name="count" class="form-control" value="0" min="0">
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" value="on" id="exclude-answered" name="exclude_answered">
|
||||
<label class="form-check-label" for="exclude-answered">
|
||||
Exclude questions I have already answered in other exams
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Generate Exam</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -59,37 +59,6 @@
|
||||
})();
|
||||
</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