summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2020-09-22 14:50:54 +0530
committeradityacp2020-09-22 14:51:21 +0530
commit3130680c9a405cbaa77108a48d3923790920b2e3 (patch)
tree06f36c053c2cb3f2c7f7fa1461dd410ad4982b37 /yaksh/models.py
parentf02cd58ea21e08c9a7e8120fd5ced3263cf904f6 (diff)
downloadonline_test-3130680c9a405cbaa77108a48d3923790920b2e3.tar.gz
online_test-3130680c9a405cbaa77108a48d3923790920b2e3.tar.bz2
online_test-3130680c9a405cbaa77108a48d3923790920b2e3.zip
Add initial tests for lesson contents
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py16
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']