# Summative Marksheets and Class Average Update

## New report page

`modules/exams/summative_reports.php`

The page is available under **Exams & Results → Summative Reports** and from the existing Marksheet action area.

## Unit Summative Marksheet

- Select a class and one of the units assigned to that class.
- Lists every active registered student linked to the class.
- Displays saved theory, practical and weighted summative marks.
- Common units hide the practical column.
- Missing results keep the score cell blank and display `MM` for grade/comment.
- Includes the class unit average from available valid summative marks.
- Supports Excel-compatible `.xls` and direct PDF export.
- Lecturers can only open units allocated to them.

## All-Units Class Summative Average

- Displays every active curriculum unit assigned to the selected class.
- Shows one summative mark per student per unit.
- Shows completed units as `completed/expected`.
- Calculates the overall average only when every expected unit has a valid summative mark.
- Incomplete students display a blank average and `MM` grade/comment.
- Includes the average for every unit and the overall class average for students with complete results.
- Supports Excel-compatible `.xls` and direct landscape PDF export.
- Restricted to System Admin, Admin and Examination Officer because it combines units assigned to different lecturers.

## Integration and compatibility

- Uses the existing class, course module, course unit, unit, session and academic-year IDs.
- Uses the existing `marks.score` weighted total as the summative mark.
- Reuses the existing `exams_marksheet` privilege; no new role permission or database migration is required.
- Existing marksheet rendering and transcript templates were not changed.
- Added a dependency-free A4 landscape PDF writer at `includes/SimpleLandscapePDF.php` for shared-hosting portability.

## Subject key enhancement

- Unit columns continue to use the saved unit code to keep wide marksheets compact.
- A subject key now displays every unit in the format `Unit Code - Unit Name`.
- The unit marksheet shows the selected unit key above the table.
- The all-units class average shows the complete subject key below the on-screen report.
- Excel exports include a dedicated Subject Key table with separate Unit Code and Unit Name columns.
- Each PDF page includes the subject key for the units displayed on that page.
- PDF row pagination was adjusted so the key and marks table remain within the landscape page without overlap.
