Skip to content

feat(gradebook): expose tab weights + weight update endpoint (pr2 of 3)#8412

Draft
LWS49 wants to merge 3 commits into
lws49/feat-gradebook-weights-pr1-foundationfrom
lws49/feat-gradebook-weights-pr2-api
Draft

feat(gradebook): expose tab weights + weight update endpoint (pr2 of 3)#8412
LWS49 wants to merge 3 commits into
lws49/feat-gradebook-weights-pr1-foundationfrom
lws49/feat-gradebook-weights-pr2-api

Conversation

@LWS49
Copy link
Copy Markdown
Collaborator

@LWS49 LWS49 commented May 28, 2026

Summary

Adds the backend API layer for the Gradebook weighted view feature. This PR introduces the GradebookComponent, ability definitions, routes, and two controllers: one for reading and updating the weighted view setting via the admin settings panel, and one serving the full Gradebook index payload (students, assessments, tabs, submissions, max grades) plus a update_weights endpoint for persisting per-tab gradebook weights. The weighted view toggle is gated to managers/owners, and gradebookWeight is conditionally included in the tabs payload only when the weighted view is enabled.

Design decisions

  • gradebookWeight is omitted from the tabs JSON when weighted_view_enabled is false - reduces payload size and avoids exposing weight data to clients that won't use it.
  • update_gradebook_weights runs in a transaction and raises RecordNotFound for tabs outside the course before touching the DB - prevents partial updates and cross-course weight mutation in one pass.
  • grade_summary and max_grades use raw SQL with find_by_sql + sanitize_sql_array rather than AR scopes - the multi-join aggregations don't map cleanly to AR's query interface and the raw form is easier to read and audit.
  • manage_gradebook_weights and manage_gradebook_settings are separate abilities - weight management is for managers/owners, settings management follows the same boundary, keeping them independently restrictable if requirements change.

Regression prevention

Covers: gradebook controller index payload shape, update_weights happy path and error cases (invalid tab, out-of-range weight), ability checks for staff/manager/owner/student, settings controller read/update, Tab#update_gradebook_weights validation and cross-course guard, Assessment.max_grades, Submission.grade_summary, GradebookSettings frontend form render and PATCH on submit.

Manual testing confirmed: settings page renders and saves; index payload includes canManageWeights and gradebookWeight correctly; update_weights persists valid weights and rejects out-of-range and foreign tab IDs; student access returns 403; weighted view disabled omits gradebookWeight from response.

Existing admin settings pattern (Course::Admin::Controller + @settings + jbuilder) is followed without modification - no behaviour change for other settings pages.

LWS49 added 3 commits May 25, 2026 11:57
…alog, toolbar buttons, visibility state, and tests

    - Add MuiColumnPickerDialog with Apply/Export actions, locked-column enforcement, and optional dataColumnIds hint when no data columns are selected
    - Update MuiTableToolbar to render a trigger button (opens dialog) and a direct export button alongside the existing CSV download icon
    - Extend useTanStackTableBuilder with column visibility state (localStorage persistence, dynamic reconciliation), onExportFromPicker, onDirectExport, and cross-page selection helpers (selectedCount, toggleAllFiltered, etc.)
    - Add ColumnPickerTemplate interface and Body.ts selection fields
    - Add full test coverage for dialog, toolbar, and hook behaviour
    - Add lib.components.table.* locale keys (en/ko/zh)
- Add gradebook_weight (0-100 integer) column to course_assessment_tabs
- Add Course::Settings::GradebookComponent with weighted_view_enabled
- Add manage_gradebook_weights/settings abilities (manager/owner only)
- Add Course Admin -> Gradebook settings page to toggle the setting
- add Tab.update_gradebook_weights: transactional bulk update scoped to
  course tabs, with pre-flight ID validation and single pre-fetch query
- extend GET /gradebook index JSON with weightedViewEnabled,
  canManageWeights, and per-tab gradebookWeight (gated by setting)
- add PATCH /gradebook/weights: manager-only, returns 422 on validation
  failure or foreign tab, transactionally rolls back on any error
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weights-pr2-api branch from caee9cd to e4bcfb6 Compare May 28, 2026 11:10
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weights-pr1-foundation branch from 8718f51 to f91df1d Compare May 28, 2026 11:14
@LWS49 LWS49 changed the title Lws49/feat gradebook weights pr2 api feat(gradebook): expose tab weights + weight update endpoint (pr2 of 3) May 29, 2026
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weights-pr1-foundation branch 3 times, most recently from 298ef61 to f572984 Compare May 29, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant