Logotipo Hedhog

Get Hedhog updates in your inbox

New releases, fresh recipes, and breaking changes — no spam.

Back to LMS modulesLMS Submodule

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

FieldTypeRequiredNotes
namestringyesMax 255 chars
slugstringnoMax 255 chars
descriptionstringno
templateContentstringyesHTML/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

FieldTypeRequiredNotes
fileFileyesmultipart/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

FieldTypeRequiredNotes
publicAccessbooleanyes

MCP Tools

Named tools callable by AI models via the Model Context Protocol (MCP).

  • lms.certificates.templates.list

    Lists certificate templates with optional pagination, search and status filter

  • lms.certificates.templates.get

    Returns a single certificate template by ID

  • lms.certificates.templates.create

    Creates a new certificate template

  • lms.certificates.templates.update

    Updates an existing certificate template

  • lms.certificates.templates.delete

    Deletes a certificate template by ID

  • lms.certificates.issued.list

    Lists issued certificates with optional pagination, search and type filter

  • lms.certificates.issued.update-public-access

    Enables or disables public access for an issued certificate