# Training Module Setup and Usage

This module tracks employee training activities. Core features include:

- **Courses**: define available topics with a title and description.
- **Sessions**: schedule one or more dates and locations for each course.
- **Enrollments**: employees may enroll themselves or be enrolled by an administrator.
- **Results**: completion status and scores are recorded for each enrollment.
- **Certificates**: generate a PDF certificate for completed courses.
- **Expiry Status**: certificates show green/orange/red badges based on expiry date.
- **Filters**: list certificates by employee role or department.

## Sample API Calls

### Enroll in a Session
```bash
# POST /api/training_enrollments/enroll/{sessionId}
curl -X POST -b cookie.txt \
  http://localhost/api/training_enrollments/enroll/42
```
The session ID is supplied in the URL. Authentication is required and the logged in employee is enrolled.

### Mark Completion
```bash
# POST /api/training_enrollments/markComplete/{enrollmentId}/{score}
curl -X POST -F "signature=@sign.png" -F "feedback=Great session" -F "rating=5" -b cookie.txt \
  http://localhost/api/training_enrollments/markComplete/10/95
```
Sets the enrollment to `Completed`, saves the signature file via the DMS and records feedback.

### Report Daily Attendance
```bash
# GET /api/reports/daily?date=YYYY-MM-DD
curl -b cookie.txt \
  "http://localhost/api/reports/daily?date=2024-05-01"
```
Add `export=csv|pdf|xlsx` to download the report instead of JSON.
Results can be used to track training session participation.

### Generate Certificate Document
```bash
# GET /api/training_certificates/generateDocument/{id}
curl -b cookie.txt \
  http://localhost/api/training_certificates/generateDocument/5
```
Creates a PDF certificate for the specified record and returns the file path.

### Expiry Reminders
Certificates nearing expiry trigger email reminders. The lead time defaults to 30 days but can be overridden per tenant using the `training_cert_lead_days` setting.

### Dashboard Widget
The dashboard shows an "Upcoming Certificate Expiry" list sourced from `training_certificates`. It highlights entries that expire soon.

### Refresher Scheduling
Certificates marked for renewal automatically create new sessions and enrollments when they are within the lead time. The lead time defaults to 30 days and can be overridden per tenant using the `refresher_lead_days` setting in `tenant_module_settings`.
