# Academic Structure Refinement

## Setup order

1. Create departments.
2. Create courses and link each course to its department and duration in years.
3. Create academic years, sessions and modules.
4. Create units once in the Unit Catalogue.
5. Build the Course Curriculum by assigning units to a course, year of study and module.
6. Create classes. Department, academic year and period details are inherited from the selected course/session/module.
7. Assign curriculum units to one or several matching classes.
8. Allocate a lecturer to each class-unit record.
9. Generate or manually adjust the timetable from saved class-unit and lecturer allocations.

## Main changes

- Added stable database links for departments, courses, academic years, sessions, modules, classes, units, curriculum mappings, class-unit allocations, lecturers and timetable rows.
- Kept existing readable name fields synchronized for compatibility with current reports.
- Added an Academic Structure dashboard with counts, setup links, readiness status and integrity checks.
- Added active/inactive status controls for departments, courses, classes, units, curriculum mappings and class-unit mappings.
- A course now has one department and a defined duration in years.
- Years of study are limited to the selected course duration.
- Sessions are linked to academic years by ID.
- Modules are linked to sessions by ID.
- Module names such as `Module 1` can be reused in different sessions.
- Units are created once without lecturer, course, module or year fields.
- Course Curriculum assigns units to a course, year and module.
- Class Unit Allocation supports one or multiple classes and one or multiple curriculum units.
- Lecturer allocation is performed per class-unit, allowing the same unit to have different lecturers in different classes.
- Timetable rules and manual timetable rows now select an existing class-unit allocation and lecturer. Course, department, session, module, year and unit are loaded automatically.
- Existing records are backfilled to the new ID-based links where matching legacy data is available.

## Database update

For an existing installation, run:

`database_updates/academic_structure_refinement.sql`

New installations already contain the refined columns and indexes in:

`college_erp_full_database.sql`
