Skip to content

feat: implement grading permissions and authorization hooks#2988

Open
bra-i-am wants to merge 5 commits intoopenedx:masterfrom
eduNEXT:bc/implement-grading-permissions
Open

feat: implement grading permissions and authorization hooks#2988
bra-i-am wants to merge 5 commits intoopenedx:masterfrom
eduNEXT:bc/implement-grading-permissions

Conversation

@bra-i-am
Copy link
Copy Markdown
Contributor

@bra-i-am bra-i-am commented Apr 8, 2026

Description

This PR implements AuthZ permission checks for the Settings → Grading page in Studio, enabling role-based UI control based on the courses.view_grading_settings and courses.edit_grading_settings permissions from openedx-authz.

What changed

New shared authz utilities

  • src/authz/hooks.ts — New useUserPermissionsWithAuthzCourse(courseId, permissions) hook that abstracts the common pattern of checking the enableAuthzCourseAuthoring waffle flag, fetching permissions when enabled, and defaulting all permissions to true when disabled.
  • src/authz/permissionHelpers.ts — New getGradingPermissions(courseId) and getFilesPermissions(courseId) helpers that return structured permission query objects.
  • src/authz/constants.ts — Added VIEW_GRADING_SETTINGS and EDIT_GRADING_SETTINGS to COURSE_PERMISSIONS.

Grading Settings page (GradingSettings.jsx):

  • If the user lacks courses.view_grading_settings → renders <PermissionDeniedAlert /> (full page block).
  • If the user lacks courses.edit_grading_settings → all edit controls are disabled (read-only view).
  • isEditable prop propagated to all child components: GradingScale, GradingScaleSegment, GradingScaleHandle, AssignmentSection, AssignmentItem, AssignmentTypeName, DeadlineSection, CreditSection.

Supporting information

  • Backend authz permission definitions: openedx_authz.constants.permissions.COURSES_VIEW_GRADING_SETTINGS / COURSES_EDIT_GRADING_SETTINGS
  • Waffle flag: authz.enable_course_authoring (CourseWaffleFlag, default false)

Testing instructions

Prerequisites:

  1. Enable the waffle flag: Django Admin → Waffle → Flags → create authz.enable_course_authoring set to Everyone.
  2. Create a test course.

Test view permission denied:

  1. Create a user with no role assigned to the course.
  2. Navigate to Settings → Grading for that course.
  3. Expected: Permission denied alert is shown.

Test view-only (read-only UI):

  1. Assign course_auditor role to a user for the course via PUT /api/authz/v1/roles/users/ with scope=course-v1:Org%2BCourse%2BRun.
  2. Log in as that user and navigate to Settings → Grading.
  3. Expected: Page loads, but all inputs are disabled and the Save button is disabled.

Test full edit access:

  1. Assign course_editor role to a user.
  2. Navigate to Settings → Grading.
  3. Expected: Full edit access — all inputs enabled, Save button works.

Other information

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code — existing JSX child components were modified and retain their existing patterns. Full migration to TypeScript is out of scope for this PR.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks) — to be added in a follow-up.
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. To import from parent folders, use @src.

@bra-i-am bra-i-am marked this pull request as draft April 8, 2026 21:55
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 8, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Apr 8, 2026

Thanks for the pull request, @bra-i-am!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.57%. Comparing base (2930265) to head (ad49a12).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...s/grading-scale/components/GradingScaleSegment.tsx 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2988    +/-   ##
========================================
  Coverage   95.57%   95.57%            
========================================
  Files        1366     1368     +2     
  Lines       31507    31541    +34     
  Branches     7119     6903   -216     
========================================
+ Hits        30113    30146    +33     
- Misses       1344     1345     +1     
  Partials       50       50            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bra-i-am bra-i-am force-pushed the bc/implement-grading-permissions branch from f36766a to 72cb564 Compare April 9, 2026 16:56
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Apr 9, 2026
@bra-i-am bra-i-am force-pushed the bc/implement-grading-permissions branch from cbce6d4 to ad49a12 Compare April 9, 2026 20:48
@bra-i-am bra-i-am marked this pull request as ready for review April 10, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

Task - RBAC Authz - Implement frontend check for Settings -> Grading permissions

3 participants