diff options
author | maheshgudi | 2016-12-23 12:18:17 +0530 |
---|---|---|
committer | maheshgudi | 2016-12-23 12:18:17 +0530 |
commit | 5f6b103408ff8a520c741d2d21d1aff24a823dad (patch) | |
tree | 7840a6eb7cfd0e38e9f4c274824855d8f77846af /yaksh/models.py | |
parent | 77e8a6c1cde9190daf9075d71caf6017dc1380e7 (diff) | |
download | online_test-5f6b103408ff8a520c741d2d21d1aff24a823dad.tar.gz online_test-5f6b103408ff8a520c741d2d21d1aff24a823dad.tar.bz2 online_test-5f6b103408ff8a520c741d2d21d1aff24a823dad.zip |
fix error; allows get_test_cases method to fetch multiple test cases model classes.
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6e1744c..d7e5964 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -317,17 +317,14 @@ class Question(models.Model): def get_test_cases(self, **kwargs): tc_list = [] - for tc in self.testcase_set.all(): - test_case_type = tc.type + for tc in self.testcase_set.values_list("type", flat=True).distinct(): test_case_ctype = ContentType.objects.get(app_label="yaksh", - model=test_case_type - ) - test_case = test_case_ctype.get_object_for_this_type( + model=tc) + test_case = test_case_ctype.get_all_objects_for_this_type( question=self, **kwargs ) - tc_list.append(test_case) - + tc_list.extend(test_case) return tc_list def get_test_case(self, **kwargs): @@ -1161,8 +1158,8 @@ class StandardTestCase(TestCase): class StdIOBasedTestCase(TestCase): - expected_input = models.CharField(max_length=100, blank=True) - expected_output = models.CharField(max_length=100) + expected_input = models.TextField(max_length=100, blank=True) + expected_output = models.TextField(max_length=100) weight = models.IntegerField(default=1.0) def get_field_value(self): @@ -1172,9 +1169,9 @@ class StdIOBasedTestCase(TestCase): "weight": self.weight} def __str__(self): - return u'Question: {0} | Exp. Output: {1} | Exp. Input: {2}'.format(self.question, - self.expected_output, self.expected_input - ) + return u'Question: {0} | Exp. Output: {1} | Exp. Input: {2}'\ + .format(self.question, self.expected_output, + self.expected_input) class McqTestCase(TestCase): |