Skip to content

Return gradebook access in the Instructor Dashboard course info API #655

Done
openedx/openedx-platform
#39445

Description

@BryanttV

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} returns has_gradebook_access as a boolean.
  • The value matches the access rule of the Gradebook API, including its rule for CCX courses.
  • With AuthZ enabled, the value is true for Course Admin and Course Staff.
  • With AuthZ enabled, the value is false for Course Editor, Course Auditor, and a custom role that includes courses.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 CourseInformationSerializerV2 in lms/djangoapps/instructor/views/serializers_v2.py.
  • The Gradebook API check is course_author_access_required in lms/djangoapps/grades/rest_api/v1/gradebook_views.py. It uses has_course_author_access, and _has_ccx_gradebook_access for CCX courses.
  • has_gradebook_access in lms/djangoapps/instructor/authz/legacy.py already 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 return true for a user the Gradebook API rejects.
  • The rule is not limited to Course Admin and Course Staff role names. For example, has_course_author_access also grants access to Limited Staff in the LMS. Reusing the check avoids a hardcoded list of roles.
  • has_gradebook_access reports user access only. Whether the Gradebook is configured is still reported by gradebook_url.

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

willow

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions