From ba817cda209787e4bc959aac8d16726a8aea1ed9 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 4 Oct 2017 18:58:55 +0530 Subject: Update non-code and non-upload answers instead of creating a new one --- yaksh/models.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index d9e07fd..0d67397 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1284,6 +1284,11 @@ class AnswerPaper(models.Model): }] return q_a + def get_latest_answer(self,question_id): + all_answers = self.answers.filter(question=question_id) + if all_answers: + return all_answers[0] + def get_questions(self): return self.questions.filter(active=True) -- cgit From 88a37e73cabe8f396631132b2cffdddd5bcae17f Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 4 Oct 2017 21:26:12 +0530 Subject: User can see previously submitted answers for non code questions --- yaksh/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 0d67397..49e028b 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1308,8 +1308,7 @@ class AnswerPaper(models.Model): return self.time_left() > 0 def get_previous_answers(self, question): - if question.type == 'code': - return self.answers.filter(question=question).order_by('-id') + return self.answers.filter(question=question).order_by('-id') def validate_answer(self, user_answer, question, json_data=None, uid=None): """ -- cgit From 81a9490e58db3b68fc1385680a080a89c5d68385 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 4 Oct 2017 23:30:24 +0530 Subject: Change get_latest_answer in Answerpaper model to order by id --- yaksh/models.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 49e028b..92076ab 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1284,10 +1284,8 @@ class AnswerPaper(models.Model): }] return q_a - def get_latest_answer(self,question_id): - all_answers = self.answers.filter(question=question_id) - if all_answers: - return all_answers[0] + def get_latest_answer(self, question_id): + return self.answers.filter(question=question_id).order_by("-id").last() def get_questions(self): return self.questions.filter(active=True) -- cgit From 8ea7f10a84af44af37a5478c389fa040723542ec Mon Sep 17 00:00:00 2001 From: King Date: Thu, 5 Oct 2017 01:05:42 +0530 Subject: Will return the last answer submitted --- yaksh/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 92076ab..68bde48 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1285,7 +1285,7 @@ class AnswerPaper(models.Model): return q_a def get_latest_answer(self, question_id): - return self.answers.filter(question=question_id).order_by("-id").last() + return self.answers.filter(question=question_id).order_by("id").last() def get_questions(self): return self.questions.filter(active=True) -- cgit