Get Hedhog updates in your inbox
New releases, fresh recipes, and breaking changes — no spam.
LMS Submodule
certificates
HTML/SVG certificate template management (with background image upload) and issued certificate tracking with per-certificate public visibility control.
Source path: libraries/lms/src/certificate
Module file: certificate.module.ts
Introduction
A certificate template stores its visual layout as a raw HTML/SVG string (`templateContent`) plus a draft/active/inactive status, letting the admin panel offer a live template editor without needing a separate templating engine. Creating or updating a template auto-resolves a unique slug and, on update, reconciles any embedded image file references inside the new `templateContent` against the previous version — image files that were removed from the markup are cleaned up rather than left as orphaned File records. `POST /templates/background-image` is a dedicated upload endpoint (validated to be an `image/*` MIME type) used to get a file ID for use inside a template's background, stored under a fixed `lms/certificates/templates/backgrounds` path.
Issued certificates are tracked separately from templates — `GET /lms/certificates/issued` lists certificates that have actually been generated for a student, filterable by `type` (course, exam, course_class_group, or learning_path, validated against a fixed `certificate_type` set) and searchable by student/course name or verification code. `PATCH /issued/:id/public-access` is the only mutation on issued certificates exposed here, toggling whether a certificate can be viewed by anyone with its link versus requiring the owning student to be authenticated — certificate issuance itself (creating new issued-certificate rows) happens elsewhere, likely as a side effect of course/exam completion handled by an event subscriber rather than a direct endpoint in this controller.
HTTP Endpoints
8 endpoints
Lists certificate templates, filterable by name/slug/description and status.
- Query
- page, pageSize, search, status
Gets a template by ID; 404 if missing.
- Params
- id (int)
Creates a template; auto-resolves a unique slug; publishes lms.certificate_template.created.
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | yes | Max 255 chars |
| slug | string | no | Max 255 chars |
| description | string | no | — |
| templateContent | string | yes | HTML/SVG template body |
| status | 'draft' | 'active' | 'inactive' | no | — |
Updates a template; reconciles embedded image file references against the previous version.
- Params
- id (int)
Uploads a background image for templates (validated image/* MIME type).
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| file | File | yes | multipart/form-data |
Deletes a template and cleans up its associated image files.
- Params
- id (int)
Lists issued certificates, filterable by type and searchable by student/course/verification code.
- Query
- page, pageSize, search, type
Toggles public visibility of an issued certificate.
- Params
- id (int)
Body
| Field | Type | Required | Notes |
|---|---|---|---|
| publicAccess | boolean | yes | — |
MCP Tools
Named tools callable by AI models via the Model Context Protocol (MCP).
lms.certificates.templates.listLists certificate templates with optional pagination, search and status filter
lms.certificates.templates.getReturns a single certificate template by ID
lms.certificates.templates.createCreates a new certificate template
lms.certificates.templates.updateUpdates an existing certificate template
lms.certificates.templates.deleteDeletes a certificate template by ID
lms.certificates.issued.listLists issued certificates with optional pagination, search and type filter
lms.certificates.issued.update-public-accessEnables or disables public access for an issued certificate