diff options
-rw-r--r-- | yaksh/models.py | 4 | ||||
-rw-r--r-- | yaksh/views.py | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 9134663..4dcd2ec 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -66,7 +66,7 @@ test_status = ( def get_assignment_dir(instance, filename): return os.sep.join(( - str(instance.user.user), str(instance.assignmentQuestion.id), filename + instance.user.username, str(instance.assignmentQuestion.id), filename )) @@ -1145,7 +1145,7 @@ class AnswerPaper(models.Model): if set(user_answer) == set(expected_answers): result['success'] = True result['error'] = ['Correct answer'] - elif question.type == 'code': + elif question.type == 'code' or question.type == "upload": user_dir = self.user.profile.get_user_dir() json_result = code_server.run_code( question.language, json_data, user_dir 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'] / |