diff options
author | ankitjavalkar | 2015-04-24 14:25:26 +0530 |
---|---|---|
committer | ankitjavalkar | 2015-04-26 21:11:52 +0530 |
commit | 8664a766406d6acf0d6a1688948153c407ea27f2 (patch) | |
tree | 7505ef02b5e36395fc7e92ff5cde7700f2025979 /testapp/exam/models.py | |
parent | 17752a69114e7dbad266337e768013920aec8c0c (diff) | |
download | online_test-8664a766406d6acf0d6a1688948153c407ea27f2.tar.gz online_test-8664a766406d6acf0d6a1688948153c407ea27f2.tar.bz2 online_test-8664a766406d6acf0d6a1688948153c407ea27f2.zip |
Code Review: Code refactoring
- Rename files
- Create function for @classmethod call
- Fix current, add new testcases
- Fix views to fetch solution/ref_code_path fields in question post save
- Fix errors
Diffstat (limited to 'testapp/exam/models.py')
-rw-r--r-- | testapp/exam/models.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/testapp/exam/models.py b/testapp/exam/models.py index d0c9cc2..51e773a 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -88,17 +88,17 @@ class Question(models.Model): tags = TaggableManager() def consolidate_answer_data(self, test_cases, user_answer): - test_case_parameter = [] - info_parameter = {} + test_case_data_dict = [] + question_info_dict = {} for test_case in test_cases: kw_args_dict = {} pos_args_list = [] - parameter_dict = {} - parameter_dict['test_id'] = test_case.id - parameter_dict['func_name'] = test_case.func_name - parameter_dict['expected_answer'] = test_case.expected_answer + test_case_data = {} + test_case_data['test_id'] = test_case.id + test_case_data['func_name'] = test_case.func_name + test_case_data['expected_answer'] = test_case.expected_answer if test_case.kw_args: for args in test_case.kw_args.split(","): @@ -109,17 +109,17 @@ class Question(models.Model): for args in test_case.pos_args.split(","): pos_args_list.append(args.strip()) - parameter_dict['kw_args'] = kw_args_dict - parameter_dict['pos_args'] = pos_args_list - test_case_parameter.append(parameter_dict) + test_case_data['kw_args'] = kw_args_dict + test_case_data['pos_args'] = pos_args_list + test_case_data_dict.append(test_case_data) - # info_parameter['language'] = self.language - info_parameter['id'] = self.id - info_parameter['user_answer'] = user_answer - info_parameter['test_parameter'] = test_case_parameter - info_parameter['ref_code_path'] = self.ref_code_path + # question_info_dict['language'] = self.language + question_info_dict['id'] = self.id + question_info_dict['user_answer'] = user_answer + question_info_dict['test_parameter'] = test_case_data_dict + question_info_dict['ref_code_path'] = self.ref_code_path - return json.dumps(info_parameter) + return json.dumps(question_info_dict) def __unicode__(self): return self.summary |