This commit is contained in:
Ross
2021-07-28 19:51:28 +01:00
parent b1e450aeee
commit 147ea612d0
9 changed files with 294 additions and 0 deletions
@@ -0,0 +1,19 @@
{% extends 'sbas/base.html' %}
{% block content %}
<h1>Examinations</h1>
<div class="sbas">
Active exams:<br/>
<ul>
{% for exam in exams %}
{% if exam.active %}
<li>
<a href="{% url 'sbas:exam_take' pk=exam.pk %}">{{exam.name}}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endblock %}
+14
View File
@@ -0,0 +1,14 @@
{% extends 'base.html' %}
{% block title %}
Sbas
{% endblock %}
{% block navigation %}
Sbas:
{% if request.user.is_authenticated %}
<a href="{% url 'sbas:exam_list' %}">Exams</a> /
{% endif %}
{% endblock %}
{% block content %}
{% endblock %}
+34
View File
@@ -0,0 +1,34 @@
{% extends 'sbas/base.html' %}
{% block content %}
<h1>Examinations</h1>
<div class="sbas">
Active exams:<br/>
<ul>
{% for exam in exams %}
{% if exam.active %}
<li>
<a href="{% url 'sbas:exam_overview' pk=exam.pk %}">{{exam.name}}</a> <a href="{% url 'sbas:exam_scores_cid' pk=exam.pk %}">(scores)</a>
</li>
{% endif %}
{% endfor %}
</ul>
Inactive exams:<br/>
<ul>
{% for exam in exams %}
{% if not exam.active %}
<li>
<a href="{% url 'sbas:exam_overview' pk=exam.pk %}">{{exam.name}}</a> <a href="{% url 'sbas:exam_scores_cid' pk=exam.pk %}">(scores)</a>
</li>
{% endif %}
{% endfor %}
</ul>
<p>Active exams will be available to take at the below url:
<a href="{% url 'sbas:active_exams' %}">Available exams</a>
</p>
</div>
{% endblock %}
+103
View File
@@ -0,0 +1,103 @@
{% extends 'sbas/exams.html' %}
{% block content %}
{% load thumbnail %}
<div class="sbas">
<h1>Exam: {{ exam.name }}</h1>
This exam has {{question_number}} questions.
<div class="parent-help" title="Click to enable / disable the exam">
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}> <span class="help-text">[When checked the exam will be available to take in the test system]</span>
</div>
<div class="parent-help" title="Click to enable / disable the exam results">
Publish results: <input type="checkbox" id="exam-publish-results-switch" {% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will be available on this site]</span>
</div>
<!--<p><button><a href="{% url 'anatomy:exam_take' pk=exam.pk sk=0 %}">Click here to start</a></button></p>-->
This exam will be available to take <a href="{% url 'sbas:exam_take' pk=exam.pk %}">here</a> (when active).
{% autoescape off %}
<ol id="full-question-list">
{% for question in questions.all %}
<li>
{{ question.stem }}
<ol type="a" class="abcde">
<li>
{{ question.a }}: {{ question.a_answer }}
</li>
<li>
{{ question.b }}: {{ question.b_answer }}
</li>
<li>
{{ question.c }}: {{ question.c_answer }}
</li>
<li>
{{ question.d }}: {{ question.d_answer }}
</li>
<li>
{{ question.e }}: {{ question.e_answer }}
</li>
</ol>
Category: {{ question.category }}, <a href="{% url 'sbas:question_detail' pk=question.pk %}">View</a> <a href="{% url 'admin:sbas_question_change' question.id %}">Edit</a>
</li>
{% endfor %}
</ol>
{% endautoescape %}
</div>
<script type="text/javascript">
$(document).ready(function () {
// send request to change the is_private state on customSwitches toggle
$("#exam-active-switch").on("change", function () {
$.ajax({
url: "{% url 'sbas:exam_toggle_active' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
active: this.checked // 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('Exam state changed.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
})
$("#exam-publish-results-switch").on("change", function () {
$.ajax({
url: "{% url 'sbas:exam_toggle_results_published' pk=exam.pk %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
publish_results: this.checked // 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('Publish results state changed.')
}
// 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 %}
+65
View File
@@ -0,0 +1,65 @@
{% extends 'sbas/exams.html' %}
{% block content %}
<div class="sbas">
<h2>{{ exam.name }}</h2>
</div>
<div id="stats-block">
<h2>Stats</h2>
Candidates: {{cids|length}}<br />
Max score: {{max_score}}<br />
Mean: {{mean}}, Median {{median}}, Mode {{mode}}
<div id="stats-plot">
<h3>Distribution of results</h3>{{plot|safe}}
</div>
</div>
<div>
<table>
<tr>
<th>Candidate ID</th>
<th>Score</th>
</tr>
{% for user, value in user_answers_marks.items %}
<tr>
<td><a href="{% url 'cid_scores' user %}">{{user}}</a></td>
<td>{{user_scores|get_item:user}}</td>
</tr>
{% endfor %}
</table>
</div>
<div>
<h3>Answers as a table</h3>
<table>
<tr>
<th>Candidate</th>
{% for cid in cids %}
<th>{{cid}}</th>
{% endfor %}
</tr>
{% for question in questions %}
<tr>
<td>Question {{forloop.counter}}</td>
{% for zipped_answers in by_question|get_item:question %}
<td>
<ol class="sbas-ans" style="list-style-type: lower-alpha;">
{% for ans, score in zipped_answers %}
<li class="user-answer-score-{{score}}" title="answer score: {{score}}">{{ans}}</li>
{% endfor %}
</ol>
</td>
{% endfor %}
</tr>
{% endfor %}
<tr>
<td>Score:</td>
{% for score in user_scores_list %}
<td>{{score}}</td>
{% endfor %}
<tr>
</table>
</div>
{% endblock %}
+23
View File
@@ -0,0 +1,23 @@
{% extends 'sbas/base.html' %}
{% block content %}
<div class="sbas">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Answers:
<ul>
{% for question, ans in answers_and_marks %}
<li class="user-answer-li">Question {{forloop.counter}} - {{ question.stem }}</li>
<ol type="a">
{% for q, a, score, correct_answer in ans %}
<li>{{q}}: Correct answer: {{correct_answer}} <br />{{a}} <span class="answer-{{score}}">(Score: {{score}})</span></li>
{% endfor %}
</ol>
{% endfor %}
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<div>
<a href="{% url 'cid_scores' cid %}">Other exams</a>
</div>
</div>
{% endblock %}
+6
View File
@@ -0,0 +1,6 @@
{% extends 'sbas/base.html' %}
{% block navigation %}
<br/>
Exams: {{exam.name}}-> <a href="{% url 'sbas:exam_overview' pk=exam.pk %}">Overview</a> / <a href="{% url 'sbas:exam_scores_cid' pk=exam.pk %}">Scores</a>
{% endblock %}
+10
View File
@@ -0,0 +1,10 @@
{% extends 'sbas/base.html' %}
{% block content %}
{% for exam in exams %}
<div class="sbas">
<h1><a href="{% url 'sbas:exam_overview' pk=exam.pk %}">Exam: {{ exam.name }} </a></h1>
{% if request.user.is_staff %}<a href="{% url 'sbas:exam_scores_cid' pk=exam.pk %}">Scores</a>{% endif %}
</div>
{% endfor %}
{% endblock %}
+20
View File
@@ -0,0 +1,20 @@
{% extends 'anatomy/base.html' %}
{% block content %}
{% for question in questions %}
<div class="anatomy">
<div class="date">
{{ question.created_date }}
</div>
<h1><a href="{% url 'anatomy:question_detail' pk=question.pk %}">{% for answer in question.answers.all %}
{{ answer }},
{% endfor %}
</a></h1>
<p>{{ question.question_type.first|linebreaksbr }}</p>
<img src="/media/anatomy/{{ question.image|linebreaksbr }}" />
<a href="{% url 'anatomy:answer_question' pk=question.pk %}">ANSWER</a>
</div>
{% endfor %}
{% endblock %}
{$ black navigation %}