summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testapp/exam/models.py1
-rw-r--r--testapp/exam/templates/exam/question.html11
-rw-r--r--testapp/exam/urls.py1
-rw-r--r--testapp/exam/views.py16
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>&nbsp;&nbsp;
+ <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
+