diff options
author | adityacp | 2020-09-17 13:59:08 +0530 |
---|---|---|
committer | adityacp | 2020-09-17 13:59:08 +0530 |
commit | 45351763f76d75672419b8575f0a1561ee3a8a53 (patch) | |
tree | 8bbfc742f54a7f98f856d050e199a232d136b718 /yaksh/models.py | |
parent | a9a8f286767468a55709215fbe584157f32a7300 (diff) | |
parent | c9d0d238cd201310e5e6da546f518675f7a12440 (diff) | |
download | online_test-45351763f76d75672419b8575f0a1561ee3a8a53.tar.gz online_test-45351763f76d75672419b8575f0a1561ee3a8a53.tar.bz2 online_test-45351763f76d75672419b8575f0a1561ee3a8a53.zip |
Merge branch 'master' of https://github.com/FOSSEE/online_test into add_in_video_questions
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 9f8c634..95a5da0 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -2338,6 +2338,17 @@ class AnswerPaper(models.Model): 'answer': answer, 'error_list': [e for e in json.loads(answer.error)] }] + + for question, answers in q_a.items(): + answers = q_a[question] + q_a[question].append({ + 'marks': max([ + answer['answer'].marks + for answer in answers + if question == answer['answer'].question + ]) + }) + return q_a def get_latest_answer(self, question_id): @@ -2347,7 +2358,7 @@ class AnswerPaper(models.Model): return self.questions.filter(active=True) def get_questions_answered(self): - return self.questions_answered.all() + return self.questions_answered.all().distinct() def get_questions_unanswered(self): return self.questions_unanswered.all() @@ -2546,7 +2557,7 @@ class AssignmentUploadManager(models.Manager): class AssignmentUpload(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) assignmentQuestion = models.ForeignKey(Question, on_delete=models.CASCADE) - assignmentFile = models.FileField(upload_to=get_assignment_dir) + assignmentFile = models.FileField(upload_to=get_assignment_dir, max_length=255) question_paper = models.ForeignKey(QuestionPaper, blank=True, null=True, on_delete=models.CASCADE) course = models.ForeignKey(Course, null=True, blank=True, |