summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-11-07 19:28:42 +0530
committerGitHub2017-11-07 19:28:42 +0530
commite65b605e59c1384ad9607c99484107929248f220 (patch)
tree798dc730344fa6ea16f1c81b981c218ea5e6abd9 /yaksh/models.py
parenta89ddbacb3b3cf48168281cb41ea61b127c9410c (diff)
parent2eee8fa300a4776647a7be7fdb9dee082f4d6fd8 (diff)
downloadonline_test-e65b605e59c1384ad9607c99484107929248f220.tar.gz
online_test-e65b605e59c1384ad9607c99484107929248f220.tar.bz2
online_test-e65b605e59c1384ad9607c99484107929248f220.zip
Merge pull request #373 from prathamesh920/detailed_csv_download_quiz
Detailed csv download quiz
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index d02b6d6..cb9b481 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -840,6 +840,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,
@@ -1201,6 +1208,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()