feat(gradebook): add Level contribution to weighted gradebook#8449
feat(gradebook): add Level contribution to weighted gradebook#8449LWS49 wants to merge 1 commit into
Conversation
7aadba7 to
5f6ba3b
Compare
521efed to
2efbb02
Compare
5f6ba3b to
dcd91bf
Compare
16ea8b5 to
1c5b845
Compare
7a38a60 to
192a1e9
Compare
fea40ba to
2fb3c20
Compare
192a1e9 to
03a1f79
Compare
6dd61fc to
91969ac
Compare
2496fbc to
365e70a
Compare
e88f292 to
0ec0a5b
Compare
| @@ -0,0 +1,126 @@ | |||
| # frozen_string_literal: true | |||
| class Course::Gradebook::LevelConfig < ApplicationRecord | |||
There was a problem hiding this comment.
Metrics/ClassLength: Class has too many lines. [101/100]
| it 'returns the raw value when clamp is off' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level * 5', formula_ast: times5, | ||
| weight: 3, clamp: false) |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
|
|
||
| it 'returns the raw value when clamp is off' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level * 5', formula_ast: times5, |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
| it 'leaves an in-range value unchanged when clamp is on' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level * 5', formula_ast: times5, | ||
| weight: 100, clamp: true) |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
|
|
||
| it 'leaves an in-range value unchanged when clamp is on' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level * 5', formula_ast: times5, |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
| it 'floors a negative value to 0 when clamp is on' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level - 5', formula_ast: minus5, | ||
| weight: 10, clamp: true) |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
|
|
||
| it 'floors a negative value to 0 when clamp is on' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level - 5', formula_ast: minus5, |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
| it 'caps a value above the weight to the weight when clamp is on' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level * 5', formula_ast: times5, | ||
| weight: 3, clamp: true) |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
|
|
||
| it 'caps a value above the weight to the weight when clamp is on' do | ||
| config = build(:course_gradebook_level_config, course: course, enabled: true, | ||
| formula: 'level * 5', formula_ast: times5, |
There was a problem hiding this comment.
[Correctable] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
- 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
0ec0a5b to
b9f129e
Compare
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 * 2ormin(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
eval- a hostile or malformed string can only ever produce a parse error, never run as code. The grammar is restricted to numbers, thelevel/maxLevelvariables, the four operators, andfloor/ceil/round/min/max.course_idunique) upserted on save, not a row-per-edit, since there is exactly one Level contribution per course.-1), keeping it disjoint from real positive assessment ids so it flows through the same compute and rendering paths without a parallel code path.weightis 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
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 oflevelContribution/courseMaxLevel(store.test.ts); dialog enable/configure/warning behaviour (ConfigureWeightsPrompt.test.tsx); Level column rendering (GradebookWeightedTable.test.tsx);LevelConfigvalidations andupsert_forsingleton behaviour (level_config_spec.rb); controller persistence and serialization (gradebook_controller_spec.rb).showtoggle controlling column visibility independent ofenabled; weight-only saves (nolevelContributionparam) leaving the singleton config untouched.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.