summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2017-04-10 16:15:59 +0530
committeradityacp2017-04-10 17:14:40 +0530
commit5623c1225f66831d5e5db2089218b7904c3124b6 (patch)
treede595d7b16794670075bac3564e5f3e3c89830bb /yaksh
parent32911e9a094e7f91ca132f98927d110049c99401 (diff)
downloadonline_test-5623c1225f66831d5e5db2089218b7904c3124b6.tar.gz
online_test-5623c1225f66831d5e5db2089218b7904c3124b6.tar.bz2
online_test-5623c1225f66831d5e5db2089218b7904c3124b6.zip
Change download assignemnts to get files using quiz
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py8
-rw-r--r--yaksh/templates/yaksh/grade_user.html2
-rw-r--r--yaksh/urls.py4
-rw-r--r--yaksh/views.py25
4 files changed, 20 insertions, 19 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 2d3aadb..5ec3062 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1313,17 +1313,17 @@ class AssignmentUpload(models.Model):
assignmentFile = models.FileField(upload_to=get_assignment_dir)
question_paper = models.ForeignKey(QuestionPaper, blank=True, null=True)
- def get_assignments(self, qp_id, que_id=None, user_id=None):
+ def get_assignments(self, qp, que_id=None, user_id=None):
if que_id and user_id:
assignment_files = AssignmentUpload.objects.filter(
assignmentQuestion_id=que_id, user_id=user_id,
- question_paper_id=qp_id
+ question_paper=qp
)
user_name = User.objects.get(id=user_id)
- file_name = user_name.get_full_name().replace(" ", "_")
+ file_name = user_name.get_full_name()
else:
assignment_files = AssignmentUpload.objects.filter(
- question_paper_id=qp_id
+ question_paper=qp
)
file_name = "%s_Assignment_files" %(
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 69c03c9..311af5c 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -165,7 +165,7 @@ Status : <b style="color: green;"> Passed </b><br/>
<h5>Student answer: </h5>
{% if question.type == "upload" %}
{% if user_file_status %}
- <a href="{{URL_ROOT}}/exam/manage/download/user_assignment/{{question.id}}/{{data.user.id}}/{{paper.question_paper.id}}">
+ <a href="{{URL_ROOT}}/exam/manage/download/user_assignment/{{question.id}}/{{data.user.id}}/{{paper.question_paper.quiz.id}}">
<div class="panel">
Assignment File for {{ data.user.get_full_name.title }}
</div>
diff --git a/yaksh/urls.py b/yaksh/urls.py
index 445b828..4a96d08 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -91,8 +91,8 @@ urlpatterns = [
url(r'^manage/create_demo_course/$', views.create_demo_course),
url(r'^manage/courses/download_course_csv/(?P<course_id>\d+)/$',
views.download_course_csv),
- url(r'^manage/download/user_assignment/(?P<question_id>\d+)/(?P<user_id>\d+)/(?P<questionpaper_id>\d+)/$',
+ url(r'^manage/download/user_assignment/(?P<question_id>\d+)/(?P<user_id>\d+)/(?P<quiz_id>\d+)/$',
views.download_assignment_file),
- url(r'^manage/download/quiz_assignments/(?P<questionpaper_id>\d+)/$',
+ url(r'^manage/download/quiz_assignments/(?P<quiz_id>\d+)/$',
views.download_assignment_file)
]
diff --git a/yaksh/views.py b/yaksh/views.py
index d0735bd..46a2bdd 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -501,14 +501,15 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
assignment_filename = request.FILES.getlist('assignment')
qp = QuestionPaper.objects.get(id=questionpaper_id)
for fname in assignment_filename:
- if AssignmentUpload.objects.filter(
- assignmentQuestion=current_question,
- assignmentFile__icontains=fname, user=user,
- question_paper=questionpaper_id).exists():
- assign_file = AssignmentUpload.objects.get(
- assignmentQuestion=current_question,
- assignmentFile__icontains=fname, user=user,
- question_paper=questionpaper_id)
+ assignment_files = AssignmentUpload.objects.filter(
+ assignmentQuestion=current_question,
+ assignmentFile__icontains=fname, user=user,
+ question_paper=questionpaper_id)
+ if assignment_files.exists():
+ assign_file = assignment_files.get(
+ assignmentQuestion=current_question,
+ assignmentFile__icontains=fname, user=user,
+ question_paper=questionpaper_id)
os.remove(assign_file.assignmentFile.path)
assign_file.delete()
AssignmentUpload.objects.create(user=user,
@@ -1429,14 +1430,14 @@ def download_course_csv(request, course_id):
@login_required
-def download_assignment_file(request, questionpaper_id, question_id=None,
- user_id=None):
+def download_assignment_file(request, quiz_id, question_id=None, user_id=None):
user = request.user
if not is_moderator(user):
raise Http404('You are not allowed to view this page!')
+ qp = QuestionPaper.objects.get(quiz_id=quiz_id)
assignment = AssignmentUpload()
- assignment_files, file_name = assignment.get_assignments(questionpaper_id,
- question_id, user_id
+ assignment_files, file_name = assignment.get_assignments(qp, question_id,
+ user_id
)
zipfile_name = string_io()
zip_file = zipfile.ZipFile(zipfile_name, "w")