From 534cc561e22da308e31282ab9c598041558aa1b4 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 14 Jan 2015 13:43:41 +0530 Subject: Added model to store assignment files --- testapp/exam/models.py | 11 +++++++++++ testapp/exam/urls.py | 2 +- testapp/urls.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/testapp/exam/models.py b/testapp/exam/models.py index 259f875..2386cd2 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -41,6 +41,9 @@ test_status = ( ('completed', 'Completed'), ) +def get_assignment_dir(instance, filename): + return '%s/%s/' % (instance.user.roll_number, instance.assignment.description) + ############################################################################### class Question(models.Model): """Question for a quiz.""" @@ -381,3 +384,11 @@ class AnswerPaper(models.Model): def __unicode__(self): u = self.user return u'Question paper for {0} {1}'.format(u.first_name, u.last_name) + + +################################################################################ +class AssignmentUpload(models.Model): + user = models.ForeignKey(Profile) + assignment = models.ForeignKey(Quiz) + assignmentQuestion = models.ForeignKey(Question) + assignmentFile = models.FileField(upload_to=get_assignment_dir) diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py index d71329c..6aa395c 100644 --- a/testapp/exam/urls.py +++ b/testapp/exam/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls.defaults import * urlpatterns = patterns('testapp.exam.views', url(r'^$', 'index'), diff --git a/testapp/urls.py b/testapp/urls.py index 0d126f4..6c19e81 100644 --- a/testapp/urls.py +++ b/testapp/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin -- cgit