diff options
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 95a5da0..f46ddda 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -2769,8 +2769,8 @@ class TOCManager(models.Manager): return data def get_question_stats(self, toc_id): - answers = LessonQuizAnswer.objects.filter( - toc_id=toc_id) + answers = LessonQuizAnswer.objects.get_queryset().filter( + toc_id=toc_id).order_by('id') question = answers.first().toc.content_object answers = answers.values( "student__first_name", "student__last_name", "student__email", @@ -2855,17 +2855,17 @@ class LessonQuizAnswer(models.Model): result['error'] = ['Correct answer'] elif question.type == 'mcc': - expected_answers = [] - for opt in question.get_test_cases(correct=True): - expected_answers.append(str(opt.id)) + expected_answers = [ + str(opt.id) for opt in question.get_test_cases(correct=True) + ] if set(user_answer) == set(expected_answers): result['success'] = True result['error'] = ['Correct answer'] elif question.type == 'integer': - expected_answers = [] - for tc in question.get_test_cases(): - expected_answers.append(int(tc.correct)) + expected_answers = [ + int(tc.correct) for tc in question.get_test_cases() + ] if int(user_answer) in expected_answers: result['success'] = True result['error'] = ['Correct answer'] |