diff options
author | prathamesh | 2017-10-26 14:35:08 +0530 |
---|---|---|
committer | prathamesh | 2017-10-26 14:35:08 +0530 |
commit | 1f554e7505f5a6aa1b796b2e31e1541188af56da (patch) | |
tree | cbe0f88b2dd7dd8ef37f391f89bb8f578cae40e0 /yaksh/models.py | |
parent | 97a277cf5b86f60525f94302d5b04de420ad7212 (diff) | |
download | online_test-1f554e7505f5a6aa1b796b2e31e1541188af56da.tar.gz online_test-1f554e7505f5a6aa1b796b2e31e1541188af56da.tar.bz2 online_test-1f554e7505f5a6aa1b796b2e31e1541188af56da.zip |
CSV download for quiz enhanced
CSV download for a quiz now shows question wise grades.
Also, for a given attempt all the users from the course are entered in
the CSV. If the user has not attempted then a dash '-' is put under the
grades.
Also, handles random questions, if a question paper has questions
selected from pool of questions then all the questions are entered in
the CSV. 'NA' is put under the question grade if that question has not
come in the question/answer paper for that given user.
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 787daa6..97f2f0b 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -826,6 +826,13 @@ class QuestionPaper(models.Model): objects = QuestionPaperManager() + def get_question_bank(self): + ''' Gets all the questions in the question paper''' + questions = list(self.fixed_questions.all()) + for random_set in self.random_questions.all(): + questions += list(random_set.questions.all()) + return questions + def _create_duplicate_questionpaper(self, quiz): new_questionpaper = QuestionPaper.objects.create(quiz=quiz, shuffle_questions=self.shuffle_questions, @@ -1185,6 +1192,15 @@ class AnswerPaper(models.Model): objects = AnswerPaperManager() + def get_per_question_score(self, question_id): + if question_id not in self.get_questions().values_list('id', flat=True): + return 'NA' + answer = self.get_latest_answer(question_id) + if answer: + return answer.marks + else: + return 0 + def current_question(self): """Returns the current active question to display.""" unanswered_questions = self.questions_unanswered.all() |