diff --git a/src/pages/timetable/LessonPlanDetailPage.tsx b/src/pages/timetable/LessonPlanDetailPage.tsx index 27da778..6c01fe5 100644 --- a/src/pages/timetable/LessonPlanDetailPage.tsx +++ b/src/pages/timetable/LessonPlanDetailPage.tsx @@ -39,6 +39,7 @@ interface LessonPlan { year_group: string | null; duration_minutes: number | null; context_notes: string | null; + homework: string | null; objectives: Objective[]; activities: Activity[]; is_public: boolean; @@ -88,6 +89,7 @@ const LessonPlanDetailPage: React.FC = () => { const [yearGroup, setYearGroup] = useState(''); const [duration, setDuration] = useState(''); const [contextNotes, setContextNotes] = useState(''); + const [homework, setHomework] = useState(''); const [isPublic, setIsPublic] = useState(false); const [objectives, setObjectives] = useState([]); const [activities, setActivities] = useState([]); @@ -110,6 +112,7 @@ const LessonPlanDetailPage: React.FC = () => { setYearGroup(data.year_group || ''); setDuration(data.duration_minutes?.toString() || ''); setContextNotes(data.context_notes || ''); + setHomework(data.homework || ''); setIsPublic(data.is_public || false); setObjectives(data.objectives || []); setActivities(data.activities || []); @@ -128,7 +131,7 @@ const LessonPlanDetailPage: React.FC = () => { // ── Save ────────────────────────────────────────────────────────────────── const save = useCallback(async ( - overrides?: Partial<{ title: string; subject: string; year_group: string; duration_minutes: number | null; context_notes: string; is_public: boolean; objectives: Objective[]; activities: Activity[] }> + overrides?: Partial<{ title: string; subject: string; year_group: string; duration_minutes: number | null; context_notes: string; homework: string; is_public: boolean; objectives: Objective[]; activities: Activity[] }> ) => { if (!accessToken || !planId) return; setSaving(true); @@ -143,6 +146,7 @@ const LessonPlanDetailPage: React.FC = () => { year_group: yearGroup || null, duration_minutes: duration ? parseInt(duration, 10) : null, context_notes: contextNotes || null, + homework: homework || '', is_public: isPublic, objectives, activities, @@ -156,7 +160,7 @@ const LessonPlanDetailPage: React.FC = () => { } finally { setSaving(false); } - }, [accessToken, planId, title, subject, yearGroup, duration, contextNotes, isPublic, objectives, activities]); + }, [accessToken, planId, title, subject, yearGroup, duration, contextNotes, homework, isPublic, objectives, activities]); const scheduleAutoSave = useCallback(() => { if (autoSaveTimer.current) clearTimeout(autoSaveTimer.current); @@ -359,6 +363,22 @@ const LessonPlanDetailPage: React.FC = () => { /> + {/* Homework */} + + + Homework + + { setHomework(e.target.value); scheduleAutoSave(); }} + multiline + minRows={2} + fullWidth + size="small" + placeholder="Homework to carry with this plan when assigned to a taught lesson…" + /> + + {/* Objectives */} diff --git a/src/pages/timetable/LessonPlansPage.tsx b/src/pages/timetable/LessonPlansPage.tsx index e0e3a74..08c9b60 100644 --- a/src/pages/timetable/LessonPlansPage.tsx +++ b/src/pages/timetable/LessonPlansPage.tsx @@ -21,6 +21,7 @@ interface PlanSummary { duration_minutes: number | null; objectives: { id: string; text: string; bloom_level?: string }[]; activities: { id: string; section: string; title: string }[]; + homework: string | null; is_public: boolean; created_at: string; updated_at: string; @@ -144,6 +145,7 @@ function PlanCard({ plan, onOpen, onDelete }: { {objCount} objective{objCount !== 1 ? 's' : ''} · {actCount} activit{actCount !== 1 ? 'ies' : 'y'} + {plan.homework ? ' · homework set' : ''} e.stopPropagation()}> diff --git a/src/pages/timetable/StudentLessonsPage.tsx b/src/pages/timetable/StudentLessonsPage.tsx index 789f706..0a670aa 100644 --- a/src/pages/timetable/StudentLessonsPage.tsx +++ b/src/pages/timetable/StudentLessonsPage.tsx @@ -22,6 +22,7 @@ interface Lesson { week_cycle: string; day_of_week: string; status: string; + homework: string | null; teacher_name: string | null; } @@ -95,6 +96,11 @@ function LessonCard({ lesson }: { lesson: Lesson }) { sx={{ height: 16, fontSize: '0.65rem' }} /> + {lesson.homework && ( + + Homework: {lesson.homework.length > 80 ? lesson.homework.slice(0, 80) + '…' : lesson.homework} + + )} {lesson.teacher_name && ( {lesson.teacher_name} diff --git a/src/pages/timetable/TaughtLessonsPage.tsx b/src/pages/timetable/TaughtLessonsPage.tsx index f4ee3c7..4d89eed 100644 --- a/src/pages/timetable/TaughtLessonsPage.tsx +++ b/src/pages/timetable/TaughtLessonsPage.tsx @@ -30,6 +30,7 @@ interface Lesson { day_of_week: string; status: string; lesson_plan: Record; + homework: string | null; notes: string | null; whiteboard_room_id: string | null; } @@ -76,16 +77,18 @@ const STATUS_COLORS: Record void; - onSave: (id: string, updates: { notes?: string; status?: string }) => Promise; + onSave: (id: string, updates: { homework?: string; notes?: string; status?: string }) => Promise; } function LessonEditDialog({ lesson, onClose, onSave }: EditDialogProps) { + const [homework, setHomework] = useState(''); const [notes, setNotes] = useState(''); const [status, setStatus] = useState('planned'); const [saving, setSaving] = useState(false); useEffect(() => { if (lesson) { + setHomework(lesson.homework || ''); setNotes(lesson.notes || ''); setStatus(lesson.status || 'planned'); } @@ -94,7 +97,7 @@ function LessonEditDialog({ lesson, onClose, onSave }: EditDialogProps) { const handleSave = async () => { if (!lesson) return; setSaving(true); - await onSave(lesson.id, { notes, status }); + await onSave(lesson.id, { homework, notes, status }); setSaving(false); onClose(); }; @@ -127,6 +130,16 @@ function LessonEditDialog({ lesson, onClose, onSave }: EditDialogProps) { Substituted + setHomework(e.target.value)} + multiline + minRows={2} + fullWidth + size="small" + placeholder="Homework for this lesson…" + /> + {lesson.homework && ( + + Homework: {lesson.homework.length > 80 ? lesson.homework.slice(0, 80) + '…' : lesson.homework} + + )} {lesson.notes && ( {lesson.notes.length > 80 ? lesson.notes.slice(0, 80) + '…' : lesson.notes} @@ -287,7 +305,7 @@ const TaughtLessonsPage: React.FC = () => { } }; - const handleSaveLesson = async (id: string, updates: { notes?: string; status?: string }) => { + const handleSaveLesson = async (id: string, updates: { homework?: string; notes?: string; status?: string }) => { if (!accessToken) return; await fetch(`${API_BASE}/timetable/lessons/${id}`, { method: 'PATCH', diff --git a/src/utils/tldraw/cc-base/cc-graph/CCPlannedLessonNodeShapeUtil.tsx b/src/utils/tldraw/cc-base/cc-graph/CCPlannedLessonNodeShapeUtil.tsx index 4bfc6e0..ddeb6b2 100644 --- a/src/utils/tldraw/cc-base/cc-graph/CCPlannedLessonNodeShapeUtil.tsx +++ b/src/utils/tldraw/cc-base/cc-graph/CCPlannedLessonNodeShapeUtil.tsx @@ -29,106 +29,112 @@ export class CCPlannedLessonNodeShapeUtil extends CCBaseShapeUtil { const styles = getNodeStyles(shape.type) - + return (
- - - - - - - - - - + - - - - - - - ) } -} \ No newline at end of file +} diff --git a/src/utils/tldraw/cc-base/cc-graph/cc-graph-migrations.ts b/src/utils/tldraw/cc-base/cc-graph/cc-graph-migrations.ts index f53e5fd..ab2375a 100644 --- a/src/utils/tldraw/cc-base/cc-graph/cc-graph-migrations.ts +++ b/src/utils/tldraw/cc-base/cc-graph/cc-graph-migrations.ts @@ -5,7 +5,8 @@ import { CCGraphShape, GraphShapeType } from './cc-graph-types' // Helper function to create version IDs for a shape type const createVersions = (shapeType: GraphShapeType) => { return createShapePropsMigrationIds(shapeType, { - Initial: 1 // All shapes start at version 1 as required by TLDraw + Initial: 1, // All shapes start at version 1 as required by TLDraw + AddPlannedLessonHomework: 2, }) } @@ -21,6 +22,13 @@ const createMigrationSequence = (shapeType: GraphShapeType) => { return props }, }, + ...(shapeType === 'cc-planned-lesson-node' ? [{ + id: versions.AddPlannedLessonHomework, + up: (props: CCGraphShape['props']) => ({ + homework: '', + ...props, + }), + }] : []), ], }) } diff --git a/src/utils/tldraw/cc-base/cc-graph/cc-graph-props.ts b/src/utils/tldraw/cc-base/cc-graph/cc-graph-props.ts index 5419753..9d938a9 100644 --- a/src/utils/tldraw/cc-base/cc-graph/cc-graph-props.ts +++ b/src/utils/tldraw/cc-base/cc-graph/cc-graph-props.ts @@ -199,6 +199,7 @@ export const ccGraphShapeProps = { subject: T.string, teacher_code: T.string, planning_status: T.string, + homework: T.string, topic_code: T.string, topic_name: T.string, lesson_code: T.string, @@ -560,6 +561,7 @@ export const getDefaultCCPlannedLessonNodeProps = () => ({ subject: '', teacher_code: '', planning_status: '', + homework: '', topic_code: '', topic_name: '', lesson_code: '', diff --git a/src/utils/tldraw/cc-base/cc-graph/cc-graph-types.ts b/src/utils/tldraw/cc-base/cc-graph/cc-graph-types.ts index 43cef6a..87be1a0 100644 --- a/src/utils/tldraw/cc-base/cc-graph/cc-graph-types.ts +++ b/src/utils/tldraw/cc-base/cc-graph/cc-graph-types.ts @@ -204,6 +204,7 @@ export type CCPlannedLessonNodeProps = CCGraphShapeProps & { subject: string teacher_code: string planning_status: string + homework: string topic_code: string topic_name: string lesson_code: string