diff options
author | maheshgudi | 2017-01-18 02:42:29 +0530 |
---|---|---|
committer | maheshgudi | 2017-01-18 02:45:03 +0530 |
commit | f93527f83ff0b6d87cd9ffb10aac3cbb27d08b8a (patch) | |
tree | 303d12dbb3e3c5b5f44563809cbe5010f8d13865 /yaksh/models.py | |
parent | c3205b84ebd1796d98e140952802cdc0baad19a7 (diff) | |
download | online_test-f93527f83ff0b6d87cd9ffb10aac3cbb27d08b8a.tar.gz online_test-f93527f83ff0b6d87cd9ffb10aac3cbb27d08b8a.tar.bz2 online_test-f93527f83ff0b6d87cd9ffb10aac3cbb27d08b8a.zip |
Can download csv of students' performance per course
Moderator can now download the csv dump of the performance of students in each quiz (best attempt of the quiz) for a course.
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index ad61872..31038f1 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -221,6 +221,13 @@ 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 +907,15 @@ 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): |