summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorankitjavalkar2020-05-28 19:01:10 +0530
committerGitHub2020-05-28 19:01:10 +0530
commit0b72c7dd886707b6e9366fd4b4f012dd03fe799c (patch)
treeddafcaca3bea8ed06b73d66316d8ddc31802ad1c
parent73dc8f6820c6c86fd8e70a68456ca2e541801bde (diff)
parenta3962950e50223a55f3b6071e37d6d383163e464 (diff)
downloadonline_test-0b72c7dd886707b6e9366fd4b4f012dd03fe799c.tar.gz
online_test-0b72c7dd886707b6e9366fd4b4f012dd03fe799c.tar.bz2
online_test-0b72c7dd886707b6e9366fd4b4f012dd03fe799c.zip
Merge pull request #718 from ankitjavalkar/fix-mcq-select
Add a custom filter to convert str to int and fix view last submitted MCQ answer
-rw-r--r--yaksh/templates/yaksh/question.html2
-rw-r--r--yaksh/templatetags/custom_filters.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index 640003b..ae2f9f4 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -226,7 +226,7 @@ question_type = "{{ question.type }}";
<!-- MCQ type question -->
{% if question.type == "mcq" %}
{% for test_case in test_cases %}
- {% if last_attempt and last_attempt|safe == test_case.id|safe %}
+ {% if last_attempt and last_attempt|to_int == test_case.id %}
<input name="answer" type="radio" value="{{ test_case.id }}" checked />
{{ test_case.options|safe }} <br/>
{% else %}
diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py
index 7dc29d4..7a065eb 100644
--- a/yaksh/templatetags/custom_filters.py
+++ b/yaksh/templatetags/custom_filters.py
@@ -38,6 +38,9 @@ def inprogress(answerpaper):
def zip_longest_out(a, b):
return zip_longest(a, b)
+@register.filter(name='to_int')
+def to_int(value):
+ return int(value)
@register.filter(name="file_title")
def file_title(name):