.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
CID: {{cid}}
|
||||
|
||||
<h2>Exam: {{exam.name}}</h2>
|
||||
|
||||
<div><p>Questions</p></div>
|
||||
<ul class="question-list">
|
||||
{% for question, answer in question_answer_tuples %}
|
||||
<li class="">{{forloop.counter}}: answer.answer</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block css %}
|
||||
<style type="text/css">
|
||||
.form-contents { display: none; }
|
||||
.selected { border: 1px solid purple; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -31,6 +31,8 @@ CID: {{cid}}
|
||||
{% else %}
|
||||
<button type="submit" name="save" class="save btn btn-default">Save</button>
|
||||
{% endif %}
|
||||
<br />
|
||||
<button type="submit" name="finish" class="save btn btn-default">Finish</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ urlpatterns = [
|
||||
#path("exam/<int:pk>/mark", views.mark_overview, name="mark_overview"),
|
||||
path("exam/<int:pk>/<int:sk>/<str:cid>/take", views.exam_take, name="exam_take"),
|
||||
path("exam/<int:pk>/start", views.exam_start, name="exam_start"),
|
||||
path("exam/<int:pk>/<str:cid>/finish", views.exam_finish, name="exam_finish"),
|
||||
path("exam/<int:pk>/", views.SbasExamViews.exam_overview, name="exam_overview"),
|
||||
path("exam/<int:pk>/scores", views.exam_scores_cid,
|
||||
name="exam_scores_cid"),
|
||||
|
||||
@@ -236,6 +236,37 @@ def exam_start(request, pk):
|
||||
},
|
||||
)
|
||||
|
||||
def exam_finish(request, pk, cid):
|
||||
exam = get_object_or_404(Exam, pk=pk)
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
|
||||
answers = CidUserAnswer.object.filter(
|
||||
cid=cid, exam=exam)
|
||||
|
||||
answer_question_map = {}
|
||||
for ans in answers:
|
||||
answer_question_map[ans.question] = ans
|
||||
|
||||
question_answer_tuples = []
|
||||
for q in questions:
|
||||
if q in answer_question_map:
|
||||
question_answer_tuples.append(q, answer_question_map[q])
|
||||
else:
|
||||
question_answer_tuples.append(q, None)
|
||||
|
||||
if not exam.active:
|
||||
raise Http404("Exam not found")
|
||||
|
||||
return render(
|
||||
request,
|
||||
"sbas/exam_finish.html",
|
||||
{
|
||||
"exam": exam,
|
||||
"question_answer_tuples": question_answer_tuples
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def exam_take(request, pk, sk, cid):
|
||||
|
||||
@@ -269,6 +300,8 @@ def exam_take(request, pk, sk, cid):
|
||||
return redirect("sbas:exam_take", pk=pk, sk=pos, cid=cid)
|
||||
elif "previous" in request.POST:
|
||||
return redirect("sbas:exam_take", pk=pk, sk=pos - 2, cid=cid)
|
||||
elif "finish" in request.POST:
|
||||
return redirect("sbas:exam_finish", pk=pk, cid=cid)
|
||||
else:
|
||||
form = CidUserAnswerForm(instance=answer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user