diff options
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 0d8e7fe..d2a85f6 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -81,10 +81,6 @@ def has_profile(user): def get_upload_dir(instance, filename): return "question_%s/%s" % (instance.question.id, filename) -def get_quiz_instructions_info(): - file_path = os.path.join(os.getcwd(), "Quiz_instructions.txt") - with open(file_path, 'r') as file: - return file.read() ############################################################################### class CourseManager(models.Manager): @@ -317,17 +313,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): @@ -553,7 +546,7 @@ class Quiz(models.Model): is_trial = models.BooleanField(default=False) instructions = models.TextField('Instructions for Students', - default=get_quiz_instructions_info) + default=None, blank=True, null=True) view_answerpaper = models.BooleanField('Allow student to view their answer\ paper', default=False) @@ -1154,19 +1147,22 @@ class TestCase(models.Model): class StandardTestCase(TestCase): test_case = models.TextField() weight = models.FloatField(default=1.0) + test_case_args = models.TextField(help_text="<b>Command Line arguments for bash only</b>", + blank=True) def get_field_value(self): return {"test_case_type": "standardtestcase", "test_case": self.test_case, - "weight": self.weight} + "weight": self.weight, + "test_case_args": self.test_case_args} def __str__(self): return u'Standard TestCase | Test Case: {0}'.format(self.test_case) 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): |