diff --git a/longs/migrations/0024_auto_20210217_1423.py b/longs/migrations/0024_auto_20210217_1423.py
new file mode 100644
index 00000000..dda2d25a
--- /dev/null
+++ b/longs/migrations/0024_auto_20210217_1423.py
@@ -0,0 +1,17 @@
+# Generated by Django 3.1.3 on 2021-02-17 14:23
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('longs', '0023_auto_20210216_1315'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='ciduseranswer',
+ options={'ordering': ['cid']},
+ ),
+ ]
diff --git a/longs/models.py b/longs/models.py
index c8cc5870..015d66c3 100644
--- a/longs/models.py
+++ b/longs/models.py
@@ -406,15 +406,15 @@ class CidUserAnswer(models.Model):
class ScoreOptions(models.TextChoices):
UNMARKED = "", _("Unmarked")
- FOUR = "4", _("4")
+ FOUR = 4, _("4")
FOUR_HALF = "4.5", _("4.5")
- FIVE = "5", _("5")
+ FIVE = 5, _("5")
FIVE_HALF = "5.5", _("5.5")
- SIX = "6", _("6")
+ SIX = 6, _("6")
SIX_HALF = "6.5", _("6.5")
- SEVEN = "7", _("7")
+ SEVEN = 7, _("7")
SEVEN_HALF = "7.5", _("7.5")
- EIGHT = "8", _("8")
+ EIGHT = 8, _("8")
score = models.CharField(
max_length=3, choices=ScoreOptions.choices, default=ScoreOptions.UNMARKED, blank=True
diff --git a/longs/templates/longs/exam_scores.html b/longs/templates/longs/exam_scores.html
index 95bbca04..6579fcc5 100644
--- a/longs/templates/longs/exam_scores.html
+++ b/longs/templates/longs/exam_scores.html
@@ -49,7 +49,7 @@
| Question {{forloop.counter}} |
{% for ans, score in by_question|get_item:question %}
- {{ans}} |
+ {{score}} |
{% endfor %}
{% endfor %}
diff --git a/longs/templates/longs/exam_scores_user.html b/longs/templates/longs/exam_scores_user.html
index c6a64ad0..86936e20 100644
--- a/longs/templates/longs/exam_scores_user.html
+++ b/longs/templates/longs/exam_scores_user.html
@@ -5,8 +5,8 @@
Exam: {{ exam.name }}
Candidate: {{ cid }}
Answers:
- {% for ans, score, correct_answer in answers_and_marks %}
- - Question {{forloop.counter}} - Correct answer: {{ correct_answer }}
+ {% for score in answers_marks %}
+ - Question {{forloop.counter}}
{{ans}} ({{score}})
{% endfor %}
diff --git a/longs/views.py b/longs/views.py
index 49c0dbed..33ff7943 100755
--- a/longs/views.py
+++ b/longs/views.py
@@ -787,27 +787,27 @@ def exam_scores_cid(request, pk):
s = q.cid_user_answers.filter(cid=cid).first()
if not s:
- # skip if no answer
- user_answers_marks[cid].append(0)
- user_answers[cid].append("")
- by_question[q].append(("", 0))
+ # skip if no answer, (score 4)
+ user_answers_marks[cid].append(4)
+ #user_answers[cid].append("")
+ by_question[q].append(("", 4))
continue
else:
- ans = s.answer
+ ans = ""
answer_score = s.get_answer_score()
- if answer_score == "unmarked":
+ if answer_score == "":
index = exam.get_question_index(q)
unmarked.add(index)
- user_answers[cid].append(ans)
+ #user_answers[cid].append(ans)
user_answers_marks[cid].append(answer_score)
- user_answers_and_marks[cid].append((ans, answer_score))
+ #user_answers_and_marks[cid].append((ans, answer_score))
by_question[q].append((ans, answer_score))
user_scores = {}
for user in user_answers_marks:
user_scores[user] = sum(
- [i for i in user_answers_marks[user] if i != "unmarked"]
+ [float(i) for i in user_answers_marks[user] if i != ""]
)
user_scores_list = list(user_scores.values())
@@ -847,12 +847,12 @@ def exam_scores_cid(request, pk):
"unmarked": unmarked,
"questions": questions,
"by_question": by_question,
- "user_answers": dict(user_answers),
+ #"user_answers": dict(user_answers),
"user_answers_marks": dict(user_answers_marks),
"user_scores": user_scores,
"user_scores_list": user_scores_list,
"user_names": user_names,
- "user_answers_and_marks": user_answers_and_marks,
+ #"user_answers_and_marks": user_answers_and_marks,
"max_score": max_score,
"mean": mean,
"median": median,
@@ -870,9 +870,9 @@ def exam_scores_cid_user(request, pk, sk):
questions = exam.exam_questions.all()
- answers_and_marks = []
+ #answers_and_marks = []
answers_marks = []
- answers = []
+ #answers = []
for q in questions:
# Get user answer
@@ -881,28 +881,21 @@ def exam_scores_cid_user(request, pk, sk):
if not user_answer or user_answer is None:
# skip if no answer
- answers_marks.append(0)
+ #answers_marks.append("")
#answers.append("")
- answer_score = 0
- ans = "Not answered"
+ answer_score = 4
+ #ans = "Not answered"
else:
- if user_answer.normal:
- ans = "Normal"
- else:
- ans = user_answer.answer
answer_score = user_answer.get_answer_score()
- correct_answer = q.GetPrimaryAnswer()
-
if not exam.publish_results:
- correct_answer = "*****"
answer_score = 0
- answers.append(ans)
+ #answers.append(ans)
answers_marks.append(answer_score)
- answers_and_marks.append((ans, answer_score, correct_answer))
+ #answers_and_marks.append((ans, answer_score, correct_answer))
- if "unmarked" in answers_marks:
- answered = [i for i in answers_marks if type(i) == int]
+ if "" in answers_marks:
+ answered = [int(i) for i in answers_marks if i != ""]
total_score = sum(answered)
unmarked_number = len(answers_marks) - len(answered)
total_score = "{} ({} unmarked)".format(total_score, unmarked_number)
@@ -918,11 +911,11 @@ def exam_scores_cid_user(request, pk, sk):
"exam": exam,
"cid": cid,
"questions": questions,
- "answers": answers,
+ #"answers": answers,
"answers_marks": answers_marks,
"total_score": total_score,
"max_score": max_score,
- "answers_and_marks": answers_and_marks,
+ #"answers_and_marks": answers_and_marks,
},
)
diff --git a/rad/views.py b/rad/views.py
index 4986e10a..170301f3 100644
--- a/rad/views.py
+++ b/rad/views.py
@@ -30,12 +30,14 @@ from anatomy.models import Exam as AnatomyExam
from rapids.models import CidUserAnswer as RapidsCidUserAnswer
from rapids.models import Exam as RapidsExam
+from longs.models import CidUserAnswer as LongsCidUserAnswer
+from longs.models import Exam as LongsExam
+
from anatomy.views import AnatomyExamViews
from rapids.views import RapidExamViews
from longs.views import LongExamViews
-
@login_required
def profile(request):
user = request.user
@@ -50,32 +52,36 @@ def cid_selector(request):
def cid_scores(request, pk):
- #exam = get_object_or_404(Exam, pk=pk)
+ # exam = get_object_or_404(Exam, pk=pk)
# TODO:Need some kind of test for cid
cid = pk
- #questions = exam.exam_questions.all()
- physics_answers = PhysicsCidUserAnswer.objects.filter(
- cid=cid)
- anatomy_answers = AnatomyCidUserAnswer.objects.filter(
- cid=cid)
- rapids_answers = RapidsCidUserAnswer.objects.filter(
- cid=cid)
+ # questions = exam.exam_questions.all()
+ physics_answers = PhysicsCidUserAnswer.objects.filter(cid=cid)
+ anatomy_answers = AnatomyCidUserAnswer.objects.filter(cid=cid)
+ rapids_answers = RapidsCidUserAnswer.objects.filter(cid=cid)
+ longs_answers = LongsCidUserAnswer.objects.filter(cid=cid)
-
- if not physics_answers and not anatomy_answers and not rapids_answers:
+ if (
+ not physics_answers
+ and not anatomy_answers
+ and not rapids_answers
+ and not longs_answers
+ ):
raise Http404("cid not found")
- physics_exam_ids = physics_answers.values_list("exam").distinct()
+ physics_exam_ids = physics_answers.values_list("exam").distinct()
physics_exams = PhysicsExam.objects.filter(id__in=physics_exam_ids)
- anatomy_exam_ids = anatomy_answers.values_list("exam").distinct()
+ anatomy_exam_ids = anatomy_answers.values_list("exam").distinct()
anatomy_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids)
- rapids_exam_ids = rapids_answers.values_list("exam").distinct()
+ rapids_exam_ids = rapids_answers.values_list("exam").distinct()
rapids_exams = RapidsExam.objects.filter(id__in=rapids_exam_ids)
+ longs_exam_ids = longs_answers.values_list("exam").distinct()
+ longs_exams = LongsExam.objects.filter(id__in=longs_exam_ids)
return render(
request,
@@ -84,10 +90,12 @@ def cid_scores(request, pk):
"physics_exams": physics_exams,
"anatomy_exams": anatomy_exams,
"rapids_exams": rapids_exams,
+ "longs_exams": longs_exams,
"cid": cid,
},
)
+
def active_exams(request):
anatomy_exams = AnatomyExamViews.active_exams(request, False)
rapid_exams = RapidExamViews.active_exams(request, False)
@@ -100,7 +108,6 @@ def active_exams(request):
active_exams = {"exams": exams}
-
return JsonResponse(active_exams)
diff --git a/templates/cid_scores.html b/templates/cid_scores.html
index 7a61a2de..e415924e 100644
--- a/templates/cid_scores.html
+++ b/templates/cid_scores.html
@@ -22,5 +22,11 @@
- {{exam.name}}
{% endfor %}
+ Longs
+
{% endblock %}