Add lessons Phase 6: lesson plans with curriculum tracking
Structured lesson plans with nested sections and items per enrollment. Deep create in one request, one-active-per-enrollment constraint, auto-set startedDate/masteredDate on status transitions, progress % calculation (skipped items excluded). 8 new tests (84 total).
This commit is contained in:
43
packages/backend/src/db/migrations/0033_lesson_plans.sql
Normal file
43
packages/backend/src/db/migrations/0033_lesson_plans.sql
Normal file
@@ -0,0 +1,43 @@
|
||||
-- Phase 6: Lesson plans — structured curriculum per enrollment
|
||||
|
||||
CREATE TYPE "lesson_plan_item_status" AS ENUM ('not_started', 'in_progress', 'mastered', 'skipped');
|
||||
|
||||
CREATE TABLE "member_lesson_plan" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
"member_id" uuid NOT NULL REFERENCES "member"("id"),
|
||||
"enrollment_id" uuid NOT NULL REFERENCES "enrollment"("id"),
|
||||
"created_by" uuid REFERENCES "user"("id"),
|
||||
"title" varchar(255) NOT NULL,
|
||||
"description" text,
|
||||
"is_active" boolean NOT NULL DEFAULT true,
|
||||
"started_date" date,
|
||||
"completed_date" date,
|
||||
"created_at" timestamptz NOT NULL DEFAULT now(),
|
||||
"updated_at" timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE "lesson_plan_section" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
"lesson_plan_id" uuid NOT NULL REFERENCES "member_lesson_plan"("id"),
|
||||
"title" varchar(255) NOT NULL,
|
||||
"description" text,
|
||||
"sort_order" integer NOT NULL,
|
||||
"created_at" timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE "lesson_plan_item" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
"section_id" uuid NOT NULL REFERENCES "lesson_plan_section"("id"),
|
||||
"title" varchar(255) NOT NULL,
|
||||
"description" text,
|
||||
"status" lesson_plan_item_status NOT NULL DEFAULT 'not_started',
|
||||
"grading_scale_id" uuid REFERENCES "grading_scale"("id"),
|
||||
"current_grade_value" varchar(50),
|
||||
"target_grade_value" varchar(50),
|
||||
"started_date" date,
|
||||
"mastered_date" date,
|
||||
"notes" text,
|
||||
"sort_order" integer NOT NULL,
|
||||
"created_at" timestamptz NOT NULL DEFAULT now(),
|
||||
"updated_at" timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
@@ -232,6 +232,13 @@
|
||||
"when": 1774920000000,
|
||||
"tag": "0032_grading_scales",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 33,
|
||||
"version": "7",
|
||||
"when": 1774930000000,
|
||||
"tag": "0033_lesson_plans",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user