# Academic, Examinations and Results Integration

## Structure used by the three modules

The Academic, Examinations and Results modules now use the same saved relationship:

**Department → Course → Year of Study → Course Module → Curriculum Unit → Class → Class Unit → Lecturer → Academic Session → Examination and Result**

A course module remains part of the course curriculum and is not created from, or attached to, an academic session. The session identifies when a class is undertaking that curriculum module.

## Academic and marks-entry workflow

- A unit must first belong to the selected course, year and course module.
- The curriculum unit must then be assigned to the class.
- The lecturer is assigned to that class-unit combination through lecturer allocation or timetabling.
- Marks Entry and Marksheet pages load only units assigned to the selected class.
- Lecturer access is checked against the same class-unit allocation.
- Student semester enrollment and unit registration store the same class, course, course-module, course-unit, academic-year and session IDs.
- Legacy readable fields remain populated for existing reports and document templates.

## Examinations and results workflow

- Exam routines select units from existing class-unit assignments.
- Result sheets load registered students and marks from the exact class, course module, unit, session and academic year.
- Identically named modules in other courses or years cannot mix results.
- Result batch approval, release and status records use the same normalized academic context.
- Exam cards obtain units from the student's registered class-unit records, with marks used only as a compatibility fallback.
- The student portal reads results and registered units using normalized unit and course-module links.

## Marksheet and transcript design

The visible marksheet and transcript designs were intentionally retained.

- The marksheet rendering functions are byte-for-byte unchanged.
- All three marksheet CSS blocks are byte-for-byte unchanged.
- The transcript preview, transcript PDF, downloadable transcript and bulk-transcript templates are unchanged after excluding only the new data-query and helper lines.
- Existing headings, letterhead, tables, grade presentation, signatures, spacing and print styles remain in place.

## Upgrade

For an existing installation, run these migrations in this order when they have not already been applied:

1. `database_updates/course_year_module_curriculum.sql`
2. `database_updates/academic_exams_results_integration.sql`

The second migration adds stable academic relationship columns, creates the exam-result batch table where required, backfills existing records and adds lookup indexes.

## Validation

- 165 PHP files passed PHP syntax validation.
- 99 academic, examination, result, migration and design-preservation checks passed.
- Full installation SQL and upgrade SQL passed structural-balance checks.
- The detailed results are in `ACADEMIC_EXAMS_RESULTS_VALIDATION.txt`.
