@@ -2710,22 +2710,36 @@ def list_financial_report_downloads(_request, course_id):
2710
2710
return JsonResponse (response_payload )
2711
2711
2712
2712
2713
- @transaction .non_atomic_requests
2714
- @require_POST
2715
- @ensure_csrf_cookie
2716
- @cache_control (no_cache = True , no_store = True , must_revalidate = True )
2717
- @require_course_permission (permissions .CAN_RESEARCH )
2718
- @common_exceptions_400
2719
- def export_ora2_data (request , course_id ):
2713
+ @method_decorator (transaction .non_atomic_requests , name = 'dispatch' )
2714
+ class ExportOra2DataView (DeveloperErrorViewMixin , APIView ):
2720
2715
"""
2721
2716
Pushes a Celery task which will aggregate ora2 responses for a course into a .csv
2722
2717
"""
2723
- course_key = CourseKey .from_string (course_id )
2724
- report_type = _ ('ORA data' )
2725
- task_api .submit_export_ora2_data (request , course_key )
2726
- success_status = SUCCESS_MESSAGE_TEMPLATE .format (report_type = report_type )
2718
+ permission_classes = (IsAuthenticated , permissions .InstructorPermission )
2719
+ permission_name = permissions .CAN_RESEARCH
2727
2720
2728
- return JsonResponse ({"status" : success_status })
2721
+ @method_decorator (cache_control (no_cache = True , no_store = True , must_revalidate = True ))
2722
+ @method_decorator (ensure_csrf_cookie )
2723
+ def post (self , request , course_id ):
2724
+ """
2725
+ Initiates a task to export Open Response Assessment (ORA) data for a course.
2726
+
2727
+ Args:
2728
+ request: The HTTP request object
2729
+ course_id: The ID of the course for which to export ORA data
2730
+
2731
+ Returns:
2732
+ Response: A JSON response containing the status message indicating the task has been initiated
2733
+ """
2734
+ course_key = CourseKey .from_string (course_id )
2735
+ report_type = _ ('ORA data' )
2736
+
2737
+ try :
2738
+ task_api .submit_export_ora2_data (request , course_key )
2739
+ success_status = SUCCESS_MESSAGE_TEMPLATE .format (report_type = report_type )
2740
+ return Response ({"status" : success_status })
2741
+ except (AlreadyRunningError , QueueConnectionError , AttributeError ) as err :
2742
+ return JsonResponse ({"error" : str (err )}, status = 400 )
2729
2743
2730
2744
2731
2745
@transaction .non_atomic_requests
0 commit comments