Skip to content

lessons

Lessons — content unit inside a product module. Can be a regular lesson (video / text) or an exam.

  • ETL strategy: merge
  • PK: id

Columns

ColumnTypeDescription
idBIGINTPK.
id_tenantBIGINTFK → tenants.id.
id_originBIGINTParent lesson id when replicated.
id_productBIGINTFK → products.id.
id_sectionBIGINTFK → modules.id. The module that owns the lesson.
id_examBIGINTFK → exams.id. Set only when format = 'exam'. Extracted from meta->>'prova'.
is_draftBOOLEANDraft.
positionINTEGEROrder within the module.
titleTEXTLesson title.
formatTEXTLesson format. Enum — see below.
videoTEXTVideo URL/identifier when applicable.
summaryTEXTDescription.
created_atTIMESTAMPTZ
deleted_atTIMESTAMPTZ

Enum · format

Only exam is normalized; other values are kept verbatim.

ValueMeaning
examThe lesson is the entry point for an exam (linked via id_exam).
video / texto / audio / (others)Other formats are kept unchanged.

Relationships

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;

OpenDB · Cademi LMS Data Warehouse