summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormahesh2018-02-07 18:49:08 +0530
committermahesh2018-02-07 19:12:48 +0530
commit2c53d636aa4a3f36586910e1d3ef5276a7efc337 (patch)
tree001129b91cce31f3cadcfce6921a7383d9a669b7 /yaksh
parent782fd83b5931efde8ae26795c65e952df5012d0f (diff)
downloadonline_test-2c53d636aa4a3f36586910e1d3ef5276a7efc337.tar.gz
online_test-2c53d636aa4a3f36586910e1d3ef5276a7efc337.tar.bz2
online_test-2c53d636aa4a3f36586910e1d3ef5276a7efc337.zip
Add course as a unique constraint
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py4
-rw-r--r--yaksh/test_models.py6
2 files changed, 7 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 6a7b800..46cf603 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1496,7 +1496,9 @@ class AnswerPaper(models.Model):
objects = AnswerPaperManager()
class Meta:
- unique_together = ('user', 'question_paper', 'attempt_number')
+ unique_together = ('user', 'question_paper',
+ 'attempt_number', "course"
+ )
def get_per_question_score(self, question_id):
if question_id not in self.get_questions().values_list('id', flat=True):
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 9166a3e..5db0f27 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -774,7 +774,8 @@ class AnswerPaperTestCases(unittest.TestCase):
question_paper=self.question_paper,
start_time=self.start_time,
end_time=self.end_time,
- user_ip=self.ip
+ user_ip=self.ip,
+ course=self.course
)
self.attempted_papers = AnswerPaper.objects.filter(
question_paper=self.question_paper,
@@ -1321,7 +1322,8 @@ class AnswerPaperTestCases(unittest.TestCase):
question_paper=self.answerpaper.question_paper,
attempt_number=self.answerpaper.attempt_number,
start_time=self.answerpaper.start_time,
- end_time=self.answerpaper.end_time
+ end_time=self.answerpaper.end_time,
+ course=self.answerpaper.course
)