Course Enrollment
Data Entity
Description
Records a user's enrollment in a training course, tracking enrollment status, completion, and the link to any resulting certificate. Supports both self-enrollment and coordinator-proxy enrollment on behalf of peer mentors.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key, globally unique enrollment identifier | PKrequiredunique |
user_id |
uuid |
FK to users — the peer mentor or coordinator being enrolled | required |
course_id |
uuid |
FK to courses — the course being enrolled in | required |
organization_id |
uuid |
FK to organizations — tenant scoping for multi-org isolation | required |
status |
enum |
Enrollment lifecycle state | required |
enrolled_at |
datetime |
Timestamp when the enrollment record was created | required |
completed_at |
datetime |
Timestamp when the user completed the course; null if not yet complete | - |
cancelled_at |
datetime |
Timestamp when the enrollment was cancelled; null if not cancelled | - |
completion_score |
decimal |
Optional numeric score (0–100) recorded upon completion, used for pass/fail determination | - |
enrolled_by_user_id |
uuid |
FK to users — the coordinator who enrolled on behalf of the peer mentor; null for self-enrollment | - |
certificate_id |
uuid |
FK to certificates — populated once a certificate is issued upon completion; null before completion | unique |
reminder_sent_at |
datetime |
Timestamp of the most recent enrollment or expiry reminder notification sent; null if no reminder sent yet | - |
notes |
text |
Optional free-text notes recorded by a coordinator regarding this enrollment | - |
created_at |
datetime |
Record creation timestamp (same as enrolled_at in most cases; kept for audit consistency) | required |
updated_at |
datetime |
Last modification timestamp, updated on any status change | required |
Database Indexes
idx_course_enrollments_unique_user_course
Columns: user_id, course_id
idx_course_enrollments_user_id
Columns: user_id
idx_course_enrollments_course_id
Columns: course_id
idx_course_enrollments_organization_id
Columns: organization_id
idx_course_enrollments_status
Columns: status
idx_course_enrollments_org_status
Columns: organization_id, status
Validation Rules
valid_user_id
error
Validation failed
valid_course_id
error
Validation failed
completion_score_range
error
Validation failed
completed_at_after_enrolled_at
error
Validation failed
organization_consistency
error
Validation failed
certificate_id_set_only_on_completion
error
Validation failed
Business Rules
unique_enrollment_per_user_per_course
A user may not hold more than one active enrollment record for the same course. Duplicate enrollment attempts return a conflict error. Cancelled enrollments do not block re-enrollment.
certificate_issued_on_completion
When status transitions to 'completed', the certificate-service is triggered to generate and persist a Certificate record linked via certificate_id. The completion is not finalised until the certificate record exists.
coordinator_proxy_enrollment_allowed
A coordinator may enroll a peer mentor within the same organization. The enrolled_by_user_id field is set to the coordinator's user ID. The audit-service records the proxy action.
tenant_scoped_access
Enrollment records are scoped to organization_id. API queries must filter by the caller's organization context. Cross-organization access is prohibited except for global admins.
cancelled_enrollment_blocks_certificate
A cancelled enrollment cannot have a certificate issued. If a certificate_id is present and the enrollment is cancelled, the certificate-service marks the certificate as voided.
status_transition_enforcement
Valid transitions: enrolled → completed, enrolled → cancelled, waitlisted → enrolled, enrolled → expired (system-initiated). Direct transitions to 'completed' from 'cancelled' or 'waitlisted' are rejected.
expiry_reminder_scheduling
The enrollment-reminder-scheduler checks for certificates with upcoming expiry dates and updates reminder_sent_at when a notification is dispatched. The rule prevents duplicate reminders within a 24-hour window.