summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormahesh2018-02-09 15:43:44 +0530
committermaheshgudi2018-03-16 15:15:50 +0530
commit07be6be0e805e17e45290b0e8137c044b2094edc (patch)
tree2dd1b2214be3c7ccc1bc82bdb2b2cb9cf1109ff4
parentd4c79e599bfee207790632a71848d383fae7bd25 (diff)
downloadonline_test-07be6be0e805e17e45290b0e8137c044b2094edc.tar.gz
online_test-07be6be0e805e17e45290b0e8137c044b2094edc.tar.bz2
online_test-07be6be0e805e17e45290b0e8137c044b2094edc.zip
Change custom filter function to get_answer_for_arrange_options
-rw-r--r--yaksh/forms.py2
-rw-r--r--yaksh/models.py4
-rw-r--r--yaksh/templates/yaksh/grade_user.html2
-rw-r--r--yaksh/templates/yaksh/question.html2
-rw-r--r--yaksh/templates/yaksh/user_data.html2
-rw-r--r--yaksh/templates/yaksh/view_answerpaper.html2
-rw-r--r--yaksh/templatetags/custom_filters.py2
-rw-r--r--yaksh/templatetags/test_custom_filters.py23
8 files changed, 17 insertions, 22 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 9317a8e..4c690b1 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -35,7 +35,7 @@ question_types = (
("integer", "Answer in Integer"),
("string", "Answer in String"),
("float", "Answer in Float"),
- ("arrange", "Arrange Options in Order"),
+ ("arrange", "Arrange Options in Correct Order"),
)
test_case_types = (
diff --git a/yaksh/models.py b/yaksh/models.py
index 624f776..ffc3c56 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -54,7 +54,7 @@ question_types = (
("integer", "Answer in Integer"),
("string", "Answer in String"),
("float", "Answer in Float"),
- ("arrange", "Arrange Options in Order"),
+ ("arrange", "Arrange Options in Correct Order"),
)
@@ -1795,7 +1795,7 @@ class AnswerPaper(models.Model):
result['error'] = ['Correct answer']
elif question.type == 'arrange':
- tc_list = sorted([ids.id for ids in question.get_test_cases()])
+ tc_list = sorted([tc.id for tc in question.get_test_cases()])
if user_answer == tc_list:
result['success'] = True
result['error'] = ['Correct answer']
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 09887c4..8430e91 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -318,7 +318,7 @@ Status : <b style="color: red;"> Failed </b><br/>
{% elif question.type == "arrange"%}
<div class="well well-sm">
- {% get_arrange_user_answer ans.answer.answer question as tc_list %}
+ {% get_answer_for_arrange_options ans.answer.answer question as tc_list %}
{% for testcases in tc_list %}
<li>{{ testcases.options.strip|safe }}</li>
{% endfor %}
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index 3bdabd1..b65073a 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -257,7 +257,7 @@ question_type = "{{ question.type }}"
{% if question.type == "arrange" %}
{% if last_attempt %}
- {% get_arrange_user_answer last_attempt question as test_cases %}
+ {% get_answer_for_arrange_options last_attempt question as test_cases %}
{% endif %}
<input name="answer" type="hidden" id='arrange_order'/>
<div class="list-group">
diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html
index fe3f2a6..9449fcc 100644
--- a/yaksh/templates/yaksh/user_data.html
+++ b/yaksh/templates/yaksh/user_data.html
@@ -127,7 +127,7 @@ User IP address: {{ paper.user_ip }}
{% elif question.type == "arrange"%}
<div class="well well-sm">
- {% get_arrange_user_answer answers.0.answer question as tc_list %}
+ {% get_answer_for_arrange_options answers.0.answer question as tc_list %}
{% for testcases in tc_list %}
<li>{{ testcases.options.strip|safe }}</li>
{% endfor %}
diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html
index 3d39092..7cbec91 100644
--- a/yaksh/templates/yaksh/view_answerpaper.html
+++ b/yaksh/templates/yaksh/view_answerpaper.html
@@ -118,7 +118,7 @@
</div>
{% elif question.type == "arrange"%}
<div class="well well-sm">
- {% get_arrange_user_answer answers.0.answer question as tc_list %}
+ {% get_answer_for_arrange_options answers.0.answer question as tc_list %}
{% for testcases in tc_list %}
<li>{{ testcases.options.strip|safe }}</li>
{% endfor %}
diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py
index e24a792..2696ae4 100644
--- a/yaksh/templatetags/custom_filters.py
+++ b/yaksh/templatetags/custom_filters.py
@@ -70,7 +70,7 @@ def get_ordered_testcases(question, answerpaper):
return question.get_ordered_test_cases(answerpaper)
@register.simple_tag
-def get_arrange_user_answer(ans, question):
+def get_answer_for_arrange_options(ans, question):
if type(ans) == bytes:
ans = ans.decode("utf-8")
else:
diff --git a/yaksh/templatetags/test_custom_filters.py b/yaksh/templatetags/test_custom_filters.py
index 5a73ae0..7f75b1f 100644
--- a/yaksh/templatetags/test_custom_filters.py
+++ b/yaksh/templatetags/test_custom_filters.py
@@ -13,7 +13,7 @@ from yaksh.models import (User, Profile, Question, Quiz, QuestionPaper,
from yaksh.templatetags.custom_filters import (completed, inprogress,
get_ordered_testcases,
- get_arrange_user_answer
+ get_answer_for_arrange_options
)
@@ -78,15 +78,10 @@ class CustomFiltersTestCases(unittest.TestCase):
self.question_paper.save()
#Creating answerpaper
- self.answerpaper = AnswerPaper.objects.create(user=self.user,
- user_ip='101.0.0.1',
- start_time=timezone.now(),
- question_paper=self.question_paper,
- end_time=timezone.now()
- +timedelta(minutes=5),
- attempt_number=1,
- course=self.course
- )
+ self.answerpaper = AnswerPaper.objects.get(user=self.user,
+ course=self.course,
+ question_paper=self.question_paper
+ )
self.answerpaper.questions.add(self.question1)
self.answerpaper.save()
# For question
@@ -126,15 +121,15 @@ class CustomFiltersTestCases(unittest.TestCase):
self.assertEqual(inprogress(answerpaper), 0)
self.assertEqual(completed(answerpaper), 1)
- def test_get_arrange_user_answer(self):
+ def test_get_answer_for_arrange_options(self):
arrange_ans = [self.arrange_testcase_3,
self.arrange_testcase_2,
self.arrange_testcase_1,
]
arrange_ans_id = [tc.id for tc in arrange_ans]
- user_ans_order = get_arrange_user_answer(arrange_ans_id,
- self.question1
- )
+ user_ans_order = get_answer_for_arrange_options(arrange_ans_id,
+ self.question1
+ )
self.assertSequenceEqual(arrange_ans, user_ans_order)
def test_get_ordered_testcases(self):