@@ -1706,22 +1706,31 @@ def post(self, request, course_id):
1706
1706
return JsonResponse ({"status" : success_status })
1707
1707
1708
1708
1709
- @transaction .non_atomic_requests
1710
- @require_POST
1711
- @ensure_csrf_cookie
1712
- @cache_control (no_cache = True , no_store = True , must_revalidate = True )
1713
- @require_course_permission (permissions .EXAM_RESULTS )
1714
- @common_exceptions_400
1715
- def get_proctored_exam_results (request , course_id ):
1709
+ @method_decorator (cache_control (no_cache = True , no_store = True , must_revalidate = True ), name = 'dispatch' )
1710
+ @method_decorator (transaction .non_atomic_requests , name = 'dispatch' )
1711
+ class GetProctoredExamResults (DeveloperErrorViewMixin , APIView ):
1716
1712
"""
1717
- get the proctored exam resultsreport for the particular course.
1713
+ get the proctored exam results report for the particular course.
1718
1714
"""
1719
- course_key = CourseKey .from_string (course_id )
1720
- report_type = _ ('proctored exam results' )
1721
- task_api .submit_proctored_exam_results_report (request , course_key )
1722
- success_status = SUCCESS_MESSAGE_TEMPLATE .format (report_type = report_type )
1723
1715
1724
- return JsonResponse ({"status" : success_status })
1716
+ permission_classes = (IsAuthenticated , permissions .InstructorPermission )
1717
+ permission_name = permissions .EXAM_RESULTS
1718
+
1719
+ @method_decorator (ensure_csrf_cookie )
1720
+ @method_decorator (transaction .non_atomic_requests )
1721
+ def post (self , request , course_id ):
1722
+ """
1723
+ get the proctored exam results report for the particular course.
1724
+ """
1725
+ try :
1726
+ course_key = CourseKey .from_string (course_id )
1727
+ report_type = _ ('proctored exam results' )
1728
+ task_api .submit_proctored_exam_results_report (request , course_key )
1729
+ success_status = SUCCESS_MESSAGE_TEMPLATE .format (report_type = report_type )
1730
+ return JsonResponse ({"status" : success_status })
1731
+ except (AlreadyRunningError , QueueConnectionError , AttributeError ) as error :
1732
+ # Return a 400 status code with the error message
1733
+ return JsonResponse ({"error" : str (error )}, status = 400 )
1725
1734
1726
1735
1727
1736
@method_decorator (cache_control (no_cache = True , no_store = True , must_revalidate = True ), name = 'dispatch' )
0 commit comments