Merge ssh://penracourses.org.uk:/home/django/rad

This commit is contained in:
Ross
2021-08-17 18:13:55 +01:00
39 changed files with 651 additions and 158 deletions
+3
View File
@@ -23,6 +23,9 @@ Longs:
<a href="{% url 'longs:long_create' %}" title="Create a new long case">Create Case</a> /
<a href="{% url 'longs:long_series_create' %}" title="Create a new image series">Create Series</a>
{% endif %}
{% if request.user.is_superuser %}
/ <a href="{% url 'longs:user_answer_table_view' %}" title="User answers">Answers</a>
{% endif %}
{% comment %} </br>
Questions by:
<span id="authors-link"><a href="{% url 'longs:author_list' %}">author</a></span> {% endcomment %}
+12
View File
@@ -0,0 +1,12 @@
{% extends "longs/base.html" %}
{% block content %}
<h2>Add Exam</h2>
<form action="" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Submit">
</form>
{% endblock %}
+4 -4
View File
@@ -4,22 +4,22 @@
<h1>Examinations</h1>
<div class="longs">
Active exams:<br/>
<ul>
<ul class="exam-list">
{% for exam in exams %}
{% if exam.active %}
<li>
<a href="{% url 'longs:exam_overview' pk=exam.pk %}">{{exam.name}}</a> <a href="{% url 'longs:mark_overview' pk=exam.pk %}">(mark)</a> <a href="{% url 'longs:exam_scores_cid' pk=exam.pk %}">(scores)</a> [Results are {% if not exam.publish_results %} not {% endif %}published]
<a href="{% url 'longs:exam_overview' pk=exam.pk %}" class="flex-col">{{exam.name}}</a> <a href="{% url 'longs:mark_overview' pk=exam.pk %}" class="flex-col">Mark</a><a href="{% url 'longs:exam_scores_cid' pk=exam.pk %}" class="flex-col">Scores</a> <span class="flex-col icon-container"><span class="published-icon {% if exam.publish_results %}published{% endif %}">Results Published</span></span>
</li>
{% endif %}
{% endfor %}
</ul>
Inactive exams:<br/>
<ul>
<ul class="exam-list">
{% for exam in exams %}
{% if not exam.active %}
<li>
<a href="{% url 'longs:exam_overview' pk=exam.pk %}">{{exam.name}}</a> <a href="{% url 'longs:mark_overview' pk=exam.pk %}">(mark)</a> <a href="{% url 'longs:exam_scores_cid' pk=exam.pk %}">(scores)</a> [Results are {% if not exam.publish_results %} not {% endif %}published]
<a href="{% url 'longs:exam_overview' pk=exam.pk %}" class="flex-col">{{exam.name}}</a> <a href="{% url 'longs:mark_overview' pk=exam.pk %}" class="flex-col">Mark</a><a href="{% url 'longs:exam_scores_cid' pk=exam.pk %}" class="flex-col">Scores</a> <span class="flex-col icon-container"><span class="published-icon {% if exam.publish_results %}published{% endif %}">Results Published</span></span>
</li>
{% endif %}
{% endfor %}
+2
View File
@@ -4,6 +4,8 @@
{% load thumbnail %}
<div class="longs">
<a href="{% url 'longs:exam_update' exam.id %}" title="Edit the Exam">Edit</a>
<a href="{% url 'longs:exam_delete' exam.id %}" title="Delete the Exam">Delete</a>
<a href="{% url 'admin:longs_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin Edit</a>
<h1>Exam: {{ exam.name }}</h1>
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.<br />
-35
View File
@@ -13,44 +13,9 @@
<input class="btn btn-primary btn-sm mt-1 mb-1" type="submit" />
</form>
</div>
<button id="delete-all-button">Delete all</button>
{% render_table table %}
{% endblock %}
{% block js %}
<script>
$(document).ready(function () {
//$("thead input:checked").each((n, el) => {
answer_ids = [];
$("tbody input:checked").each((n, el) => {
answer_ids.push(el.value);
})
$("#delete-all-button").on("click", function () {
$.ajax({
url: "{% url 'longs:user_answer_delete_multiple' %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
answer_ids: JSON.stringify(answer_ids) // true if checked else false
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Deleted.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
})
});
</script>
{% endblock %}
@@ -0,0 +1,61 @@
{% extends 'longs/base.html' %}
{% load render_table from django_tables2 %}
{% block css %}
{% endblock %}
{% block content %}
<div id="view-filter-options">
<h3>Filter User Answers</h3>
<form action="" method="get">
{{ filter.form }}
<input class="btn btn-primary btn-sm mt-1 mb-1" type="submit" />
</form>
</div>
{% render_table table %}
<button id="delete-selected-button">Delete selected answers</button>
{% endblock %}
{% block js %}
<script>
$(document).ready(function () {
$("table thead th input").click((e) => {
let status = e.currentTarget.checked; console.log(status, $("table tbody input")); $("table tbody input").prop("checked", status);
})
//$("thead input:checked").each((n, el) => {
$("#delete-selected-button").on("click", function () {
answer_ids = [];
$("tbody input:checked").each((n, el) => {
answer_ids.push(el.value);
})
if (confirm(`Delete ${answer_ids.length} answers?`)) {
$.ajax({
url: "{% url 'longs:user_answer_delete_multiple' %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
answer_ids: JSON.stringify(answer_ids) // true if checked else false
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Deleted.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
}
})
});
</script>
{% endblock %}