summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2017-04-19 12:54:41 +0530
committeradityacp2017-04-19 12:54:41 +0530
commitdeaa592f01d5f270abca89c78620af1406fee67c (patch)
tree54119e736fa3dd56935b83c8a93b4b7b17ee0c75 /yaksh/models.py
parentf8613224a26f077ffa48ed8420278950293a3a16 (diff)
downloadonline_test-deaa592f01d5f270abca89c78620af1406fee67c.tar.gz
online_test-deaa592f01d5f270abca89c78620af1406fee67c.tar.bz2
online_test-deaa592f01d5f270abca89c78620af1406fee67c.zip
Change urls, models, views
- Add Assignment upload model manager - Change views to update marks for user if updated manually - Change variable names in views - Add url to provide assignment download for student
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 5ec3062..6646615 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1306,12 +1306,8 @@ class AnswerPaper(models.Model):
.format(u.first_name, u.last_name, q.description)
-###############################################################################
-class AssignmentUpload(models.Model):
- user = models.ForeignKey(User)
- assignmentQuestion = models.ForeignKey(Question)
- assignmentFile = models.FileField(upload_to=get_assignment_dir)
- question_paper = models.ForeignKey(QuestionPaper, blank=True, null=True)
+################################################################################
+class AssignmentUploadManager(models.Manager):
def get_assignments(self, qp, que_id=None, user_id=None):
if que_id and user_id:
@@ -1319,19 +1315,28 @@ class AssignmentUpload(models.Model):
assignmentQuestion_id=que_id, user_id=user_id,
question_paper=qp
)
- user_name = User.objects.get(id=user_id)
- file_name = user_name.get_full_name()
+ file_name = User.objects.get(id=user_id).get_full_name()
else:
assignment_files = AssignmentUpload.objects.filter(
question_paper=qp
)
- file_name = "%s_Assignment_files" %(
+ file_name = "{0}_Assignment_files".format(
assignment_files[0].question_paper.quiz.description
)
return assignment_files, file_name
+
+################################################################################
+class AssignmentUpload(models.Model):
+ user = models.ForeignKey(User)
+ assignmentQuestion = models.ForeignKey(Question)
+ assignmentFile = models.FileField(upload_to=get_assignment_dir)
+ question_paper = models.ForeignKey(QuestionPaper, blank=True, null=True)
+ objects = AssignmentUploadManager()
+
+
###############################################################################
class TestCase(models.Model):
question = models.ForeignKey(Question, blank=True, null=True)