diff options
author | Prabhu Ramachandran | 2017-01-18 16:13:53 +0530 |
---|---|---|
committer | GitHub | 2017-01-18 16:13:53 +0530 |
commit | e75d5e67bc129c0d55ce94496ef4636c80dba0eb (patch) | |
tree | 9e610b5436165458be16ae7aa45857b292643bd8 /yaksh/models.py | |
parent | c3205b84ebd1796d98e140952802cdc0baad19a7 (diff) | |
parent | 1f66352c1f26eb0688ae0884781e6a6a66d43b18 (diff) | |
download | online_test-e75d5e67bc129c0d55ce94496ef4636c80dba0eb.tar.gz online_test-e75d5e67bc129c0d55ce94496ef4636c80dba0eb.tar.bz2 online_test-e75d5e67bc129c0d55ce94496ef4636c80dba0eb.zip |
Merge pull request #181 from maheshgudi/mcq_bugfix
Course CSV Download and Correct option(s) in view answerpaper
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index ad61872..8d4f930 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -221,6 +221,12 @@ class Course(models.Model): success = False return success + def get_only_students(self): + teachers = list(self.teachers.all().values_list("id", flat=True)) + teachers.append(self.creator.id) + students = self.students.exclude(id__in=teachers) + return students + def __str__(self): return self.name @@ -900,6 +906,13 @@ class AnswerPaperManager(models.Manager): data['questionpaperid'] = questionpaper_id return data + def get_user_best_of_attempts_marks(self, quiz, user_id): + best_attempt = 0.0 + papers = self.filter(question_paper__quiz=quiz, + user=user_id).values("marks_obtained") + if papers: + best_attempt = max([marks["marks_obtained"] for marks in papers]) + return best_attempt ############################################################################### class AnswerPaper(models.Model): |