forked from muyrety/Smarter
131 lines
5.9 KiB
Django/Jinja
131 lines
5.9 KiB
Django/Jinja
{% extends "browsing.j2" %}
|
|
|
|
{% block title %} Select questions {% endblock %}
|
|
|
|
{% block head %}
|
|
<script src="{{ url_for('static', filename='js/user_browse.js') }}"></script>
|
|
{% endblock %}
|
|
|
|
{% block after_bootstrap_js %}
|
|
<script type="module" src="{{ url_for('static', filename='js/select_user_questions.js') }}"></script>
|
|
{% endblock %}
|
|
|
|
{% block header %}
|
|
<div id="serverErrorModal" class="modal fade" tabindex="-1">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content bg-info-subtle text-success border-success-subtle">
|
|
<div class="modal-header border-success-subtle">
|
|
<h5 class="modal-title">Server error</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>There has been an error while contacting the server, try again later</p>
|
|
</div>
|
|
<div class="modal-footer justify-content-center border-success-subtle">
|
|
<button type="button" class="btn btn-outline-success" data-bs-dismiss="modal">OK</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-5">
|
|
<div id="notEnoughQuestions" class="d-none mt-3 alert bg-info-subtle border-success-subtle alert-dismissible">
|
|
<p class="text-success"> All question sets must have at least 5 questions </p>
|
|
<button type="button" class="btn-close" id="notEnoughQuestionsDismiss"></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-5">
|
|
<div id="tooManyQuestions" class="d-none mt-3 alert bg-info-subtle border-success-subtle alert-dismissible">
|
|
<p class="text-success"> All question sets must have no more than 50 questions </p>
|
|
<button type="button" class="btn-close" id="tooManyQuestionsDismiss"></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-center mt-3">
|
|
<button class="btn btn-primary" id="submitSet">Submit question set</button>
|
|
</div>
|
|
|
|
|
|
<div class="row justify-content-center mt-3">
|
|
<div id="otdblink" class="col-lg-4 col-md-5 m-2 text-center">
|
|
<a href="{{ url_for('question_sets.add_opentdb') }}" class="btn btn-primary">Open Trivia DB questions</a>
|
|
<a href="{{ url_for('about.opentdb') }}" class="link-offset-2 text-primary-emphasis ms-1">?</a>
|
|
</div>
|
|
<div class="col-lg-4 col-md-5 m-2 text-center">
|
|
<button class="btn btn-outline-primary" disabled>User-created questions</button>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class="border-primary">
|
|
|
|
<form id="IDSubmitionForm">
|
|
<div class="row justify-content-center">
|
|
<div class="col-auto">
|
|
<div class="alert bg-info-subtle border-success-subtle alert-dismissible d-none" id="serverFailAlert">
|
|
<p class="text-success"> Could not connect to the server, try again </p>
|
|
<button type="button" class="btn-close" id="serverFailAlertDismiss"></button>
|
|
</div>
|
|
<div class="alert bg-info-subtle border-success-subtle alert-dismissible d-none" id="questionChosenAlert">
|
|
<p class="text-success"> This question has already been added </p>
|
|
<button type="button" class="btn-close" id="questionChosenAlertDismiss"></button>
|
|
</div>
|
|
<div class="alert bg-info-subtle border-success-subtle alert-dismissible d-none" id="questionNotValidAlert">
|
|
<p class="text-success"> This question ID is not valid </p>
|
|
<button type="button" class="btn-close" id="questionNotValidAlertDismiss"></button>
|
|
</div>
|
|
<div class="alert bg-info-subtle border-success-subtle alert-dismissible d-none" id="successAlert">
|
|
<p class="text-success"> Question successfully added </p>
|
|
<button type="button" class="btn-close" id="successAlertDismiss"></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row justify-content-center text-center mt-3">
|
|
<div class="col-auto m-2">
|
|
<input name="id" type="number" class="form-control bg-info-subtle border-success-subtle text-success">
|
|
</div>
|
|
<div class="col-auto m-2">
|
|
<button type="submit" class="btn btn-outline-primary">Select by ID</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<hr class="border-primary">
|
|
{% endblock %}
|
|
|
|
{% block table %}
|
|
<table class="table table-info border-primary-subtle mt-3">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col" class="text-primary-emphasis">ID</th>
|
|
<th scope="col" class="text-primary-emphasis">Category</th>
|
|
<th scope="col" class="text-primary-emphasis">Difficulty</th>
|
|
<th scope="col" class="text-primary-emphasis">Question</th>
|
|
<th scope="col" class="text-primary-emphasis">Created by</th>
|
|
<th scope="col" class="invisible text-primary-emphasis">Select</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="questionTableBody">
|
|
{% for question in questions %}
|
|
<tr>
|
|
<th scope="row" class="text-primary-emphasis">{{ question["id"] }}</th>
|
|
<td class="text-primary-emphasis">{{ question["category"] }}</td>
|
|
<td class="text-primary-emphasis">{{ question["difficulty"] }}</td>
|
|
<td class="text-primary-emphasis">{{ question["question"] }}</td>
|
|
<td class="text-primary-emphasis">{{ question["creator"] }}</td>
|
|
<td>
|
|
<form class="selectQuestion">
|
|
<input name="id" type="hidden" value="{{ question["id"] }}">
|
|
<button name="submitButton" class="btn btn-outline-success" type="submit">Select</button>
|
|
<button name="removeButton" class="btn btn-outline-danger d-none" disabled type="submit">Remove</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
<p class="text-center text-primary-emphasis">You have reached the end</p>
|
|
{% endblock %}
|