From f5701e1c6ba3700b834257a4b84388485cb8818d Mon Sep 17 00:00:00 2001
From: maheshgudi
Date: Thu, 5 Oct 2017 20:39:22 +0530
Subject: Use MCQ/MCC testcases id instead of options to validate answer
---
yaksh/models.py | 6 +++---
yaksh/templates/yaksh/grade_user.html | 26 +++++++++++++++++++++-----
yaksh/templates/yaksh/question.html | 12 ++++++------
yaksh/templates/yaksh/user_data.html | 18 ++++++++++++++++++
yaksh/templates/yaksh/view_answerpaper.html | 29 ++++++++++++++++++++++++-----
yaksh/test_models.py | 4 ++--
yaksh/test_views.py | 10 +++++-----
7 files changed, 79 insertions(+), 26 deletions(-)
diff --git a/yaksh/models.py b/yaksh/models.py
index b5bde04..4859d3e 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1321,15 +1321,15 @@ class AnswerPaper(models.Model):
'weight': 0.0}
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():
+ expected_answer = question.get_test_case(correct=True).id
+ if user_answer.strip() == str(expected_answer).strip():
result['success'] = True
result['error'] = ['Correct answer']
elif question.type == 'mcc':
expected_answers = []
for opt in question.get_test_cases(correct=True):
- expected_answers.append(opt.options)
+ expected_answers.append(str(opt.id))
if set(user_answer) == set(expected_answers):
result['success'] = True
result['error'] = ['Correct answer']
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 2038210..37bc788 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -236,7 +236,7 @@ Status : Passed
Error: | {{error.error_msg}} |