Skip to content

Commit

Permalink
feat!: upgrading simple api with DRF. (#35463)
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 authored Oct 1, 2024
1 parent 3b93bfb commit 093734b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,27 +1353,27 @@ def _get_problem_responses(request, *, course_id, problem_locations, problem_typ
return JsonResponse({"status": success_status, "task_id": task.task_id})


@require_POST
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_course_permission(permissions.CAN_RESEARCH)
def get_grading_config(request, course_id):
@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True), name='dispatch')
class GetGradingConfig(APIView):
"""
Respond with json which contains a html formatted grade summary.
"""
course_id = CourseKey.from_string(course_id)
# course = get_course_with_access(
# request.user, 'staff', course_id, depth=None
# )
course = get_course_by_id(course_id)

grading_config_summary = instructor_analytics_basic.dump_grading_context(course)
permission_classes = (IsAuthenticated, permissions.InstructorPermission)
permission_name = permissions.CAN_RESEARCH

response_payload = {
'course_id': str(course_id),
'grading_config_summary': grading_config_summary,
}
return JsonResponse(response_payload)
@method_decorator(ensure_csrf_cookie)
def post(self, request, course_id):
"""
Post method to return grading config.
"""
course_id = CourseKey.from_string(course_id)
course = get_course_by_id(course_id)
grading_config_summary = instructor_analytics_basic.dump_grading_context(course)
response_payload = {
'course_id': str(course_id),
'grading_config_summary': grading_config_summary,
}
return JsonResponse(response_payload)


@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 @@ -27,7 +27,7 @@
path('modify_access', api.ModifyAccess.as_view(), name='modify_access'),
path('bulk_beta_modify_access', api.bulk_beta_modify_access, name='bulk_beta_modify_access'),
path('get_problem_responses', api.get_problem_responses, name='get_problem_responses'),
path('get_grading_config', api.get_grading_config, name='get_grading_config'),
path('get_grading_config', api.GetGradingConfig.as_view(), name='get_grading_config'),
re_path(r'^get_students_features(?P<csv>/csv)?$', api.get_students_features, name='get_students_features'),
path('get_issued_certificates/', api.get_issued_certificates, name='get_issued_certificates'),
path('get_students_who_may_enroll', api.GetStudentsWhoMayEnroll.as_view(), name='get_students_who_may_enroll'),
Expand Down

0 comments on commit 093734b

Please sign in to comment.