Skip to content

Commit

Permalink
feat!: upgrading api to DRF. (openedx#35609)
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 authored Feb 17, 2025
1 parent 87a5611 commit cba02f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,22 +1683,27 @@ def post(self, request, course_key_string):
return Response(status=status.HTTP_204_NO_CONTENT)


@transaction.non_atomic_requests
@require_POST
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_course_permission(permissions.ENROLLMENT_REPORT)
@common_exceptions_400
def get_course_survey_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 GetCourseSurveyResults(DeveloperErrorViewMixin, APIView):
"""
get the survey results report for the particular course.
"""
course_key = CourseKey.from_string(course_id)
report_type = _('survey')
task_api.submit_course_survey_report(request, course_key)
success_status = SUCCESS_MESSAGE_TEMPLATE.format(report_type=report_type)
permission_classes = (IsAuthenticated, permissions.InstructorPermission)
permission_name = permissions.ENROLLMENT_REPORT

return JsonResponse({"status": success_status})
@method_decorator(ensure_csrf_cookie)
@method_decorator(transaction.non_atomic_requests)
def post(self, request, course_id):
"""
method to return survey results report for the particular course.
"""
course_key = CourseKey.from_string(course_id)
report_type = _('survey')
task_api.submit_course_survey_report(request, course_key)
success_status = SUCCESS_MESSAGE_TEMPLATE.format(report_type=report_type)

return JsonResponse({"status": success_status})


@transaction.non_atomic_requests
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 @@ -65,7 +65,7 @@
path('problem_grade_report', api.problem_grade_report, name='problem_grade_report'),

# Reports..
path('get_course_survey_results', api.get_course_survey_results, name='get_course_survey_results'),
path('get_course_survey_results', api.GetCourseSurveyResults.as_view(), name='get_course_survey_results'),
path('export_ora2_data', api.export_ora2_data, name='export_ora2_data'),
path('export_ora2_summary', api.export_ora2_summary, name='export_ora2_summary'),

Expand Down

0 comments on commit cba02f5

Please sign in to comment.