.
This commit is contained in:
@@ -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']},
|
||||
),
|
||||
]
|
||||
+5
-5
@@ -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
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<tr>
|
||||
<td>Question {{forloop.counter}}</td>
|
||||
{% for ans, score in by_question|get_item:question %}
|
||||
<td class="user-answer-score-{{score}}" title="answer score: {{score}}">{{ans}}</td>
|
||||
<td class="user-answer-score-{{score}}" title="answer score: {{score}}">{{score}}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<h2>Exam: {{ exam.name }}</h2>
|
||||
<h3>Candidate: {{ cid }}</h3>
|
||||
Answers:
|
||||
<ul>{% for ans, score, correct_answer in answers_and_marks %}
|
||||
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span class="correct-answer">{{ correct_answer }}</span></li>
|
||||
<ul>{% for score in answers_marks %}
|
||||
<li class="user-answer-li">Question {{forloop.counter}}</li>
|
||||
<span class="user-answer-score user-answer-score-{{score}}"><pre>{{ans}}</pre> ({{score}})</span>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
+22
-29
@@ -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,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
+22
-15
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -22,5 +22,11 @@
|
||||
<li><a href="{% url 'rapids:exam_scores_cid_user' pk=exam.pk sk=cid %}">{{exam.name}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h3>Longs</h3>
|
||||
<ul>
|
||||
{% for exam in longs_exams %}
|
||||
<li><a href="{% url 'longs:exam_scores_cid_user' pk=exam.pk sk=cid %}">{{exam.name}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user