summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/models.py4
-rw-r--r--yaksh/test_models.py8
2 files changed, 7 insertions, 5 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 0456b52..eeae4af 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -2311,8 +2311,8 @@ class AnswerPaper(models.Model):
q_a[question].append({
'marks': max([
answer['answer'].marks
- for answer in answers
- if question == answer['answer'].question
+ for answer in answers
+ if question == answer['answer'].question
])
})
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index a77c8bf..a48876c 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -1654,12 +1654,14 @@ class AnswerPaperTestCases(unittest.TestCase):
answers_saved = Answer.objects.filter(question=question)
error_list = [json.loads(ans.error) for ans in answers_saved]
if answers_saved:
- self.assertEqual(len(answered[question]), len(answers_saved))
+ self.assertGreater(len(answered[question]), len(answers_saved))
ans = []
err = []
for val in answered[question]:
- ans.append(val.get('answer'))
- err.append(val.get('error_list'))
+ if val.get('answer') is not None:
+ ans.append(val.get('answer'))
+ if val.get('error_list') is not None:
+ err.append(val.get('error_list'))
self.assertEqual(set(ans), set(answers_saved))
self.assertEqual(error_list, err)