Skip to content

Optional klass type on grade names; percent-based attendance grade effect - #115

Merged
buzz-code merged 7 commits into
mainfrom
claude/grade-types-attendance-percents-4i5af9
Jul 15, 2026
Merged

buzz-code merged 7 commits into
mainfrom
claude/grade-types-attendance-percents-4i5af9

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

Summary

Grade names get an optional klass type

  • GradeName gets a nullable klassTypeReferenceId, following the same pattern as Klass.
  • Grade-name matching (getDisplayGrade) now filters to klass-type-specific names for the student's klass, falling back to klass-type-agnostic names, in the percent-report pivot and the React report card.

Attendance grade effect gets an optional percent-based mode

  • AttGradeEffect gets an optional effectPercent column, mutually exclusive with the existing effect (at least one required on create; effect: 0 is treated as a valid, explicit value, not "unset").
  • When a matching rule uses effectPercent, the grade is multiplied by that percentage instead of receiving an additive effect. effectPercent must be greater than 0 (no upper bound — a rule may legitimately boost a grade above 100%).
  • Threaded through getGradeEffect/getFinalGrade, GradeEffectByUser/AbsCountEffectByUser (via the nra-server submodule bump), and the percent-report pivot.
  • Client UI text is Hebrew-only, no raw English field names.

Migrations: all three were generated via yarn typeorm:generate against a live MySQL instance (loaded from db/data.sql + existing migrations) and verified up/down, not hand-written. Along the way, Student's userId/studentNumber/year unique index was given an explicit name matching what the original migration created, eliminating an unrelated index-rename diff that every subsequent generated migration was picking up.

server/shared: bumped to nra-server's claude/grade-types-attendance-percents-4i5af9 branch tip (buzz-code/nra-server#26), which adds effectPercent support to the attendance-effect view SQL and a Hebrew-translated Max validator.

Verification

908/908 server tests pass, server and client both build cleanly. Manually verified the validation fix (effect: 0 valid, effectPercent range) against class-validator directly, and the view SQL correctness against a live MySQL instance including a threshold-collision edge case.


Generated by Claude Code

claude added 7 commits July 15, 2026 07:59
…rade effect

- GradeName gets an optional klassTypeReferenceId, following the same
  pattern as Klass. Grade-name matching (getDisplayGrade) now filters to
  klass-type-specific names for the student's klass, falling back to
  klass-type-agnostic names, in the percent-report pivot and the React
  report card.
- AttGradeEffect gets an optional effectPercent column, mutually exclusive
  with the existing effect (at least one required on create). When a
  matching rule uses effectPercent, the grade is multiplied by that
  percentage instead of receiving an additive effect. Extended
  getGradeEffect/getFinalGrade accordingly, and threaded effectPercent
  through GradeEffectByUser/AbsCountEffectByUser and the percent-report
  pivot.
- The view-expression SQL for the attendance-effect views is kept local to
  this repo (server/src/db/view-entities/attendance-effect-view.util.ts)
  rather than extending server/shared, per this repo's rule against
  modifying the shared submodule directly.
- All three migrations were generated via `yarn typeorm:generate` against a
  live MySQL instance (loaded from db/data.sql + existing migrations) and
  verified up/down, not hand-written.
Student's userId/studentNumber/year unique index had no explicit name, so
TypeORM's auto-generated hash name diverged from the name the original
migration used (students_user_student_number_year_unique). Every migration
generated since then picked up a spurious rename of this index. Naming it
explicitly in the entity eliminates that drift entirely (migration:generate
now reports no schema changes).

Also relax AGENTS.md's shared-submodule rule from a hard "never" to
"avoid when possible", since editing server/shared or client/shared
directly is sometimes the right call.
Replaces the local duplicate of attendance-effect-view.util.ts with the
shared version now that server/shared has been updated (nra-server commit
8fdfc0f) to support effectPercent directly. Removes the duplication between
this repo and the shared submodule; GradeEffectByUser/AbsCountEffectByUser
now import from @shared/view-entities/attendance-effect-view.util again.

Verified zero schema diff via migration:generate and full test suite green.
…ly UI text

effect=0 is a valid explicit value (no grade change), but the mutual-exclusion
check used a truthy test (!Boolean(item.effect)) that treated 0 the same as
"not provided", wrongly forcing effectPercent to also be required. Switched
both ValidateIf conditions to explicit null/undefined checks.

effectPercent is now constrained to (0, 100] via Min(1)/Max(100) from
server/shared (bumped to pick up the new Max wrapper and Hebrew field-name
translations for percents/count/effect/effectPercent). Min/Max needed
{ always: true } to not get filtered out under the CREATE validation group.

Also replaced the att-grade-effect.jsx helper text that named the fields in
English with Hebrew-only wording.
effectPercent still must be positive (Min(1)), but no longer capped at 100 -
an admin may legitimately want a rule that boosts a grade above its original
value. Updated the client helper text accordingly.
Picks up nra-server's CONSUMER_CHANGES.md documentation commit; no code
changes, submodule pointer only.
@buzz-code
buzz-code merged commit a1e4568 into main Jul 15, 2026
1 check passed
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.

2 participants