summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2021-01-25 13:12:56 +0530
committeradityacp2021-01-25 14:28:11 +0530
commit1e5c8af8748602d90a52f51d45799274155f8cd9 (patch)
treed51c46ee81866b7065f994b9e3c100457947312c /yaksh/models.py
parentc474c68a2621e8c470ce2751103128fa793be62e (diff)
downloadonline_test-1e5c8af8748602d90a52f51d45799274155f8cd9.tar.gz
online_test-1e5c8af8748602d90a52f51d45799274155f8cd9.tar.bz2
online_test-1e5c8af8748602d90a52f51d45799274155f8cd9.zip
Fix views and models tests
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 7609859..3e3e2d1 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -2178,6 +2178,8 @@ class AnswerPaperManager(models.Manager):
return best_attempt
def get_user_scores(self, question_papers, user, course_id):
+ if not question_papers:
+ return None
qp_ids = list(zip(*question_papers))[0]
papers = self.filter(
course_id=course_id, user_id=user.get("id"),
@@ -2277,6 +2279,8 @@ class AnswerPaper(models.Model):
)
def get_per_question_score(self, question_ids):
+ if not question_ids:
+ return None
que_ids = list(zip(*question_ids))[1]
answers = self.answers.filter(
question_id__in=que_ids).values("question_id", "marks")