summaryrefslogtreecommitdiff
path: root/testapp/exam/models.py
diff options
context:
space:
mode:
authorankitjavalkar2015-03-05 12:27:02 +0530
committerankitjavalkar2015-04-26 19:43:19 +0530
commit9440bff5ae69c1d27f5c9622ca15cb8c603c6174 (patch)
tree761e4c37f02244232ce876233e026f1c0e894ad6 /testapp/exam/models.py
parent8e2469e937fd4f80ebf2053d6e21c9b670d38ea2 (diff)
downloadonline_test-9440bff5ae69c1d27f5c9622ca15cb8c603c6174.tar.gz
online_test-9440bff5ae69c1d27f5c9622ca15cb8c603c6174.tar.bz2
online_test-9440bff5ae69c1d27f5c9622ca15cb8c603c6174.zip
Code Server code cleanup and code commonification
- Pass question and test case info as json string (info_parameter) - Return success status and error message as a json string - Embed user answer and question lang in info_parameter - Commonify Python code evaluations and assertion test - Deprecate individual function call based on language
Diffstat (limited to 'testapp/exam/models.py')
-rw-r--r--testapp/exam/models.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/testapp/exam/models.py b/testapp/exam/models.py
index ea79ad2..dd0c806 100644
--- a/testapp/exam/models.py
+++ b/testapp/exam/models.py
@@ -1,4 +1,5 @@
import datetime
+import json
from random import sample, shuffle
from django.db import models
from django.contrib.auth.models import User
@@ -82,8 +83,9 @@ class Question(models.Model):
# Tags for the Question.
tags = TaggableManager()
- def consolidate_test_cases(self, test):
- test_case_parameter= []
+ def consolidate_answer_data(self, test, user_answer):
+ test_case_parameter = []
+ info_parameter = {}
for i in test:
kw_args_dict = {}
@@ -94,7 +96,6 @@ class Question(models.Model):
parameter_dict['func_name'] = i.func_name
parameter_dict['expected_answer'] = i.expected_answer
parameter_dict['ref_code_path'] = i.ref_code_path
- parameter_dict['language'] = self.language
if i.kw_args:
for args in i.kw_args.split(","):
@@ -109,7 +110,12 @@ class Question(models.Model):
parameter_dict['pos_args'] = pos_args_list
test_case_parameter.append(parameter_dict)
- return test_case_parameter
+ info_parameter['language'] = self.language
+ info_parameter['id'] = self.id
+ info_parameter['user_answer'] = user_answer
+ info_parameter['test_parameter'] = test_case_parameter
+
+ return json.dumps(info_parameter)
def __unicode__(self):
return self.summary