.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
CID: {{cid}}
|
||||
|
||||
<h2>Collection: {{collection.name}}</h2>
|
||||
|
||||
<div><p>Questions</p></div>
|
||||
{{answer_count}} out of {{collection_length}} questions answered. Click to go to question.
|
||||
<div class="sba-finish-list">
|
||||
{% for question, answer in question_answer_tuples %}
|
||||
<a href="{% url 'atlas:collection_take' pk=collection.id case_number=forloop.counter0 cid=cid passcode=passcode %}"><button {% if not answer %}class="unanswered"{% endif %}>{{forloop.counter}}: {{answer.answer}}</button></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
Start time: {{cid_user_collection.start_time}}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
+1
-1
@@ -18,7 +18,7 @@ urlpatterns = [
|
||||
path("collection/<int:pk>/delete", views.CaseCollectionDelete.as_view(), name="collection_delete"),
|
||||
path("collection/<int:pk>/update", views.CaseCollectionUpdate.as_view(), name="collection_update"),
|
||||
path("collection/<int:pk>", views.collection_detail_view, name="collection_detail_view"),
|
||||
#path("collection/<int:pk>/take/<int:cid>/<str:passcode>", views.collection_detail_view_take, name="collection_detail_view_take"),
|
||||
path("collection/<int:pk>/take/<int:cid>/<str:passcode>", views.collection_take_overview, name="collection_take_overview"),
|
||||
path("collection/<int:pk>/<int:case_number>", views.collection_case_view, name="collection_case_view"),
|
||||
path("collection/<int:pk>/<int:case_number>/take/<int:cid>/<str:passcode>", views.collection_case_view_take, name="collection_case_view_take"),
|
||||
path("condition/", views.ConditionView.as_view(), name="condition_view"),
|
||||
|
||||
+44
-6
@@ -47,6 +47,7 @@ from .models import (
|
||||
Case,
|
||||
CaseCollection,
|
||||
CaseDetail,
|
||||
CidReportAnswer,
|
||||
Condition,
|
||||
PathologicalProcess,
|
||||
Presentation,
|
||||
@@ -1055,12 +1056,49 @@ def collection_detail_view(request, pk):
|
||||
request, "atlas/collection_detail_view.html", {"collection": collection}
|
||||
)
|
||||
|
||||
#def collection_detail_view_take(request, pk, cid, passcode):
|
||||
# collection = get_object_or_404(CaseCollection, pk=pk)
|
||||
#
|
||||
# return render(
|
||||
# request, "atlas/collection_detail_view.html", {"collection": collection}
|
||||
# )
|
||||
def collection_take_overview(request, pk, cid, passcode):
|
||||
collection = get_object_or_404(CaseCollection, pk=pk)
|
||||
|
||||
if not collection.active:
|
||||
raise Http404("Exam not found")
|
||||
|
||||
if not collection.check_cid_user(cid, passcode):
|
||||
raise Http404("Error accessing exam")
|
||||
|
||||
cases = collection.cases.all().order_by("casedetail__sort_order").prefetch_related()
|
||||
|
||||
case_details = CaseDetail.objects.get(case__in=cases, collection=collection)
|
||||
answers = CidReportAnswer.objects.filter(cid=cid, question__in=case_details)
|
||||
|
||||
answer_question_map = {}
|
||||
for ans in answers:
|
||||
answer_question_map[ans.question] = ans
|
||||
|
||||
question_answer_tuples = []
|
||||
answer_count = 0
|
||||
for q in cases:
|
||||
if q in answer_question_map and answer_question_map[q].answer:
|
||||
question_answer_tuples.append((q, answer_question_map[q]))
|
||||
answer_count += 1
|
||||
else:
|
||||
question_answer_tuples.append((q, None))
|
||||
|
||||
c = CidUser.objects.filter(cid=cid).first()
|
||||
cid_user_exam = collection.get_or_create_cid_user_exam(cid_user=c)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"sbas/exam_take_overview.html",
|
||||
{
|
||||
"collection": collection,
|
||||
"cid": cid,
|
||||
"question_answer_tuples": question_answer_tuples,
|
||||
"answer_count": answer_count,
|
||||
"collection_length": len(cases),
|
||||
"passcode": passcode,
|
||||
"cid_user_exam": cid_user_exam,
|
||||
},
|
||||
)
|
||||
|
||||
def collection_case_view_take(request, pk, case_number, cid, passcode):
|
||||
return collection_case_view(request, pk, case_number, True, cid, passcode)
|
||||
|
||||
Reference in New Issue
Block a user