From 9a2717b662c7dd3fca54e8b8f2e526454ad72d83 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Fri, 19 Feb 2021 15:05:42 +0530 Subject: Fix upload assignment issue for multiple attempts --- yaksh/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 1965191..ceebda6 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -722,7 +722,7 @@ def show_question(request, question, paper, error_message=None, assignmentQuestion_id=question.id, course_id=course_id, user=request.user, - question_paper_id=paper.question_paper_id + answer_paper=paper ) files = FileUpload.objects.filter(question_id=question.id, hide=False) course = Course.objects.get(id=course_id) @@ -861,7 +861,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, assignment_files = AssignmentUpload.objects.filter( assignmentQuestion=current_question, course_id=course_id, assignmentFile__icontains=fname, user=user, - question_paper=questionpaper_id) + answer_paper=paper.id) if assignment_files.exists(): assign_file = assignment_files.first() if os.path.exists(assign_file.assignmentFile.path): @@ -870,7 +870,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, AssignmentUpload.objects.create( user=user, assignmentQuestion=current_question, course_id=course_id, - assignmentFile=fname, question_paper_id=questionpaper_id + assignmentFile=fname, answer_paper_id=paper.id ) user_answer = 'ASSIGNMENT UPLOADED' if not current_question.grade_assignment_upload: -- cgit From 3e23a631e9c8e25fd13c7f1f8b0fed54d0c34b8f Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Fri, 26 Feb 2021 08:37:27 +0530 Subject: Fix assignment download on grade user interface --- yaksh/views.py | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index ceebda6..7d4f788 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -720,8 +720,6 @@ def show_question(request, question, paper, error_message=None, if question.type == 'upload': assignment_files = AssignmentUpload.objects.filter( assignmentQuestion_id=question.id, - course_id=course_id, - user=request.user, answer_paper=paper ) files = FileUpload.objects.filter(question_id=question.id, hide=False) @@ -856,22 +854,15 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, course_id=course_id, module_id=module_id, previous_question=current_question ) + uploaded_files = [] for fname in assignment_filename: fname._name = fname._name.replace(" ", "_") - assignment_files = AssignmentUpload.objects.filter( - assignmentQuestion=current_question, course_id=course_id, - assignmentFile__icontains=fname, user=user, - answer_paper=paper.id) - if assignment_files.exists(): - assign_file = assignment_files.first() - if os.path.exists(assign_file.assignmentFile.path): - os.remove(assign_file.assignmentFile.path) - assign_file.delete() - AssignmentUpload.objects.create( - user=user, assignmentQuestion=current_question, - course_id=course_id, - assignmentFile=fname, answer_paper_id=paper.id - ) + uploaded_files.append(AssignmentUpload( + assignmentQuestion=current_question, + assignmentFile=fname, + answer_paper_id=paper.id + )) + AssignmentUpload.objects.bulk_create(uploaded_files) user_answer = 'ASSIGNMENT UPLOADED' if not current_question.grade_assignment_upload: new_answer = Answer( @@ -1874,6 +1865,8 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None, and update all their marks and also give comments for each paper. """ current_user = request.user + papers = AnswerPaper.objects.filter(user=current_user) + print('Paper: ', papers) if not is_moderator(current_user): raise Http404('You are not allowed to view this page!') if not course_id: @@ -1898,7 +1891,8 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None, course.is_teacher(current_user): raise Http404('This course does not belong to you') has_quiz_assignments = AssignmentUpload.objects.filter( - course_id=course_id, question_paper_id__in=questionpaper_id + answer_paper__course_id=course_id, + answer_paper__question_paper_id__in=questionpaper_id ).exists() context = { "users": user_details, @@ -1917,9 +1911,11 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None, attempt_number = attempts[0].attempt_number except IndexError: raise Http404('No attempts for paper') + has_user_assignments = AssignmentUpload.objects.filter( - course_id=course_id, question_paper_id__in=questionpaper_id, - user_id=user_id + answer_paper__course_id=course_id, + answer_paper__question_paper_id__in=questionpaper_id, + answer_paper__user_id=user_id ).exists() user = User.objects.get(id=user_id) data = AnswerPaper.objects.get_user_data( @@ -2383,7 +2379,7 @@ def download_assignment_file(request, quiz_id, course_id, zipfile_name = string_io() zip_file = zipfile.ZipFile(zipfile_name, "w") for f_name in assignment_files: - folder = f_name.user.get_full_name().replace(" ", "_") + folder = f_name.answer_paper.user.get_full_name().replace(" ", "_") sub_folder = f_name.assignmentQuestion.summary.replace(" ", "_") folder_name = os.sep.join((folder, sub_folder, os.path.basename( f_name.assignmentFile.name)) -- cgit From 3523fea7d001d3e9ecdd9d87b94121b8c8e75ef0 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Mon, 1 Mar 2021 15:24:33 +0530 Subject: Fix failing testcases in Travis --- yaksh/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 7d4f788..ea18541 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2182,8 +2182,8 @@ def view_answerpaper(request, questionpaper_id, course_id): data = AnswerPaper.objects.get_user_data(user, questionpaper_id, course_id) has_user_assignments = AssignmentUpload.objects.filter( - user=user, course_id=course.id, - question_paper_id=questionpaper_id + answer_paper__user=user, answer_paper__course_id=course.id, + answer_paper__question_paper_id=questionpaper_id ).exists() context = {'data': data, 'quiz': quiz, 'course_id': course.id, "has_user_assignments": has_user_assignments} -- cgit From 085b1fae43a16cff87e1ab0cf3730e84d4943442 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Wed, 3 Mar 2021 23:55:24 +0530 Subject: Fix failing test --- yaksh/views.py | 1 - 1 file changed, 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index ea18541..3cff7f5 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1866,7 +1866,6 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None, """ current_user = request.user papers = AnswerPaper.objects.filter(user=current_user) - print('Paper: ', papers) if not is_moderator(current_user): raise Http404('You are not allowed to view this page!') if not course_id: -- cgit