summaryrefslogtreecommitdiff
path: root/testapp/exam/models.py
diff options
context:
space:
mode:
authorankitjavalkar2015-04-07 15:34:42 +0530
committerankitjavalkar2015-04-26 19:46:00 +0530
commit11489a740a020f0401ce04c0b1a52f6bef31257e (patch)
tree91e11372a8984fb9ac1836cdf1f66eb9ea7beca4 /testapp/exam/models.py
parent28ba37e907553aeac3841e221853683b9171f0db (diff)
downloadonline_test-11489a740a020f0401ce04c0b1a52f6bef31257e.tar.gz
online_test-11489a740a020f0401ce04c0b1a52f6bef31257e.tar.bz2
online_test-11489a740a020f0401ce04c0b1a52f6bef31257e.zip
Code review - changes as per code review discussion
- make loop in consolidate_test_cases more readable - split signal handler func definition into three seperate func - pass seperate kwargs to TestCode class - unpack json in CodeServer class and then pass to TestCode
Diffstat (limited to 'testapp/exam/models.py')
-rw-r--r--testapp/exam/models.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/testapp/exam/models.py b/testapp/exam/models.py
index 5989be4..706d864 100644
--- a/testapp/exam/models.py
+++ b/testapp/exam/models.py
@@ -63,7 +63,7 @@ class Question(models.Model):
# Answer for MCQs.
solution = models.TextField(blank=True)
- # Test cases file paths
+ # Test cases file paths (comma seperated for reference code path and test case code path)
ref_code_path = models.TextField(blank=True)
# Any multiple choice options. Place one option per line.
@@ -86,27 +86,26 @@ class Question(models.Model):
# Tags for the Question.
tags = TaggableManager()
- def consolidate_answer_data(self, test, user_answer):
+ def consolidate_answer_data(self, test_cases, user_answer): #test
test_case_parameter = []
info_parameter = {}
- for i in test:
+ for test_case in test_cases:
kw_args_dict = {}
pos_args_list = []
parameter_dict = {}
- parameter_dict['test_id'] = i.id
- parameter_dict['func_name'] = i.func_name
- parameter_dict['expected_answer'] = i.expected_answer
- parameter_dict['ref_code_path'] = i.ref_code_path
-
- if i.kw_args:
- for args in i.kw_args.split(","):
- key, val = args.split("=")
- kw_args_dict[key.strip()] = val.strip()
-
- if i.pos_args:
- for args in i.pos_args.split(","):
+ parameter_dict['test_id'] = test_case.id
+ parameter_dict['func_name'] = test_case.func_name
+ parameter_dict['expected_answer'] = test_case.expected_answer
+
+ if test_case.kw_args:
+ for args in test_case.kw_args.split(","):
+ arg_name, arg_value = args.split("=")
+ kw_args_dict[arg_name.strip()] = arg_value.strip()
+
+ if test_case.pos_args:
+ for args in test_case.pos_args.split(","):
pos_args_list.append(args.strip())
parameter_dict['kw_args'] = kw_args_dict