fix physics scores

This commit is contained in:
Ross
2020-12-16 21:40:27 +00:00
parent 90f69c2c14
commit 2e91dff46f
5 changed files with 153 additions and 53 deletions
@@ -0,0 +1,23 @@
{% extends 'physics/base.html' %}
{% block content %}
<div class="physics">
<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}}: {{a}} <br />Correct answer: {{correct_answer}} <span class="answer-{{score}}">(Score: {{score}})</span></li>
{% endfor %}
</ol>
{% endfor %}
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<div>
<a href="{% url 'physics:cid_scores' cid %}">Other exams</a>
</div>
</div>
{% endblock %}
+60 -21
View File
@@ -21,32 +21,32 @@
<ol type="a" class="abcde">
<li>
<span class="question-text">{{ question.a }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question" id="{{question.pk}}-a-checkbox" data-q="{{question.pk}}" data-a="a">
<div class="slider round"></div>
type="checkbox" class="question a" id="{{question.pk}}-a-checkbox" data-q="{{question.pk}}" data-a="a">
<div class="slider round a"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.b }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question" id="{{question.pk}}-b-checkbox" data-q="{{question.pk}}" data-a="b">
<div class="slider round"></div>
type="checkbox" class="question b" id="{{question.pk}}-b-checkbox" data-q="{{question.pk}}" data-a="b">
<div class="slider round b"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.c }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question" id="{{question.pk}}-c-checkbox" data-q="{{question.pk}}" data-a="c">
<div class="slider round"></div>
type="checkbox" class="question c" id="{{question.pk}}-c-checkbox" data-q="{{question.pk}}" data-a="c">
<div class="slider round c"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.d }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question" id="{{question.pk}}-d-checkbox" data-q="{{question.pk}}" data-a="d">
<div class="slider round"></div>
type="checkbox" class="question d" id="{{question.pk}}-d-checkbox" data-q="{{question.pk}}" data-a="d">
<div class="slider round d"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.e }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question" id="{{question.pk}}-e-checkbox" data-q="{{question.pk}}" data-a="e">
<div class="slider round"></div>
type="checkbox" class="question e" id="{{question.pk}}-e-checkbox" data-q="{{question.pk}}" data-a="e">
<div class="slider round e"></div>
</label>
</li>
</ol>
@@ -108,14 +108,13 @@ function postAnswers(ans) {
$.post("{% url 'physics:exam_answers_submit' %}", JSON.stringify(ans)).done((data) => {
console.log(data);
if (data.success) {
if (data.question_count == window.number_of_questions) {
let ret = confirm(
`${data.question_count} answers sucessfully submitted. Click OK to finish the exam.`
window.answers_submitted = true;
`Answers sucessfully submitted. Click OK to finish the exam.`
);
if (ret) {
window.saveSession();
window.answers_submitted = true;
if (config.exam_results_url != "") {
let url = config.exam_results_url;
@@ -131,9 +130,6 @@ function postAnswers(ans) {
$("#options-panel").show();
} else {
}
} else {
alert(`Answers sucessfully submitted.`);
}
} else {
alert(`Error submitting answers: ${data.error}`);
}
@@ -152,6 +148,7 @@ function postAnswers(ans) {
height: 20px;
margin: 0px;
margin-bottom: -5px;
float: right;
}
.truefalse-switch input {
@@ -165,7 +162,7 @@ function postAnswers(ans) {
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 0, 0, 0.5);
background-color: rgba(0, 4, 255, 0.5);
-webkit-transition: .4s;
transition: .4s;
border-radius: 20px;
@@ -185,7 +182,7 @@ function postAnswers(ans) {
}
input:checked+.slider {
background-color: rgba(0, 255, 0, 0.5);
background-color: rgba(162, 0, 255, 0.5);
}
input:focus+.slider {
@@ -200,7 +197,6 @@ function postAnswers(ans) {
/*------ ADDED CSS ---------*/
.slider:after {
content: 'FALSE';
color: white;
display: block;
position: absolute;
@@ -211,12 +207,55 @@ function postAnswers(ans) {
font-family: Verdana, sans-serif;
}
input:checked+.slider:after {
content: 'TRUE';
.a.slider:after {
content: 'a) FALSE';
}
.b.slider:after {
content: 'b) FALSE';
}
.c.slider:after {
content: 'c) FALSE';
}
.d.slider:after {
content: 'd) FALSE';
}
.e.slider:after {
content: 'e) FALSE';
}
input:checked+.slider.a:after {
content: 'a )TRUE';
}
input:checked+.slider.b:after {
content: 'b )TRUE';
}
input:checked+.slider.c:after {
content: 'c )TRUE';
}
input:checked+.slider.d:after {
content: 'd )TRUE';
}
input:checked+.slider.e:after {
content: 'e )TRUE';
}
.question-text {
display: inline-block;
vertical-align: text-top;
clear: both;
width: 600px;
}
.abcde {
clear: both;
}
</style>
{% endblock %}