From 140b6c6a06269cc39eae192605f623c7818e9260 Mon Sep 17 00:00:00 2001 From: mahesh Date: Fri, 16 Feb 2018 16:30:55 +0530 Subject: Add shuffle_testcases to QuestionPaper model instead of Question --- yaksh/models.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 0bb1e66..8e0bb4d 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -818,10 +818,6 @@ class Question(models.Model): #Solution for the question. solution = models.TextField(blank=True) - # Shuffle testcase order. - shuffle_testcases = models.BooleanField("Shuffle testcase for each user", - default=False - ) def consolidate_answer_data(self, user_answer, user=None): question_data = {} @@ -1151,6 +1147,11 @@ class QuestionPaper(models.Model): # Sequence or Order of fixed questions fixed_question_order = models.CharField(max_length=255, blank=True) + # Shuffle testcase order. + shuffle_testcases = models.BooleanField("Shuffle testcase for each user", + default=True + ) + objects = QuestionPaperManager() def get_question_bank(self): @@ -1218,7 +1219,8 @@ class QuestionPaper(models.Model): for question in questions: question_ids.append(str(question.id)) testcases = question.get_test_cases() - if question.shuffle_testcases: + if self.shuffle_testcases and \ + question.type in ["mcq", "mcc"]: random.shuffle(testcases) testcases_ids = ",".join([str(tc.id) for tc in testcases]) testcases_order = TestCaseOrder.objects.create( -- cgit