Skip to content

feat(gradebook): add Level contribution to weighted gradebook#8449

Open
LWS49 wants to merge 3 commits into
lws49/feat-gradebook-exportfrom
lws49/feat-gradebook-weighted-view-add-level-contribution
Open

feat(gradebook): add Level contribution to weighted gradebook#8449
LWS49 wants to merge 3 commits into
lws49/feat-gradebook-exportfrom
lws49/feat-gradebook-weighted-view-add-level-contribution

Conversation

@LWS49

@LWS49 LWS49 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional Level contribution to the weighted gradebook, sitting alongside the existing assessment-tab weights. An instructor enters an arithmetic formula (e.g. level * 2 or min(level, 5)) that maps each student's course Level to grade-points, which then folds into the student's weighted Total. The formula, weight budget, effective max level, and column visibility are configured in the Configure Contributions dialog and persisted per course. A new Level column surfaces each student's contribution in the weighted table.

Design decisions

  • Formula handling parses into a small arithmetic AST and evaluates with plain arithmetic rather than eval - a hostile or malformed string can only ever produce a parse error, never run as code. The grammar is restricted to numbers, the level/maxLevel variables, the four operators, and floor/ceil/round/min/max.
  • Level config is a singleton per course (course_id unique) upserted on save, not a row-per-edit, since there is exactly one Level contribution per course.
  • The Level term reuses the existing breakdown structure via synthetic negative tab/assessment ids (-1), keeping it disjoint from real positive assessment ids so it flows through the same compute and rendering paths without a parallel code path.
  • weight is treated as an advisory budget: contributions outside [0, weight] drive a dialog warning rather than being clamped, leaving the instructor in control of the formula.

Regression prevention

  • Covers: formula tokenizer/parser including precedence, unary minus, functions, and rejection of invalid input (levelFormula.test.ts); Level folding into student totals and breakdown, null/disabled handling, and out-of-range detection (computeWeighted.test.ts); store hydration and update of levelContribution/courseMaxLevel (store.test.ts); dialog enable/configure/warning behaviour (ConfigureWeightsPrompt.test.tsx); Level column rendering (GradebookWeightedTable.test.tsx); LevelConfig validations and upsert_for singleton behaviour (level_config_spec.rb); controller persistence and serialization (gradebook_controller_spec.rb).
  • Manually tested: enabling and configuring a formula with weight/max level and confirming it persists across reload; Level column and Total reflecting the contribution and disabling removing it; invalid formula handled gracefully without crashing the Total; out-of-range warning firing; show toggle controlling column visibility independent of enabled; weight-only saves (no levelContribution param) leaving the singleton config untouched.
  • Backward compatible: when the weighted view is disabled or no Level config exists, the serializer returns a disabled/zeroed contribution and the gradebook behaves exactly as before.

Adding screenshots: the Configure Contributions dialog showing the Level section (formula input + weight + out-of-range warning), and the weighted table with the Level column populated.

@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view-add-level-contribution branch from 7aadba7 to 5f6ba3b Compare June 17, 2026 06:09
@LWS49 LWS49 changed the title Lws49/feat gradebook weighted view add level contribution feat(gradebook): add Level contribution to weighted gradebook Jun 17, 2026
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view branch 2 times, most recently from 521efed to 2efbb02 Compare June 17, 2026 06:45
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view-add-level-contribution branch from 5f6ba3b to dcd91bf Compare June 18, 2026 16:08
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view branch 9 times, most recently from 16ea8b5 to 1c5b845 Compare June 26, 2026 08:51
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view-add-level-contribution branch 3 times, most recently from 7a38a60 to 192a1e9 Compare June 29, 2026 05:45
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view branch 3 times, most recently from 7a4ad9f to fea40ba Compare June 29, 2026 08:12
Add weighted view built on top of gradebook:

- add tables course_gradebook_contributions and course_gradebook_assessment_contributions
- weighted table with equal/custom weight modes and per-assessment
  weight inputs, with a sum gate on custom weights
- points / percentage display toggle
- inline per-student assessment breakdown (row expand)
- projected-total hint
- gradebook_excluded column, serialization, and update-weights API echo
- per-assessment include/exclude in the configure-weights modal,
  seeding custom weights from included assessments only
- excluded assessments shown in the breakdown with no contribution
- add SegmentedSelect component for stylized selection that is not "on-off"
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view branch from fea40ba to 2fb3c20 Compare June 29, 2026 08:20
LWS49 added 2 commits June 29, 2026 16:26
- map student Level to grade-points via a safe parsed arithmetic formula
- fold the Level term into weighted Total and per-student breakdown
- add Configure Contributions controls: formula, weight, max level, show
- persist a singleton LevelConfig per course (new table + migration)
- surface a Level column in the weighted table, toggleable via column picker
- warn when a contribution falls outside the advisory weight budget
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view-add-level-contribution branch from 192a1e9 to 03a1f79 Compare June 29, 2026 08:27
@LWS49 LWS49 force-pushed the lws49/feat-gradebook-weighted-view branch 4 times, most recently from 6dd61fc to 91969ac Compare June 29, 2026 12:12
Base automatically changed from lws49/feat-gradebook-weighted-view to lws49/feat-gradebook-export June 29, 2026 12:12
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