Skip to content

Commit a1edf7a

Browse files
committed
feat: export ora2 summary to DRF
1 parent 334c0fe commit a1edf7a

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

lms/djangoapps/instructor/views/api.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,22 +2723,33 @@ def export_ora2_data(request, course_id):
27232723
return JsonResponse({"status": success_status})
27242724

27252725

2726-
@transaction.non_atomic_requests
2727-
@require_POST
2728-
@ensure_csrf_cookie
2729-
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
2730-
@require_course_permission(permissions.CAN_RESEARCH)
2731-
@common_exceptions_400
2732-
def export_ora2_summary(request, course_id):
2726+
@method_decorator(transaction.non_atomic_requests, name='dispatch')
2727+
class ExportOra2SummaryView(DeveloperErrorViewMixin, APIView):
27332728
"""
2734-
Pushes a Celery task which will aggregate a summary students' progress in ora2 tasks for a course into a .csv
2729+
Pushes a Celery task which will aggregate a summary of students' progress in ora2 tasks for a course into a .csv
27352730
"""
2736-
course_key = CourseKey.from_string(course_id)
2737-
report_type = _('ORA summary')
2738-
task_api.submit_export_ora2_summary(request, course_key)
2739-
success_status = SUCCESS_MESSAGE_TEMPLATE.format(report_type=report_type)
2731+
permission_classes = (IsAuthenticated, permissions.InstructorPermission)
2732+
permission_name = permissions.CAN_RESEARCH
27402733

2741-
return JsonResponse({"status": success_status})
2734+
@method_decorator(ensure_csrf_cookie)
2735+
@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True))
2736+
def post(self, request, course_id):
2737+
"""
2738+
Initiates a Celery task to generate an ORA summary report for the specified course.
2739+
2740+
Args:
2741+
request: The HTTP request object
2742+
course_id: The string representation of the course key
2743+
2744+
Returns:
2745+
Response: A JSON response with a status message indicating the report generation has started
2746+
"""
2747+
course_key = CourseKey.from_string(course_id)
2748+
report_type = _('ORA summary')
2749+
task_api.submit_export_ora2_summary(request, course_key)
2750+
success_status = SUCCESS_MESSAGE_TEMPLATE.format(report_type=report_type)
2751+
2752+
return Response({"status": success_status})
27422753

27432754

27442755
@transaction.non_atomic_requests

lms/djangoapps/instructor/views/api_urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
# Reports..
6868
path('get_course_survey_results', api.GetCourseSurveyResults.as_view(), name='get_course_survey_results'),
6969
path('export_ora2_data', api.export_ora2_data, name='export_ora2_data'),
70-
path('export_ora2_summary', api.export_ora2_summary, name='export_ora2_summary'),
70+
path('export_ora2_summary', api.ExportOra2SummaryView.as_view(), name='export_ora2_summary'),
7171

7272
path('export_ora2_submission_files', api.export_ora2_submission_files,
7373
name='export_ora2_submission_files'),

0 commit comments

Comments
 (0)