From 5d1c3f0ba11bfd84be1d3074a327b021eced56e5 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 15 Oct 2020 23:45:23 +0530 Subject: Display unanswered questions in grading view --- yaksh/models.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'yaksh') diff --git a/yaksh/models.py b/yaksh/models.py index da2327c..cca2a2c 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -2378,15 +2378,24 @@ class AnswerPaper(models.Model): 'error_list': [e for e in json.loads(answer.error)] }] + q_a.update( + { q: [] for q in self.questions_unanswered.all() } + ) + for question, answers in q_a.items(): answers = q_a[question] - q_a[question].append({ - 'marks': max([ - answer['answer'].marks - for answer in answers - if question == answer['answer'].question - ]) - }) + if answers: + q_a[question].append({ + 'marks': max([ + answer['answer'].marks + for answer in answers + if question == answer['answer'].question + ]), + }) + else: + q_a[question].append({ + 'marks': 0.0, + }) return q_a -- cgit