summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorPalaparthy Adityachandra2021-02-11 11:38:01 +0530
committerGitHub2021-02-11 11:38:01 +0530
commitfc2da8b120415bc22825ea57d5a8b453b63ab838 (patch)
tree796cc1ecec9f841920e79903f48c16017defa17f /yaksh/models.py
parentc179633d31dbdd1bb4cc9a6e157664bc5712756c (diff)
parented50666eceb10b7c8cfa1352ffde2c1025f3aa9a (diff)
downloadonline_test-fc2da8b120415bc22825ea57d5a8b453b63ab838.tar.gz
online_test-fc2da8b120415bc22825ea57d5a8b453b63ab838.tar.bz2
online_test-fc2da8b120415bc22825ea57d5a8b453b63ab838.zip
Merge pull request #816 from adityacp/hot_fixes
UI and Bug Fixes
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index b4d0f76..16800fe 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -2027,7 +2027,7 @@ class AnswerPaperManager(models.Manager):
que_ids = [que.id for que in all_questions]
papers = self.filter(
question_paper_id=questionpaper_id, course_id=course_id,
- attempt_number=attempt_number
+ attempt_number=attempt_number, status=status
).values_list("id", flat=True)
answers = Answer.objects.filter(
answerpaper__id__in=papers, question_id__in=que_ids
@@ -2173,11 +2173,12 @@ class AnswerPaperManager(models.Manager):
answerpaper__id__in=answerpaper_ids
).values("question_id", "answerpaper__id")
df = pd.DataFrame(answers)
- answerpapers = df.groupby("answerpaper__id")
- question_attempted = {}
- for ap in answerpapers:
- question_attempted[ap[0]] = len(ap[1]["question_id"].unique())
- return question_attempted
+ if not df.empty and "answerpaper__id" in df.columns:
+ answerpapers = df.groupby("answerpaper__id")
+ question_attempted = {}
+ for ap in answerpapers:
+ question_attempted[ap[0]] = len(ap[1]["question_id"].unique())
+ return question_attempted
###############################################################################