summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authormahesh2016-05-02 17:58:31 +0530
committermahesh2016-05-04 11:52:01 +0530
commit4341bf83f9eef904a9dd5f515dd0159f9c05de7d (patch)
treeca6f15efba363c421596c225acf4f145f8f1cc74 /yaksh/models.py
parentf3379350276ecd73f4856c4fca006ffb1e857066 (diff)
downloadonline_test-4341bf83f9eef904a9dd5f515dd0159f9c05de7d.tar.gz
online_test-4341bf83f9eef904a9dd5f515dd0159f9c05de7d.tar.bz2
online_test-4341bf83f9eef904a9dd5f515dd0159f9c05de7d.zip
added get_user_data in answerpaper manager method
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 4029579..f3b8e52 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -518,6 +518,23 @@ class AnswerPaperManager(models.Manager):
return self.filter(question_paper=questionpaper, user=user)\
.order_by('-attempt_number')
+ def get_user_data(self, user, questionpaper_id, attempt_number = None):
+
+ if attempt_number is not None:
+ papers = self.filter( user=user, question_paper_id=questionpaper_id,
+ attempt_number = attempt_number)
+ else:
+ papers = self.filter(user=user, question_paper_id=questionpaper_id)\
+ .order_by("-attempt_number")
+
+ data = {}
+ profile = user.profile if hasattr(user, 'profile') else None
+ data['user'] = user
+ data['profile'] = profile
+ data['papers'] = papers
+ data['questionpaperid'] = questionpaper_id
+ return data
+
###############################################################################
class AnswerPaper(models.Model):
@@ -692,6 +709,8 @@ class AnswerPaper(models.Model):
if question.type == 'code':
return self.answers.filter(question=question).order_by('-id')
+
+
def __unicode__(self):
u = self.user
return u'Question paper for {0} {1}'.format(u.first_name, u.last_name)
@@ -719,4 +738,3 @@ class TestCase(models.Model):
# Test case Expected answer in list form
expected_answer = models.TextField(blank=True, null = True)
-#################################################################################