Logotipo Hedhog

Get Hedhog updates in your inbox

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

Back to LMS modulesLMS Submodule

LMS Submodule

discussions

Student-facing lesson engagement: discussion topics with video-timestamp anchors and likes (shared across enrolled students), and personal time-stamped notes (private to each student).

Source path: libraries/lms/src/course-lesson-discussion, libraries/lms/src/course-lesson-note

Module file: course-lesson-discussion.module.ts, course-lesson-note.module.ts

Introduction

These two controllers sit side-by-side under `/lms/course-lessons/:lessonId/` and look superficially similar — both require the caller to be enrolled in the lesson's course (via a shared `assertStudentAccess` check that resolves `person_id` from the authenticated user and verifies a non-cancelled `course_enrollment`), and both anchor entries to a `playerTimeSeconds` position in the lesson video. The key behavioral difference is visibility: discussion topics are shared across every enrolled student in the lesson — `GET /discussion/topics` returns the full thread tree with no per-user filtering, only computing a `likedByMe` flag per topic for the viewer — while notes are strictly private, with every query filtered to `person_id = caller`. A student cannot see another student's notes under any circumstance.

Discussion replies are not a separate entity; a reply is just another topic row with `parentTopicId` set, and the tree is reconstructed in memory on each read. Likes use a composite-unique `(topic_id, person_id)` row with `ON CONFLICT DO NOTHING` on like and an unconditional delete on unlike, so liking twice or unliking when not liked are both silent no-ops rather than errors. Posted content is run through a manual regex-based sanitizer that strips `<script>`/`<style>` blocks, inline `on*` event attributes, and `javascript:` URIs — it is not a full HTML sanitizer library, so other tags/attributes pass through untouched.

HTTP Endpoints

9 endpoints

Full discussion thread tree for the lesson; requires the caller to be enrolled in the course.

Params
lessonId (int)

Posts a topic, or a reply if parentTopicId is set; content is HTML-sanitized.

Params
lessonId (int)

Body

FieldTypeRequiredNotes
contentstringyesMax 20000 chars
playerTimeSecondsnumberyesMin 0
parentTopicIdnumbernoSet to reply to an existing topic

Likes a topic (idempotent — liking twice is a no-op).

Params
lessonId, topicId (int)

Removes the caller's like (no-op if not previously liked).

Params
lessonId, topicId (int)

Lists the caller's own notes for the lesson, ordered by player timestamp.

Params
lessonId (int)

Gets one of the caller's own notes by ID.

Params
lessonId, id (int)

Creates a private note for the caller on the lesson.

Params
lessonId (int)

Body

FieldTypeRequiredNotes
descriptionstringyesMax 5000 chars
playerTimeSecondsnumberyesMin 0
frameFileIdnumber | nullnoScreenshot frame attachment

Updates one of the caller's own notes.

Params
lessonId, id (int)

Deletes one of the caller's own notes; 204 No Content.

Params
lessonId, id (int)

MCP Tools

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

  • lms.lesson-discussion.topics.list

    Lists discussion topics for a course lesson, returned as a thread tree. Requires enrollment

  • lms.lesson-discussion.topics.create

    Creates a new discussion topic (or reply) on a course lesson

  • lms.lesson-discussion.topics.like

    Likes a discussion topic on a course lesson

  • lms.lesson-discussion.topics.unlike

    Removes the like from a discussion topic on a course lesson

  • lms.lesson-notes.list

    Lists the authenticated user's notes for a course lesson, ordered by player timestamp

  • lms.lesson-notes.get

    Returns a single note by ID for the authenticated user

  • lms.lesson-notes.create

    Creates a new note on a course lesson for the authenticated user

  • lms.lesson-notes.update

    Updates one of the authenticated user's lesson notes

  • lms.lesson-notes.delete

    Deletes one of the authenticated user's lesson notes