From e937c2a3a17bfc127af89a86e213e434350cd360 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 15 Mar 2017 18:12:31 +0530 Subject: Change assignment dir path and add condition for json data --- yaksh/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 4cdba5c..d4d11f5 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -473,8 +473,10 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): assignment_filename = request.FILES.getlist('assignment') for fname in assignment_filename: if AssignmentUpload.objects.filter( + assignmentQuestion=current_question, assignmentFile__icontains=fname, user=user).exists(): assign_file = AssignmentUpload.objects.get( + assignmentQuestion=current_question, assignmentFile__icontains=fname, user=user) os.remove(assign_file.assignmentFile.path) assign_file.delete() @@ -499,7 +501,8 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): # questions, we obtain the results via XML-RPC with the code executed # safely in a separate process (the code_server.py) running as nobody. json_data = current_question.consolidate_answer_data(user_answer) \ - if current_question.type == 'code' else None + if current_question.type == 'code' or \ + current_question.type == 'upload' else None result = paper.validate_answer(user_answer, current_question, json_data) if result.get('success'): new_answer.marks = (current_question.points * result['weight'] / -- cgit