UPDATED SRC - OCTOBER 2026

Included changes:

1. BURSARY / ACCOUNTS
- Students with no fee record still show the configured default term school-fee amount in Balance.
- Outstanding filters now use the same visible Balance value.
- Bursary overview Recorded due and Total outstanding are calculated from the exact balances shown in Student accounts.
- Admin dashboard Total outstanding and Recorded due use the same visible account Balance totals.

2. ADMIN DASHBOARD
- Desktop stat cards use exactly 3 columns per row.
- They reduce to 2 columns only on narrower screens and 1 column on mobile.

3. RESULT PDF / UI
- Full student report is now a compact one-page A4 report.
- A single student PDF is asserted to contain exactly 1 page.
- Combined PDF is asserted to contain exactly the same number of pages as students rendered (20 students = 20 pages).
- Updated report layout follows the compact school-report style: school header, student details, academic table, behaviours/skills, remarks and grading key on one page.
- Applied to admin, principal, vice-principal, HOS and shared Results pages.

4. SCHOOL-CONFIGURABLE RESULT ENGINE
- New admin route: /admin/result-configuration
- School can choose which existing result columns teachers use.
- School can rename displayed columns and set min/max values.
- School can define formulas for ST1, ST2, CAT and TOTAL.
- Grade bands are configurable.
- Teacher result input automatically loads the correct profile (secondary/default, primary/nursery, play class).
- Only enabled columns are shown to teachers.
- Score validation follows configured limits.
- Calculated ST1/ST2/CAT/TOTAL/GRADE are saved back into the existing results row.
- Safe formula parser supports arithmetic plus ROUND, AVG, MIN, MAX, ABS, FLOOR and CEIL.

5. DATABASE / API INTEGRATION
- Production backend endpoint is now implemented in backend/api/result_configuration.php.
- Shared server calculation engine is in backend/api/shared/ResultConfiguration.php.
- Migration is in backend/migrations/20261001_result_configuration.sql.
- Teacher and general result write endpoints now recalculate configured formulas on the server.
- Form-teacher, subject-teacher and shared teacher input pages all use the configured columns.
- Result writes include the school key so per-school configurations remain separated.
- RESULT_CONFIGURATION_SETUP.md documents deployment.

A local/default fallback remains only as resilience if the result configuration endpoint is temporarily unavailable.

2026-10-02 RESULT CONFIGURATION / RESULT COLUMN CORRECTION
- Secondary, Primary/Nursery and Play Class now use one shared profile resolver so Teacher Input and Teacher Results select the same configuration for the same class.
- Teacher Results now loads the assigned class metadata before selecting the result profile; it no longer guesses from an incomplete student row alone.
- Result Configuration now separates "Teacher input columns" from "Show in result" columns.
- Each result component now stores showInResult inside the existing configuration JSON. No database migration is required; the current backend preserves component properties.
- Official Admin/Principal/VP/HOS result tables and the Teacher result preview use only fields selected under "Show in result". Total, Grade and Remark remain standard columns.
- Existing configurations without showInResult remain backward-compatible: enabled teacher-input fields are initially treated as result-display fields until the admin saves the new display selection.
- Formula entry is now a click builder: choose fields, operators (+ - * /), brackets, functions, commas, and numeric constants instead of manually typing database column names.

2026-10-02 DYNAMIC RESULT DISPLAY COLUMNS
- Result Configuration now controls BOTH assessment score fields and standard/statistical result columns.
- Term Result can independently show/hide: Total, Position in Subject, Grade, Class Highest, Class Average, Class Lowest and Remark.
- Cumulative Result can independently show/hide: 1st Term, 2nd Term, 3rd Term, Cumulative, Position, Grade, Class Highest, Class Average, Class Lowest and Remark.
- FCA Result can independently show/hide: CA, Exam, Total, Position, Grade, Class Highest, Class Average, Class Lowest and Remark.
- Every standard/statistical column also has a configurable display label.
- SUBJECT remains the only mandatory first column.
- The selected display columns are used by both Teacher Results (view-only preview) and official Admin/Principal/VP/HOS results.
- Secondary, Primary/Nursery and Play Class keep separate display settings inside their existing result profiles.
- Backend result configuration normalization now preserves resultDisplay settings. No database migration is required because the configuration is stored in the existing configuration_json LONGTEXT.

PLANNED DEVELOPER FIELD ENTITLEMENTS
- The paid/allowed-field control discussed with the developer is intentionally NOT exposed to school admins in this build.
- It should be implemented as a server-enforced developer entitlement layer (not a frontend-only checkbox), so a school cannot re-enable unpaid fields by editing a request.
- Once the school/package field list is supplied, the entitlement layer can disable unavailable input/calculation/result fields safely per school.

2026-10-02 - SECTION-BASED RESULT PROFILE FIX
----------------------------------------------
- Result configuration selection now follows the real class -> section_id -> sections relationship.
- Nursery and Primary school sections both use the Primary/Nursery result profile.
- Play Class sections use the Play Class profile; Secondary sections use Secondary.
- Removed class-ID level guessing from the shared frontend result-profile resolver.
- Admin/Principal/VP/HOS Results now load full class metadata instead of rebuilding classes from student names only.
- Result Configuration only shows profiles that exist in the school's current Sections setup; if section discovery is unavailable it safely shows all profiles.
- Schools with only Secondary, only Primary/Nursery, or any subset are supported.
- Official result SECTION display now prefers the assigned school section metadata.
- Teacher input and teacher result preview continue to use the same shared resolver.
