From cbdeb90a756832c71c80bac4dbe9ba1a3aceacb2 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Fri, 16 Jan 2015 16:47:43 +0530 Subject: added view, urls for assignment upload & changed the model --- testapp/exam/models.py | 1 - testapp/exam/templates/exam/question.html | 11 +++++++++++ testapp/exam/urls.py | 1 + testapp/exam/views.py | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) (limited to 'testapp/exam') diff --git a/testapp/exam/models.py b/testapp/exam/models.py index 2386cd2..1cafa89 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -389,6 +389,5 @@ class AnswerPaper(models.Model): ################################################################################ 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/templates/exam/question.html b/testapp/exam/templates/exam/question.html index 855a29e..f8888b1 100644 --- a/testapp/exam/templates/exam/question.html +++ b/testapp/exam/templates/exam/question.html @@ -95,6 +95,17 @@ function setSnippetHeight() {% endif %}

+ + {% if question.type == "bash assignment" %} +
+

Upload assignment file for the said question

+ +


+
   + +
+ {% endif %} +
{% csrf_token %} {% if question.type == "mcq" %} diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py index 6aa395c..e32b7e1 100644 --- a/testapp/exam/urls.py +++ b/testapp/exam/urls.py @@ -11,6 +11,7 @@ urlpatterns = patterns('testapp.exam.views', url(r'^intro/(?P\d+)/$','intro'), url(r'^complete/$', 'complete'), url(r'^complete/(?P\d+)/(?P\d+)/$', 'complete'), + url(r'^submit-assignment(?P\d+)/$', 'submit_assignment'), url(r'^register/$', 'user_register'), url(r'^(?P\d+)/$', 'question'), url(r'^(?P\d+)/check/$', 'check'), diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 8fde7a7..9902b74 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -1189,3 +1189,19 @@ def design_questionpaper(request): context = {'form': form} return my_render_to_response('exam/design_questionpaper.html', context, context_instance=ci) + + +def submit_assignment(request, question_id=None): + user = request.user + skip = request.POST.get('skip', None) + if request.method == "POST" and skip is not None: + question = Question.objects.get(id=question_id) + assignment = AssignmentUpload() + assignment.user = user + assignment.assignmentQuestion = question + assignment.assignmentFile = request.FILES['assignment'] + assignment.save() + #next question ke liye code idhar + else: + #code for skipping the question + -- cgit