summaryrefslogtreecommitdiff
path: root/testapp/exam/models.py
diff options
context:
space:
mode:
authorankitjavalkar2015-02-05 14:28:48 +0530
committerankitjavalkar2015-04-26 19:31:24 +0530
commitecb202633d3b90c55128030adb7817387bf28c95 (patch)
treebc90138ce3e57ce3c2d6db3c845673077145e4c0 /testapp/exam/models.py
parent28e2d32f9839b0e3cb3e99ce0113832627610bd7 (diff)
downloadonline_test-ecb202633d3b90c55128030adb7817387bf28c95.tar.gz
online_test-ecb202633d3b90c55128030adb7817387bf28c95.tar.bz2
online_test-ecb202633d3b90c55128030adb7817387bf28c95.zip
Modify method of passing test case attributes to code server
Conflicts: testapp/exam/admin.py testapp/exam/models.py testapp/exam/views.py
Diffstat (limited to 'testapp/exam/models.py')
-rw-r--r--testapp/exam/models.py75
1 files changed, 63 insertions, 12 deletions
diff --git a/testapp/exam/models.py b/testapp/exam/models.py
index df3b485..4eeceac 100644
--- a/testapp/exam/models.py
+++ b/testapp/exam/models.py
@@ -62,15 +62,6 @@ class Question(models.Model):
# Test cases for the question in the form of code that is run.
test = models.TextField(blank=True)
- #Test case Keyword arguments in dict form
- test_keyword_args = models.TextField(blank=True) ####
-
- #Test case Positional arguments in list form
- test_pos_args = models.TextField(blank=True) ####
-
- #Test case Expected answer in list form
- test_expected_answer = models.TextField(blank=True) ####
-
# Any multiple choice options. Place one option per line.
options = models.TextField(blank=True)
@@ -91,6 +82,34 @@ class Question(models.Model):
# Tags for the Question.
tags = TaggableManager()
+ def consolidate_test_cases(self, test):
+ test_case_parameter= []
+
+ for i in test:
+ 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(","):
+ 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)
+
+ return test_case_parameter
+
def __unicode__(self):
return self.summary
@@ -411,16 +430,48 @@ class AssignmentUpload(models.Model):
class TestCase(models.Model):
question = models.ForeignKey(Question)
+ # Test case function name
+ func_name = models.CharField(max_length=200)
+
# Test case Keyword arguments in dict form
- test_keyword_args = models.TextField(blank=True)
+ kw_args = models.TextField(blank=True)
# Test case Positional arguments in list form
- test_pos_args = models.TextField(blank=True)
+ pos_args = models.TextField(blank=True)
# Test case Expected answer in list form
- test_expected_answer = models.TextField(blank=True)
+ expected_answer = models.TextField(blank=True)
+
+ # Test case path to system test code applicable for CPP, C, Java and Scilab
+ ref_code_path = models.TextField(blank=True)
# Is this Test Case public or not. If it is not
# public it will not be visible to the user
# public = models.BooleanField(default=False)
+ # def consolidate_test_cases(self):
+ # test_case_parameter= {}
+ # kw_args_dict = {}
+ # pos_args_list = []
+
+ # for i in self:
+ # test_case_parameter.setdefault(i.id, {})
+ # test_case_parameter[i.id]['func_name'] = i.func_name
+ # test_case_parameter[i.id]['expected_answer'] = i.expected_answer
+
+ # for args in i.kw_args.split(","):
+ # key, val = args.split("=")
+ # kw_args_dict[key.strip()] = val.strip()
+
+
+ # for args in i.pos_args.split(","):
+ # pos_args_list.append(args.strip())
+
+ # test_case_parameter[i.id]['kw_args'] = kw_args_dict
+ # test_case_parameter[i.id]['pos_args'] = pos_args_list
+
+ # # test_case_parameter[i.id]['kw_args'] = i.kw_args
+ # # test_case_parameter[i.id]['pos_args'] = i.pos_args
+
+ # return test_case_parameter
+