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).
44 lines
1.5 KiB
SQL
44 lines
1.5 KiB
SQL
-- 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()
|
|
);
|