diff --git a/anatomy/models.py b/anatomy/models.py
index 851ea330..65972c44 100644
--- a/anatomy/models.py
+++ b/anatomy/models.py
@@ -91,6 +91,9 @@ class AnatomyQuestion(models.Model):
null=True,
blank=True)
created_date = models.DateTimeField(default=timezone.now)
+
+ open_access = models.BooleanField(help_text="If an question should be freely available to browse",
+ default=True)
def __str__(self):
# Get first answer
@@ -195,9 +198,6 @@ class Exam(models.Model):
active = models.BooleanField(help_text="If an exam should be available",
default=True)
- recreate_json = models.BooleanField(help_text="If the json cache needs updating",
- default=False)
-
def __str__(self):
return self.name
diff --git a/anatomy/templates/anatomy/exam_scores_user.html b/anatomy/templates/anatomy/exam_scores_user.html
new file mode 100644
index 00000000..3bca3b1b
--- /dev/null
+++ b/anatomy/templates/anatomy/exam_scores_user.html
@@ -0,0 +1,13 @@
+{% extends 'anatomy/exams.html' %}
+
+{% block content %}
+
+
{{ exam.name }}
+ Candidate: {{ user_names|get_item:user }}
+
+ Answers: {% for ans, score in answers_and_marks %}
+ {{ans}} ({{score}}),
+ {% endfor %}
+
Total mark: {{ score }}
+
+{% endblock %}
diff --git a/anatomy/urls.py b/anatomy/urls.py
index 7127832b..e2679031 100644
--- a/anatomy/urls.py
+++ b/anatomy/urls.py
@@ -16,6 +16,8 @@ urlpatterns = [
path("exam//", views.exam_overview, name="exam_overview"),
path("exam//scores", views.exam_scores_cid,
name="exam_scores_cid"),
+ path("exam//scores//", views.exam_scores_cid_user,
+ name="exam_scores_cid_user"),
path("exam/submit", views.postExamAnswers, name="exam_answers_submit"),
path("exam/", views.exam_list, name="exam_list"),
path("exam/json/", views.active_exams, name="active_exams"),
diff --git a/anatomy/views.py b/anatomy/views.py
index 969bf54f..8de6c5da 100644
--- a/anatomy/views.py
+++ b/anatomy/views.py
@@ -580,6 +580,56 @@ def exam_scores_cid(request, pk):
},
)
+def exam_scores_cid_user(request, pk, sk):
+ exam = get_object_or_404(Exam, pk=pk)
+
+ # TODO:Need some kind of test for cid
+ cid = sk
+
+ questions = exam.exam_questions.all()
+
+ answers_and_marks = []
+ answers_marks = []
+ answers = []
+
+ for q in questions:
+ # Get user answer
+ s = q.cid_user_answers.filter(cid=cid)
+ if not s:
+ # skip if no answer
+ answers_marks.append(0)
+ answers.append("")
+ continue
+
+ ans = s[0].answer
+ if q.answers.filter(answer__iexact=ans, status=Answer.MarkOptions.CORRECT).first() is not None:
+ a = 2
+ elif q.answers.filter(answer__iexact=ans, status=Answer.MarkOptions.HALF_MARK).first() is not None:
+ a = 1
+ else:
+ a = 0
+ answers.append(ans)
+ answers_marks.append(a)
+ answers_and_marks.append((ans, a))
+
+ score = sum(answers_marks)
+
+ total = len(questions)
+
+ return render(
+ request,
+ "anatomy/exam_scores_user.html",
+ {
+ "exam": exam,
+ "cid": cid,
+ "questions": questions,
+ "answers": answers,
+ "answers_marks": answers_marks,
+ "score": score,
+ "answers_and_marks": answers_and_marks,
+ },
+ )
+
@login_required
def exam_scores(request, pk):