From 1f554e7505f5a6aa1b796b2e31e1541188af56da Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 26 Oct 2017 14:35:08 +0530 Subject: 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. --- yaksh/models.py | 16 ++++++ yaksh/templates/yaksh/monitor.html | 44 +++++++++++++- yaksh/test_models.py | 88 +++++++++++++++++++++++++++- yaksh/test_views.py | 20 ++++--- yaksh/urls.py | 4 +- yaksh/views.py | 115 +++++++++++++++++++++++++------------ 6 files changed, 238 insertions(+), 49 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() diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html index 9ce0dc4..2e7097f 100644 --- a/yaksh/templates/yaksh/monitor.html +++ b/yaksh/templates/yaksh/monitor.html @@ -76,7 +76,10 @@ $(document).ready(function()
Papers in progress: {{ inprogress_papers }}
- ++