summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index e25fd81..1eca721 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1457,9 +1457,12 @@ class QuestionPaper(models.Model):
random.shuffle(testcases)
testcases_ids = ",".join([str(tc.id) for tc in testcases]
)
- TestCaseOrder.objects.create(
- answer_paper=ans_paper, question=question,
- order=testcases_ids)
+ if not TestCaseOrder.objects.filter(
+ answer_paper=ans_paper, question=question
+ ).exists():
+ TestCaseOrder.objects.create(
+ answer_paper=ans_paper, question=question,
+ order=testcases_ids)
ans_paper.questions_order = ",".join(question_ids)
ans_paper.save()
@@ -2297,4 +2300,7 @@ class TestCaseOrder(models.Model):
order = models.TextField()
+ class Meta:
+ unique_together = ("answer_paper", "question", "order")
+
##############################################################################