summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authorankitjavalkar2016-12-21 18:09:49 +0530
committerankitjavalkar2016-12-21 18:17:48 +0530
commita88197040b69a556f9c7b0432350b9d1d4aad06f (patch)
tree9a3dd0a6a7977033d28e351c8a866c495449c530 /yaksh/test_models.py
parentfb991b4792b48c80e269236bf5aa28a70d34dbf6 (diff)
downloadonline_test-a88197040b69a556f9c7b0432350b9d1d4aad06f.tar.gz
online_test-a88197040b69a556f9c7b0432350b9d1d4aad06f.tar.bz2
online_test-a88197040b69a556f9c7b0432350b9d1d4aad06f.zip
Fix rendering and representation of errors
- Error are sent as list - Error are None if answer is fully correct - Error is rendered as in grade user and code questions as neat CSS divs - Fix corresponding test cases - Fix get_question answers in models.py
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 317c832..dc69024 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -487,12 +487,14 @@ class AnswerPaperTestCases(unittest.TestCase):
# answers for the Answer Paper
self.answer_right = Answer(question=Question.objects.get(id=1),
answer="Demo answer",
- correct=True, marks=1
+ correct=True, marks=1,
+ error=json.dumps([])
)
self.answer_wrong = Answer(question=Question.objects.get(id=2),
answer="My answer",
correct=False,
- marks=0
+ marks=0,
+ error=json.dumps(['error1', 'error2'])
)
self.answer_right.save()
self.answer_wrong.save()
@@ -587,7 +589,6 @@ class AnswerPaperTestCases(unittest.TestCase):
# Then
self.assertTrue(correct)
self.assertTrue(result['success'])
- self.assertEqual(result['error'], 'Correct answer')
self.answer.correct = True
self.answer.marks = 1
@@ -729,8 +730,8 @@ class AnswerPaperTestCases(unittest.TestCase):
""" Test get_question_answer() method of Answer Paper"""
answered = self.answerpaper.get_question_answers()
first_answer = list(answered.values())[0][0]
- self.assertEqual(first_answer.answer, 'Demo answer')
- self.assertTrue(first_answer.correct)
+ self.assertEqual(first_answer[0].answer, 'Demo answer')
+ self.assertTrue(first_answer[0].correct)
self.assertEqual(len(answered), 2)
def test_is_answer_correct(self):