From 8c1c1f6c8b1de16fba5f93e58a0cd3cb751e02d7 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 10 Feb 2021 19:02:29 +0530 Subject: Change in templates, views - Revamp UI in course page - Fix a bug where a trial module is created without setting is_trial in models - Fix a bug in question statistics where only completed answerpaper data is needed --- yaksh/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index b4d0f76..5934ae2 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 -- cgit From ed50666eceb10b7c8cfa1352ffde2c1025f3aa9a Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 11 Feb 2021 11:04:59 +0530 Subject: Fix issue in pandas dataframe where key is not available --- yaksh/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 5934ae2..16800fe 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -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 ############################################################################### -- cgit