summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authoradityacp2017-04-10 16:15:59 +0530
committeradityacp2017-04-10 17:14:40 +0530
commit5623c1225f66831d5e5db2089218b7904c3124b6 (patch)
treede595d7b16794670075bac3564e5f3e3c89830bb /yaksh/views.py
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/views.py')
-rw-r--r--yaksh/views.py25
1 files changed, 13 insertions, 12 deletions
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")