Implement exam selection feature with HTMX support in exam edit view and add exam selection fragment template
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form hx-post="{% url 'generic:generic_exam_json_edit' %}" hx-target="#action-result" hx-swap="innerHTML">
|
||||
<input type="hidden" name="type" value="{{ type }}" />
|
||||
<div class="mb-2">
|
||||
<label for="id_exam_id">Choose exam</label>
|
||||
<select name="exam_id" id="id_exam_id" class="form-select form-select-sm">
|
||||
{% for ex in exams %}
|
||||
<option value="{{ ex.pk }}">{{ ex.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label>Selected questions</label>
|
||||
<div class="selected-placeholder small text-muted">(will be taken from selected checkboxes)</div>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<button class="btn btn-primary btn-sm" type="submit" name="add_from_selection">Add selected</button>
|
||||
<button class="btn btn-secondary btn-sm" type="button" onclick="document.querySelector('#action-result').innerHTML='';">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -21,9 +21,9 @@
|
||||
</div>
|
||||
<div class="btn-group" role="group">
|
||||
<button id="button-select-add-exam" class="btn btn-outline-primary btn-sm"
|
||||
data-exam_json_edit_url="{% url 'generic:generic_exam_json_edit' %}"
|
||||
data-exam_list_url="{% url 'api-1:'|add:app_name|add:'_user_exams' %}"
|
||||
data-type={{app_name}} data-csrf="{{ csrf_token }}">Add to exam</button>
|
||||
hx-get="{% url 'generic:generic_exam_json_edit' %}?type={{ app_name }}"
|
||||
hx-target="#action-result"
|
||||
hx-swap="innerHTML">Add to exam</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user