Repository navigation
Optional klass type on grade names; percent-based attendance grade effect - #115
Merged
Merged
Conversation
…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.
# Conflicts: # server/shared
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grade names get an optional klass type
GradeNamegets a nullableklassTypeReferenceId, following the same pattern asKlass.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
AttGradeEffectgets an optionaleffectPercentcolumn, mutually exclusive with the existingeffect(at least one required on create;effect: 0is treated as a valid, explicit value, not "unset").effectPercent, the grade is multiplied by that percentage instead of receiving an additiveeffect.effectPercentmust be greater than 0 (no upper bound — a rule may legitimately boost a grade above 100%).getGradeEffect/getFinalGrade,GradeEffectByUser/AbsCountEffectByUser(via thenra-serversubmodule bump), and the percent-report pivot.Migrations: all three were generated via
yarn typeorm:generateagainst a live MySQL instance (loaded fromdb/data.sql+ existing migrations) and verified up/down, not hand-written. Along the way,Student'suserId/studentNumber/yearunique 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 tonra-server'sclaude/grade-types-attendance-percents-4i5af9branch tip (buzz-code/nra-server#26), which addseffectPercentsupport to the attendance-effect view SQL and a Hebrew-translatedMaxvalidator.Verification
908/908 server tests pass, server and client both build cleanly. Manually verified the validation fix (
effect: 0valid,effectPercentrange) againstclass-validatordirectly, and the view SQL correctness against a live MySQL instance including a threshold-collision edge case.Generated by Claude Code