This commit is contained in:
Ross
2021-12-15 19:17:40 +00:00
parent 64249e8d9f
commit 2ee5472ef2
3 changed files with 49 additions and 14 deletions
+17 -13
View File
@@ -1,21 +1,25 @@
{% extends 'base.html' %}
{% block title %}
Anatomy
Anatomy
{% endblock %}
{% block navigation %}
Anatomy:
{% if request.user.is_authenticated %}
<a href="{% url 'anatomy:index' %}">Packets</a> /
<a href="{% url 'anatomy:exam_list' %}">Exams</a> /
<a href="{% url 'anatomy:exam_create' %}" title="Create a new exam">Create Exam</a> /
<a href="{% url 'anatomy:question_list' %}">Questions</a> /
<a href="{% url 'anatomy:anatomy_question_create' %}" title="Create a new question">Create Question</a>
{% if request.user.is_superuser %}
/ <a href="{% url 'anatomy:user_answer_table_view' %}" title="User answers">Answers</a>
{% endif %}
{% endif %}
Anatomy:
{% if request.user.is_authenticated %}
<a href="{% url 'anatomy:index' %}">Packets</a> /
<a href="{% url 'anatomy:exam_list' %}">Exams</a> /
<a href="{% url 'anatomy:exam_create' %}" title="Create a new exam">Create Exam</a> /
<a href="{% url 'anatomy:question_list' %}">Questions</a> /
<a href="{% url 'anatomy:anatomy_question_create' %}" title="Create a new question">Create Question</a>
{% if request.user.is_superuser %}
/ <a href="{% url 'anatomy:user_answer_table_view' %}" title="User answers">Answers</a>
{% endif %}
{% endif %}
{% endblock %}
{% block content %}
{% endblock %}
{% if simple_content %}
{{simple_content}}
{% endif %}
{% endblock %}
+8 -1
View File
@@ -78,9 +78,16 @@ urlpatterns = [
),
path(
"exam/<int:pk>/scores",
cache_page(60 * 1)(views.exam_scores_cid),
views.exam_scores_cid,
# cache_page(60 * 1)(views.exam_scores_cid),
name="exam_scores_cid",
),
path(
"exam/<int:pk>/scores/refresh",
views.exam_scores_refresh,
# cache_page(60 * 1)(views.exam_scores_cid),
name="exam_scores_refresh",
),
path(
"exam/<int:pk>/scores/<int:sk>/<str:passcode>/",
views.exam_scores_cid_user,
+24
View File
@@ -450,6 +450,30 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
},
)
@login_required
def exam_scores_refresh(request, pk):
exam = get_object_or_404(Exam, pk=pk)
if not exam.exam_mode:
raise Http404("Packet not in exam mode")
questions = exam.exam_questions.all()
cids = (
CidUserAnswer.objects.filter(question__in=questions, exam__id=pk)
)
# Force a score update
for c in cids:
c.get_answer_score(cached=False)
return render(
request,
"anatomy/base.html",
{
"simple_content": "Answer scores updated",
},
)
@login_required
def exam_scores_cid(request, pk):