Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PADV 916 - CCX support for Gradebook #111

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lms/djangoapps/grades/rest_api/v1/gradebook_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from common.djangoapps.student.auth import has_course_author_access
from common.djangoapps.student.auth import has_course_author_access, is_ccx_course
from common.djangoapps.student.models import CourseAccessRole, CourseEnrollment, CourseMode
from common.djangoapps.student.roles import BulkRoleCache
from common.djangoapps.student.roles import BulkRoleCache, CourseInstructorRole, CourseStaffRole
from common.djangoapps.track.event_transaction_utils import (
create_new_event_transaction_id,
get_event_transaction_id,
Expand Down Expand Up @@ -227,6 +227,13 @@ def _wrapper_view(self, request, course_id, *args, **kwargs):
"""
course_key = CourseKey.from_string(course_id)
if not has_course_author_access(request.user, course_key):
user_has_gradebook_access = any([
CourseStaffRole(course_key).has_user(request.user),
CourseInstructorRole(course_key).has_user(request.user),
])
if is_ccx_course(course_key) and user_has_gradebook_access:
return view(self, request, course_key, *args, **kwargs)

raise DeveloperErrorViewMixin.api_error(
status_code=status.HTTP_403_FORBIDDEN,
developer_message='The requesting user does not have course author permissions.',
Expand Down
Loading