Appearance
lessons
Lessons — content unit inside a product module. Can be a regular lesson (video / text) or an exam.
- ETL strategy:
merge - PK:
id
Columns
| Column | Type | Description |
|---|---|---|
id | BIGINT | PK. |
id_tenant | BIGINT | FK → tenants.id. |
id_origin | BIGINT | Parent lesson id when replicated. |
id_product | BIGINT | FK → products.id. |
id_section | BIGINT | FK → modules.id. The module that owns the lesson. |
id_exam | BIGINT | FK → exams.id. Set only when format = 'exam'. Extracted from meta->>'prova'. |
is_draft | BOOLEAN | Draft. |
position | INTEGER | Order within the module. |
title | TEXT | Lesson title. |
format | TEXT | Lesson format. Enum — see below. |
video | TEXT | Video URL/identifier when applicable. |
summary | TEXT | Description. |
created_at | TIMESTAMPTZ | |
deleted_at | TIMESTAMPTZ |
Enum · format
Only exam is normalized; other values are kept verbatim.
| Value | Meaning |
|---|---|
exam | The lesson is the entry point for an exam (linked via id_exam). |
video / texto / audio / (others) | Other formats are kept unchanged. |
Relationships
- Parent:
tenants,products,modules,exams(optional). - Children:
exam_resultsviaid_lesson,lesson_ratings,user_lesson_progressviaid_item = lessons.id.
Lessons eligible for progress
A lesson only counts toward product progress (the basis of user_product_progress) when its module, parent module and product are all published and active. The equivalent filter is:
sql
SELECT l.*
FROM lms.lessons l
JOIN lms.modules m ON m.id = l.id_section AND m.id_tenant = l.id_tenant
LEFT JOIN lms.modules m_parent
ON m_parent.id = m.id_section AND m_parent.id_tenant = m.id_tenant
JOIN lms.products p ON p.id = l.id_product AND p.id_tenant = l.id_tenant
WHERE l.deleted_at IS NULL AND l.is_draft = FALSE
AND m.deleted_at IS NULL AND m.is_draft = FALSE
AND (m_parent.id IS NULL OR (m_parent.deleted_at IS NULL AND m_parent.is_draft = FALSE))
AND p.deleted_at IS NULL AND p.is_draft = FALSE;