summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2016-12-23 15:03:37 +0530
committeradityacp2016-12-23 15:03:37 +0530
commitd442941819dc7f8b65a2965fbcefe000fea1cde2 (patch)
tree624d8ba12cf83cf57f685bc8cee158be14aee783 /yaksh/models.py
parent14b628f49a7d0aa58c22c021c62a5d0a748ae881 (diff)
parent48366e84b98157ac32b22b2aa19b1c1cde68afd4 (diff)
downloadonline_test-d442941819dc7f8b65a2965fbcefe000fea1cde2.tar.gz
online_test-d442941819dc7f8b65a2965fbcefe000fea1cde2.tar.bz2
online_test-d442941819dc7f8b65a2965fbcefe000fea1cde2.zip
Fix conflict
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 8ef1097..35e14e9 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1027,9 +1027,15 @@ class AnswerPaper(models.Model):
for answer in self.answers.all():
question = answer.question
if question in q_a:
- q_a[question].append(answer)
+ q_a[question].append({'answer': answer,
+ 'error_list': [e for e in json.loads(answer.error)]
+ }
+ )
else:
- q_a[question] = [answer]
+ q_a[question] = [{'answer': answer,
+ 'error_list': [e for e in json.loads(answer.error)]
+ }
+ ]
return q_a
def get_questions(self):
@@ -1064,20 +1070,20 @@ class AnswerPaper(models.Model):
For code questions success is True only if the answer is correct.
"""
- result = {'success': True, 'error': 'Incorrect answer', 'weight': 0.0}
+ result = {'success': True, 'error': ['Incorrect answer'], 'weight': 0.0}
correct = False
if user_answer is not None:
if question.type == 'mcq':
expected_answer = question.get_test_case(correct=True).options
if user_answer.strip() == expected_answer.strip():
correct = True
- result['error'] = 'Correct answer'
+ result['error'] = ['Correct answer']
elif question.type == 'mcc':
expected_answers = []
for opt in question.get_test_cases(correct=True):
expected_answers.append(opt.options)
if set(user_answer) == set(expected_answers):
- result['error'] = 'Correct answer'
+ result['error'] = ['Correct answer']
correct = True
elif question.type == 'code':
user_dir = self.user.profile.get_user_dir()
@@ -1158,9 +1164,7 @@ class StandardTestCase(TestCase):
"test_case_args": self.test_case_args}
def __str__(self):
- return u'Question: {0} | Test Case: {1}'.format(self.question,
- self.test_case
- )
+ return u'Standard TestCase | Test Case: {0}'.format(self.test_case)
class StdIOBasedTestCase(TestCase):
@@ -1175,7 +1179,7 @@ class StdIOBasedTestCase(TestCase):
"weight": self.weight}
def __str__(self):
- return u'Question: {0} | Exp. Output: {1} | Exp. Input: {2}'.format(self.question,
+ return u'StdIO Based Testcase | Exp. Output: {0} | Exp. Input: {1}'.format(
self.expected_output, self.expected_input
)
@@ -1188,9 +1192,7 @@ class McqTestCase(TestCase):
return {"test_case_type": "mcqtestcase", "options": self.options, "correct": self.correct}
def __str__(self):
- return u'Question: {0} | Correct: {1}'.format(self.question,
- self.correct
- )
+ return u'MCQ Testcase | Correct: {0}'.format(self.correct)
class HookTestCase(TestCase):