Repository navigation
Description
Description
With AuthZ enabled (authz.enable_course_authoring), a user can access the Instructor Dashboard with a role that has no legacy equivalent, but the Gradebook API still authorizes requests with the legacy course author check. These users see the View Gradebook link and cannot use the Gradebook MFE it leads to. The course info API should tell the MFE whether the user can access the Gradebook, so the link can be hidden when they cannot.
Current Behavior
GET /api/instructor/v2/courses/{course_id} returns gradebook_url based only on configuration: the grades.writable_gradebook flag and the WRITABLE_GRADEBOOK_URL setting. The response has no field that says whether the current user can access the Gradebook.
The Gradebook API uses course_author_access_required, which does not check AuthZ permissions such as courses.view_gradebook. AuthZ roles pass this check only through their legacy equivalent. For example, Course Admin and Course Staff pass, while roles such as Course Editor, Course Auditor, or custom roles do not.
Expected Behavior
The course info response includes a new boolean field, has_gradebook_access, that is true only when the current user passes the access check of the Gradebook API for that course.
With AuthZ enabled, it is false for a user whose only roles have no legacy equivalent that grants Gradebook access, even if one of those roles includes courses.view_gradebook.
Acceptance Criteria
-
GET /api/instructor/v2/courses/{course_id}returnshas_gradebook_accessas a boolean. - The value matches the access rule of the Gradebook API, including its rule for CCX courses.
- With AuthZ enabled, the value is
truefor Course Admin and Course Staff. - With AuthZ enabled, the value is
falsefor Course Editor, Course Auditor, and a custom role that includescourses.view_gradebook, when the user has no other access to the Gradebook. - With AuthZ enabled, a user who has both a role without Gradebook access and a role with it gets
true. - Users who can access the Gradebook API for other reasons, such as global staff, get
true. - With AuthZ disabled, the value matches the legacy access rule of the Gradebook API.
- Existing response fields, including
gradebook_url, do not change. - The new field is documented in the API schema.
- Tests cover the cases above.
Out of Scope
- Showing or hiding the View Gradebook link in the Instructor Dashboard MFE. That work is tracked in the Grading tab issue, Granular permissions: Grading tab #499.
- Changing the permissions enforced by the Gradebook API or the Gradebook MFE, including support for
courses.view_gradebook. This will be addressed in a follow-up issue.
Technical Notes
The changes belong in openedx-platform:
- Add the field to
CourseInformationSerializerV2inlms/djangoapps/instructor/views/serializers_v2.py. - The Gradebook API check is
course_author_access_requiredinlms/djangoapps/grades/rest_api/v1/gradebook_views.py. It useshas_course_author_access, and_has_ccx_gradebook_accessfor CCX courses. has_gradebook_accessinlms/djangoapps/instructor/authz/legacy.pyalready follows this rule. Verify that it also covers the CCX case before reusing it.- Do not compute the value with
user_has_instructor_permission(user, "courses.view_gradebook", course_key). With AuthZ enabled, it can returntruefor a user the Gradebook API rejects. - The rule is not limited to Course Admin and Course Staff role names. For example,
has_course_author_accessalso grants access to Limited Staff in the LMS. Reusing the check avoids a hardcoded list of roles. has_gradebook_accessreports user access only. Whether the Gradebook is configured is still reported bygradebook_url.
Related Issues
- Related to Enforcement: Grading tab #490 (Enforcement: Grading tab)
- Related to Granular permissions: Grading tab #499 (Granular permissions: Grading tab)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity