improve user score pages
This commit is contained in:
@@ -280,4 +280,24 @@ img.uploading:hover {
|
||||
|
||||
#annotation-json-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.user-answer-score-0 {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.user-answer-score-1 {
|
||||
color: greenyellow;
|
||||
}
|
||||
|
||||
.user-answer-score-2 {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.correct-answer {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.user-answer-li {
|
||||
padding-top: 10px;
|
||||
}
|
||||
@@ -39,9 +39,11 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="content container">
|
||||
{% if request.user.is_authenticated %}
|
||||
<a href="{% url 'anatomy:exam_list' %}">Exams</a> /
|
||||
<a href="{% url 'anatomy:anatomy_question_view' %}">Questions</a> /
|
||||
<a href="{% url 'anatomy:anatomy_question_create' %}" title="Create a new question">Create Question</a>
|
||||
{% endif %}
|
||||
{% block navigation %}
|
||||
{% endblock %}
|
||||
<div class="row">
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{% extends 'anatomy/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="anatomy">
|
||||
<h2>Please enter your CID</h2>
|
||||
<p>CID: <input type="text" name="cid" id="cid-input"></p>
|
||||
<button id="cid-selector-go-button">Go...</button>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#cid-selector-go-button").click(() => {
|
||||
cid = document.getElementById("cid-input").value;
|
||||
window.location = window.location + cid;
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -4,12 +4,15 @@
|
||||
<div class="anatomy">
|
||||
<h2>Exam: {{ exam.name }}</h2>
|
||||
<h3>Candidate: {{ cid }}</h3>
|
||||
Answers:
|
||||
Answers:
|
||||
<ul>{% for ans, score, correct_answer in answers_and_marks %}
|
||||
<li>Question {{forloop.counter}}: {{ correct_answer }}</li>
|
||||
{{ans}} ({{score}}),
|
||||
{% endfor %}
|
||||
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span class="correct-answer">{{ correct_answer }}</span></li>
|
||||
<span class="user-answer-score-{{score}}">{{ans}} ({{score}})</span>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<br /> Total mark: {{ total_score }}
|
||||
<br /> Total mark: {{ total_score }} / {{max_score}}
|
||||
<div>
|
||||
<a href="{% url 'anatomy:cid_scores' cid %}">Other exams</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
+2
-1
@@ -28,7 +28,8 @@ urlpatterns = [
|
||||
path("exam/json/", views.active_exams, name="active_exams"),
|
||||
path("exam/json/<int:pk>", views.exam_json, name="exam_json"),
|
||||
path("exam/json/<int:pk>/recreate", views.exam_json_recreate, name="exam_json_recreate"),
|
||||
path("cid/<int:pk>/scores", views.cid_scores, name="cid_scores"),
|
||||
path("cid/<int:pk>", views.cid_scores, name="cid_scores"),
|
||||
path("cid/", views.cid_selector, name="cid_selector"),
|
||||
path("ajax/exam/flag/", views.flag_question, name="flag_question"),
|
||||
path("body_part/create/", views.create_body_part, name="create_body_part"),
|
||||
path("body_part/ajax/get_body_part_id",
|
||||
|
||||
+13
-6
@@ -656,11 +656,12 @@ def exam_scores_cid_user(request, pk, sk):
|
||||
# skip if no answer
|
||||
answers_marks.append(0)
|
||||
answers.append("")
|
||||
continue
|
||||
answer_score = 0
|
||||
ans = "Not answered"
|
||||
else:
|
||||
ans = user_answer.answer
|
||||
|
||||
ans = user_answer.answer
|
||||
|
||||
answer_score = user_answer.get_answer_score()
|
||||
answer_score = user_answer.get_answer_score()
|
||||
|
||||
correct_answer = q.GetPrimaryAnswer()
|
||||
answers.append(ans)
|
||||
@@ -669,7 +670,7 @@ def exam_scores_cid_user(request, pk, sk):
|
||||
|
||||
total_score = sum(answers_marks)
|
||||
|
||||
total = len(questions)
|
||||
max_score = len(questions) * 2
|
||||
|
||||
return render(
|
||||
request,
|
||||
@@ -681,10 +682,16 @@ def exam_scores_cid_user(request, pk, sk):
|
||||
"answers": answers,
|
||||
"answers_marks": answers_marks,
|
||||
"total_score": total_score,
|
||||
"max_score": max_score,
|
||||
"answers_and_marks": answers_and_marks,
|
||||
},
|
||||
)
|
||||
|
||||
def cid_selector(request):
|
||||
return render(
|
||||
request,
|
||||
"anatomy/cid_selector.html",
|
||||
)
|
||||
|
||||
@login_required
|
||||
def exam_scores(request, pk):
|
||||
@@ -748,7 +755,7 @@ def cid_scores(request, pk):
|
||||
|
||||
|
||||
if not answers:
|
||||
return Http404("cid not found")
|
||||
raise Http404("cid not found")
|
||||
|
||||
exam_ids = answers.values_list("exam").distinct()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user