# Assigned trainer material visibility

Trainers now see active materials uploaded by admins or other trainers for their assigned active modules. They also see program-wide materials for programs they teach, global/general materials, and their own uploads. A module-specific material remains limited to that module's assigned trainer; teaching another module in the same program does not grant access to it.

Training Materials includes a View button for active materials. Listing and preview use the same trainer access rule. The program filter also includes materials that were linked only to a module. Shared archived materials are excluded; trainers retain the existing listing of their own archived uploads. Admin and student permissions are unchanged.

## Deploy

Back up the matching server files, then extract `material-access-update.zip` into the application's `elearninghub` directory, preserving its folders:

- `core/MaterialAccess.php` (new)
- `public/modules/training_materials.php` (updated)
- `public/modules/preview_material.php` (updated)

No database migration or Composer update is needed. Existing materials become visible automatically based on their module/program assignment; no re-upload is needed.

After upload, sign in as the trainer assigned to an active module and open Training Materials. Confirm that an active admin-uploaded material for that module is listed and opens using View. If a material is missing, check its active/archive status, selected module, and the module's assigned trainer.

## Validation

Run `php tests/material_access_test.php` locally. It uses MySQL temporary tables on a dedicated connection and does not modify existing application data. Tests cover shared uploads, program-only materials, unrelated modules, program/module ID collisions, global/general materials, archives, program filtering and reassignment.
