.
This commit is contained in:
@@ -124,6 +124,19 @@ class Question(models.Model):
|
|||||||
self.e_answer,
|
self.e_answer,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_answer_by_choice(self, choice):
|
||||||
|
if choice == "a":
|
||||||
|
return self.a_answer
|
||||||
|
if choice == "b":
|
||||||
|
return self.b_answer
|
||||||
|
if choice == "c":
|
||||||
|
return self.c_answer
|
||||||
|
if choice == "d":
|
||||||
|
return self.d_answer
|
||||||
|
if choice == "e":
|
||||||
|
return self.e_answer
|
||||||
|
|
||||||
|
|
||||||
def get_correct_answer(self):
|
def get_correct_answer(self):
|
||||||
if self.best_answer == "a":
|
if self.best_answer == "a":
|
||||||
return self.a_answer
|
return self.a_answer
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
<h3>Candidate: {{ cid }}</h3>
|
<h3>Candidate: {{ cid }}</h3>
|
||||||
Answers:
|
Answers:
|
||||||
<ul>
|
<ul>
|
||||||
{% for question, a, score, correct_answer in answers_and_marks %}
|
{% for question, a, score, correct_answer, chosen_answer in answers_and_marks %}
|
||||||
<li class="user-answer-li"><a href="{% url 'sbas:exam_take' exam.pk forloop.counter0 cid passcode %}">Question
|
<li class="user-answer-li"><a href="{% url 'sbas:exam_take' exam.pk forloop.counter0 cid passcode %}">Question
|
||||||
{{forloop.counter}}</a> - {{ question.stem |safe}}</li>
|
{{forloop.counter}}</a> - {{ question.stem |safe}}</li>
|
||||||
<span>Correct answer: {{correct_answer|safe}} <br />{{a}} <span class="answer-{{score}}">(Score:
|
<span>Correct answer: {{correct_answer|safe}} <br />Chosen answer: {{a}} {{chosen_answer|safe}} <span class="answer-{{score}}">(Score:
|
||||||
{{score}})</span></span>
|
{{score}})</span></span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
+2
-1
@@ -126,7 +126,8 @@ def exam_scores_cid_user(request, pk, cid, passcode):
|
|||||||
answers_marks.append(answer_score)
|
answers_marks.append(answer_score)
|
||||||
|
|
||||||
merged_ans = (ans, answer_score, correct_answer)
|
merged_ans = (ans, answer_score, correct_answer)
|
||||||
answers_and_marks.append((q, *merged_ans))
|
chosen_answer = q.get_answer_by_choice(ans)
|
||||||
|
answers_and_marks.append((q, *merged_ans, chosen_answer))
|
||||||
|
|
||||||
total_score = sum(answers_marks)
|
total_score = sum(answers_marks)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user