diff options
author | hardythe1 | 2015-01-16 16:47:43 +0530 |
---|---|---|
committer | hardythe1 | 2015-01-16 16:47:43 +0530 |
commit | cbdeb90a756832c71c80bac4dbe9ba1a3aceacb2 (patch) | |
tree | ce0aeb69dde2351ac1d1372fdd15dbec94ac9ccc /testapp | |
parent | 534cc561e22da308e31282ab9c598041558aa1b4 (diff) | |
download | online_test-cbdeb90a756832c71c80bac4dbe9ba1a3aceacb2.tar.gz online_test-cbdeb90a756832c71c80bac4dbe9ba1a3aceacb2.tar.bz2 online_test-cbdeb90a756832c71c80bac4dbe9ba1a3aceacb2.zip |
added view, urls for assignment upload & changed the model
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/models.py | 1 | ||||
-rw-r--r-- | testapp/exam/templates/exam/question.html | 11 | ||||
-rw-r--r-- | testapp/exam/urls.py | 1 | ||||
-rw-r--r-- | testapp/exam/views.py | 16 |
4 files changed, 28 insertions, 1 deletions
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() </div>{% endif %} <p id="status"></p> + + {% if question.type == "bash assignment" %} + <form action="{{URL_ROOT}}/exam/submit-assignment/{{ question.id }}/check/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post"> + <p>Upload assignment file for the said question<p> + <input type=file id=assignment name=assignment> + <hr> + <br><button class="btn" type="submit" name="submitassign" id="submitassign">Upload</button> + <button class="btn" type="submit" name="skip" id="skip">Skip</button> + </form> + {% endif %} + <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post"> {% 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<questionpaper_id>\d+)/$','intro'), url(r'^complete/$', 'complete'), url(r'^complete/(?P<attempt_no>\d+)/(?P<questionpaper_id>\d+)/$', 'complete'), + url(r'^submit-assignment(?P<question_id>\d+)/$', 'submit_assignment'), url(r'^register/$', 'user_register'), url(r'^(?P<q_id>\d+)/$', 'question'), url(r'^(?P<q_id>\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 + |