Get Hedhog updates in your inbox
New releases, fresh recipes, and breaking changes — no spam.
LMS Submodule
enterprise
Multi-tenant enterprise accounts that license courses and class groups to an organization, plus four role-scoped training portals (admin, instructor, viewer, student) for that organization's own staff.
Source path: libraries/lms/src/enterprise
Module file: enterprise.module.ts, enterprise/training/enterprise-training.module.ts
Introduction
The Enterprise submodule turns the LMS into a B2B product: an enterprise is a licensed organization (optionally linked to a CRM person/company) that gets its own slice of courses, class groups, users, and students, gated by a license limit. `EnterpriseController` is the platform-admin surface for managing these accounts — creating enterprises, linking/unlinking courses and class groups to them, adding enterprise users with a role (hr_manager, enterprise_admin, viewer), and managing the roster of enterprise students. Adding a user automatically grants the corresponding global platform role (`lms-enterprise-admin` for hr_manager/enterprise_admin) plus `lms-training-access`; removing the last enterprise link for a user revokes that access again. Linking a class group to an enterprise backfills any already-enrolled students into `enterprise_student` and records a license "assigned" event, keeping license consumption accurate even when enrollment happened before the enterprise link existed. Three public, unauthenticated endpoints stream course/class logo and banner images for use in enterprise-branded portal headers.
The other four controllers under `enterprise/training/` are the actual portals enterprise members use day-to-day, all reusing the Enterprise submodule's data rather than duplicating it. `TrainingAdminController` (role-gated, `/lms/enterprise/training/admin`) is the richest: dashboards, course/class-group browsing, a license management surface (assign/revoke, list with department/status filters), student and admin-user management scoped to the enterprise, and Portuguese-named reporting endpoints (`relatorios`, `avaliacoes`) for reports and evaluations. `TrainingInstructorController` gives an enterprise-linked instructor their own dashboard, their assigned class groups, attendance and material management (including file upload), and reports. `TrainingViewerController` is read-only and, notably, reuses `TrainingAdminService` directly rather than having its own service — there is no dedicated viewer business logic, just a narrower read-only controller surface over the same data. `TrainingStudentController` is the enterprise member-facing portal, decorated `@NoRole()` (any authenticated user, not a specific role) rather than `@Role()` like the other three, reflecting that any platform user can be an enterprise student without needing a platform-level role grant.
A point worth flagging for API consumers: most admin/instructor endpoints accept an optional `enterpriseId` query parameter to scope a multi-enterprise admin's view, but the viewer and student controllers mostly omit it (relying on implicit scoping from the authenticated user's own enterprise link) — except `TrainingViewerController`'s class-groups endpoint, which inconsistently still accepts it. Several admin/instructor write endpoints (assign license, add admin, submit attendance) take plain inline body shapes rather than DTOs, so they have no class-validator runtime validation.
HTTP Endpoints
84 endpoints
Streams the linked course logo image (unauthenticated, for portal branding).
- Params
- courseId (int)
Streams the linked course's logo for a class group.
- Params
- classId (int)
Paginated enterprise list with CRM/avatar and linked-resource counts.
- Query
- page, pageSize, search, status, crmPersonId
Creates an enterprise; 409 on duplicate slug.
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | yes | Max 255 chars |
| slug | string | no | — |
| status | 'active' | 'trial' | 'inactive' | 'suspended' | no | — |
| crm_person_id | number | null | no | — |
| portal_enabled | boolean | no | — |
| license_limit | number | null | no | — |
| notes | string | no | — |
Aggregate counts: total, active, trial, portal-enabled.
Distinct CRM persons linked to any enterprise, for picker UI.
Enterprise portal profiles available to the current user (auto-activates pending links); empty if unauthenticated.
KPIs, license usage, 12-month license timeline, and recent activity feed.
- Params
- id (int)
Single enterprise with CRM/company details and role-breakdown counts.
- Params
- id (int)
Updates enterprise fields.
- Params
- id (int)
Deletes the enterprise.
- Params
- id (int)
Paginated enterprise users with email/last-login.
- Params
- id (int)
- Query
- page, pageSize, search, status, role
Adds a user to the enterprise; auto-grants the matching global role plus lms-training-access.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| user_id | number | yes | — |
| role | 'hr_manager' | 'enterprise_admin' | 'viewer' | yes | — |
| person_id | number | null | no | — |
| status | 'active' | 'inactive' | 'pending' | no | — |
Updates role/status; re-applies global role mapping if role changed.
- Params
- id, userId (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| role | 'hr_manager' | 'enterprise_admin' | 'viewer' | no | — |
| status | 'active' | 'inactive' | 'pending' | no | — |
Removes the link; revokes lms-training-access if no other enterprise links remain.
- Params
- id, userId (int)
Courses linked to the enterprise.
- Params
- id (int)
- Query
- page, pageSize, search, status
Links a course to the enterprise; 409 if already linked.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| course_id | number | yes | — |
| contracted_at | string | null | no | — |
Unlinks a course.
- Params
- id, courseId (int)
Class groups linked to the enterprise.
- Params
- id (int)
- Query
- page, pageSize, search, status
Links a class group; backfills already-enrolled students into enterprise_student and logs a license event.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| course_class_group_id | number | yes | — |
Unlinks a class group.
- Params
- id, classGroupId (int)
Enterprise students with primary email contact.
- Params
- id (int)
- Query
- page, pageSize, search, status
Adds a student; logs a license "assigned" event.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| person_id | number | yes | — |
| status | 'active' | 'inactive' | 'pending' | no | — |
Updates status; logs a license "status_changed" event if changed.
- Params
- id, personId (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| status | 'active' | 'inactive' | 'pending' | no | — |
Removes a student; logs a license "revoked" event.
- Params
- id, personId (int)
Training admin dashboard summary.
- Query
- enterpriseId?
Course completion stat aggregates.
- Query
- enterpriseId?
Paginated course list.
- Query
- enterpriseId?, page, pageSize, search, level, category
Course detail (admin view).
- Params
- courseId (int)
- Query
- enterpriseId?
Paginated class group list.
- Query
- enterpriseId?, page, pageSize, search, status, deliveryMode, instructorId?
Class group detail.
- Params
- id (int)
Students in a class group.
- Params
- id (int)
- Query
- page, pageSize, search, status
Sessions for a class group.
- Params
- id (int)
Materials for a class group.
- Params
- id (int)
License availability for the admin's enterprise(s).
Paginated license (student) list.
- Query
- page, pageSize, search, status, department
Assigns a license — creates/links a student record.
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | yes | — |
| string | no | — | |
| department | string | no | — |
Revokes a license from a person.
- Params
- personId (int)
Students eligible to enroll in a class group.
- Params
- id (int)
- Query
- search?
Enrolls an existing student.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| personId | number | yes | — |
Creates a new student and enrolls them.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | yes | — |
| string | no | — | |
| department | string | no | — |
Student stats.
- Query
- enterpriseId?
Paginated student list.
- Query
- enterpriseId?, page, pageSize, search, status
Student profile/progress detail.
- Params
- personId (int)
- Query
- enterpriseId?
Admin user stats.
- Query
- enterpriseId?
Paginated admin list.
- Query
- enterpriseId?, page, pageSize, search, role
Adds an admin user to the enterprise.
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | yes | — |
| string | no | — | |
| department | string | no | — |
| role | string | no | — |
Updates an admin's role.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| role | string | yes | — |
Removes an admin.
- Params
- id (int)
Training admin reports.
- Query
- enterpriseId?, dateFrom?, dateTo?
Evaluation statistics.
- Query
- enterpriseId?
Paginated class groups with evaluation data.
- Query
- enterpriseId?, page, pageSize, search
Evaluation detail for a class group.
- Params
- classGroupId (int)
- Query
- enterpriseId?
Instructor dashboard summary.
- Query
- enterpriseId?
The instructor's assigned class groups.
- Query
- enterpriseId?, search, status, deliveryMode
Instructor reports.
- Query
- enterpriseId?, dateFrom?, dateTo?
Evaluation data for a class group.
- Params
- id (int)
Class group detail.
- Params
- id (int)
Students in the class group.
- Params
- id (int)
- Query
- page, pageSize, search, status
Sessions list.
- Params
- id (int)
Full attendance summary for the class group.
- Params
- id (int)
Materials list.
- Params
- id (int)
Download URL for a material.
- Params
- id, materialId (int)
Uploads a new material file to the class group.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| file | File | yes | multipart/form-data |
Deletes a material.
- Params
- id, materialId (int)
Submits attendance for a specific session.
- Params
- id, sessionId (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| records | { studentId: number; present: boolean }[] | yes | — |
Viewer dashboard (delegates to the admin service, read-only).
Course stats.
Course list.
- Query
- page, pageSize, search, level, category
Course detail.
- Params
- courseId (int)
Class group list.
- Query
- enterpriseId?, search, status, deliveryMode
Class group detail.
- Params
- id (int)
Students.
- Params
- id (int)
- Query
- page, pageSize, search, status
Sessions.
- Params
- id (int)
Materials.
- Params
- id (int)
Student stats.
Paginated student list.
- Query
- page, pageSize, search, status
Student detail.
- Params
- personId (int)
Class groups the student is enrolled in.
- Query
- enterpriseId?, search, status, deliveryMode
Class group detail.
- Params
- id (int)
Sessions.
- Params
- id (int)
Materials available to the student.
- Params
- id (int)
The student's pending/submitted evaluation forms for this class group.
- Params
- id (int)
MCP Tools
Named tools callable by AI models via the Model Context Protocol (MCP).
lms.enterprise.listLists enterprises with optional pagination and filters
lms.enterprise.statsReturns aggregate statistics for enterprises
lms.enterprise.crm-optionsReturns CRM person options available for enterprise linking
lms.enterprise.getReturns a single enterprise by ID
lms.enterprise.overviewReturns an overview summary of an enterprise (users, courses, classes, students, licenses)
lms.enterprise.createCreates a new enterprise
lms.enterprise.updateUpdates an existing enterprise
lms.enterprise.deleteDeletes an enterprise by ID
lms.enterprise.users.listLists users belonging to an enterprise
lms.enterprise.users.addAdds a user to an enterprise
lms.enterprise.users.updateUpdates a user within an enterprise (e.g. change role)
lms.enterprise.users.removeRemoves a user from an enterprise
lms.enterprise.courses.listLists courses assigned to an enterprise
lms.enterprise.courses.addAssigns a course to an enterprise
lms.enterprise.courses.removeRemoves a course from an enterprise
lms.enterprise.classes.listLists class groups assigned to an enterprise
lms.enterprise.classes.addAssigns a class group to an enterprise
lms.enterprise.classes.removeRemoves a class group from an enterprise
lms.enterprise.students.listLists students belonging to an enterprise
lms.enterprise.students.addAdds a student to an enterprise
lms.enterprise.students.updateUpdates a student's data within an enterprise
lms.enterprise.students.removeRemoves a student from an enterprise
lms.training-admin.dashboardReturns the training admin dashboard summary for the authenticated user
lms.training-admin.courses.listLists courses visible to the authenticated training admin
lms.training-admin.courses.statsReturns course statistics for the authenticated training admin
lms.training-admin.courses.getReturns details of a specific course for the training admin
lms.training-admin.class-groups.listLists class groups visible to the authenticated training admin
lms.training-admin.class-groups.getReturns details of a specific class group for the training admin
lms.training-admin.class-groups.studentsLists students in a class group for the training admin
lms.training-admin.class-groups.sessionsLists sessions for a class group (training admin view)
lms.training-admin.class-groups.materialsLists materials for a class group (training admin view)
lms.training-admin.class-groups.enrollable-studentsLists students that can be enrolled in a class group
lms.training-admin.class-groups.enrollEnrolls an existing student in a class group
lms.training-admin.class-groups.enroll-newCreates a new student and enrolls them in a class group
lms.training-admin.license-infoReturns license availability info for the authenticated training admin
lms.training-admin.licenses.listLists licenses managed by the authenticated training admin
lms.training-admin.licenses.assignAssigns a license to a user
lms.training-admin.licenses.revokeRevokes a license from a user
lms.training-admin.students.listLists students visible to the authenticated training admin
lms.training-admin.students.statsReturns student statistics for the authenticated training admin
lms.training-admin.students.getReturns the profile and progress of a specific student
lms.training-admin.admins.listLists admins for the enterprise
lms.training-admin.admins.statsReturns admin statistics for the enterprise
lms.training-admin.admins.addAdds a new admin to the enterprise
lms.training-admin.admins.update-roleUpdates the role of an admin within the enterprise
lms.training-admin.admins.removeRemoves an admin from the enterprise
lms.training-admin.reportsReturns admin reports for the enterprise
lms.training-admin.evaluations.statsReturns evaluation statistics for the enterprise
lms.training-admin.evaluations.listLists class groups with evaluation data
lms.training-admin.evaluations.getReturns evaluation details for a specific class group
lms.training-instructor.dashboardReturns the training dashboard summary for the authenticated instructor
lms.training-instructor.class-groups.listLists class groups assigned to the authenticated instructor
lms.training-instructor.class-groups.getReturns details of a specific class group for the authenticated instructor
lms.training-instructor.class-groups.studentsLists students in a class group (instructor view)
lms.training-instructor.class-groups.sessionsLists sessions for a class group (instructor view)
lms.training-instructor.class-groups.attendance.getReturns the full attendance summary for a class group
lms.training-instructor.class-groups.attendance.submitSubmits attendance records for a specific session
lms.training-instructor.class-groups.materials.listLists materials for a class group (instructor view)
lms.training-instructor.class-groups.materials.deleteDeletes a material from a class group
lms.training-instructor.class-groups.evaluationsReturns evaluation data for a class group (instructor view)
lms.training-instructor.reportsReturns reports for the authenticated instructor
lms.training-student.dashboardReturns the training dashboard summary for the authenticated student
lms.training-student.class-groups.listLists class groups in which the authenticated student is enrolled
lms.training-student.class-groups.getReturns details of a specific class group for the authenticated student
lms.training-student.class-groups.sessionsLists sessions for a class group (student view)
lms.training-student.class-groups.materialsLists materials for a class group (student view)
lms.training-student.class-groups.my-evaluationsReturns the evaluations submitted by the authenticated student for a class group
lms.training-student.streak.getReturns the authenticated student's learning streak data
lms.training-student.streak.register-activityRegisters a learning activity for the authenticated student's streak