Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: upgrading get_proctored_exam_results api to DRF ( 32 ) #35612

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,22 +1658,31 @@ def get_course_survey_results(request, course_id):
return JsonResponse({"status": success_status})


@transaction.non_atomic_requests
@require_POST
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_course_permission(permissions.EXAM_RESULTS)
@common_exceptions_400
def get_proctored_exam_results(request, course_id):
@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True), name='dispatch')
@method_decorator(transaction.non_atomic_requests, name='dispatch')
class GetProctoredExamResults(DeveloperErrorViewMixin, APIView):
"""
get the proctored exam resultsreport for the particular course.
get the proctored exam results report for the particular course.
"""
course_key = CourseKey.from_string(course_id)
report_type = _('proctored exam results')
task_api.submit_proctored_exam_results_report(request, course_key)
success_status = SUCCESS_MESSAGE_TEMPLATE.format(report_type=report_type)

return JsonResponse({"status": success_status})
permission_classes = (IsAuthenticated, permissions.InstructorPermission)
permission_name = permissions.EXAM_RESULTS

@method_decorator(ensure_csrf_cookie)
@method_decorator(transaction.non_atomic_requests)
def post(self, request, course_id):
"""
get the proctored exam results report for the particular course.
"""
try:
course_key = CourseKey.from_string(course_id)
report_type = _('proctored exam results')
task_api.submit_proctored_exam_results_report(request, course_key)
success_status = SUCCESS_MESSAGE_TEMPLATE.format(report_type=report_type)
return JsonResponse({"status": success_status})
except AlreadyRunningError as error:
# Return a 400 status code with the error message
return JsonResponse({"error": str(error)}, status=400)


@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True), name='dispatch')
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor/views/api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
path('show_student_extensions', api.ShowStudentExtensions.as_view(), name='show_student_extensions'),

# proctored exam downloads...
path('get_proctored_exam_results', api.get_proctored_exam_results, name='get_proctored_exam_results'),
path('get_proctored_exam_results', api.GetProctoredExamResults.as_view(), name='get_proctored_exam_results'),

# Grade downloads...
path('list_report_downloads', api.ListReportDownloads.as_view(), name='list_report_downloads'),
Expand Down
Loading