DocsChapter 8 — Teacher Management

Chapter 8 — Teacher Management & Academic Workspace

Shipped

Complete teacher-facing workspace covering profile management, homework, student observations, leave management, performance analytics, and Elite AI Copilot tools powered by Gemini 2.0 Flash.

Backend: Node.js / Express / MongoDBFrontend: Next.js (App Router)Mobile: React Native / ExpoAI: Gemini 2.0 Flash (Elite)

Basic Tier — All Schools

  • Teacher Profile & Identity (§8.1–8.10)
  • Subject & Class Teacher Assignments (§8.11–8.20)
  • Homework Management (§8.26–8.28)
  • Student Observations (§8.37–8.38)
  • Leave Management with Substitute (§8.41–8.42)
  • Performance Analytics (§8.43–8.44)

Elite Tier — AI Copilot Tools

  • Worksheet Generator (§8.46)
  • Quiz Generator (§8.47)
  • Evaluation Assistant (§8.48)
  • Report Card Comments (§8.49)
  • Observation Assistant (§8.50)
  • Teacher Copilot / Chat (§8.51)
  • Class Recording Summary (§8.45)

Guarded by checkEliteTier middleware (backend) + EliteGuard component (frontend)

Basic Tier — Feature Details

Teacher Profile & Identity (§8.1–8.10)

  • TeacherProfile model supplements the User document (one-to-one)
  • Employee ID, department, designation, joining date, employment type (full-time / part-time / contract / guest / visiting)
  • Qualifications array: degree, university, year of completion, specialization, certificate URL
  • Status state machine: pending → active → on_leave → suspended → inactive → archived
  • Emergency contact, bio, and comprehensive metrics object
  • Admin can search, filter by status/employment-type, and view subject & class-teacher summary

Subject & Class Teacher Assignments (§8.11–8.20)

  • Subject assignments array: subject, class, section, academic year, isActive flag
  • PATCH /api/teacher-profiles/:id/subject-assignments — full array replacement
  • Class teacher assignment: PATCH /api/teacher-profiles/:id/class-teacher (stored as classTeacherOf[] on TeacherProfile)
  • Dashboard summary: today's sessions, this-month sessions, class teacher status
  • Admin view: school-wide teacher list with subject counts badges
  • Teacher-profile CRUD UI lives on the admin side (dashboard/admin/teachers), not under dashboard/teacher/ — teachers themselves only hit GET dashboard-summary and GET/PUT their own :id

Homework Management (§8.26–8.28)

  • Homework model separate from Assignments (lighter-weight, class-level)
  • Lifecycle: draft → published → closed
  • PATCH /api/homework/:id/publish — publishes to students at a point in time
  • Student submission subdocs: content, attachments, status, feedback, marks, reviewedAt
  • POST /api/homework/:id/submit — deadline check, duplicate prevention
  • PATCH /api/homework/:id/review/:studentId — marks + feedback per student
  • GET /api/homework/student/my — student's own homework with submission status
  • Frontend: list with status filter tabs, create modal, view submissions modal
  • Mobile: FlatList with filter chips, create modal, publish button on draft items

Student Observations (§8.37–8.38)

  • Observation types: academic / behavior / participation / leadership / health / other
  • Visibility levels: private / shared / parent_visible
  • Follow-up system: followUpRequired flag, followUpDate, PATCH /complete-followup
  • Tags for cross-observation filtering
  • GET /api/teacher-observations/student/:studentId — student-level view for parents/admin
  • Frontend: type-filter chip row, create modal with visibility selector
  • Mobile: color-coded type badges, follow-up completion button per card

Teacher Leave Management (§8.41–8.42)

  • Leave types: casual / sick / earned / maternity / paternity / emergency / duty / other
  • Auto-computed totalDays in pre-save Mongoose hook
  • Status flow: pending → approved / rejected; teacher can cancel pending only
  • PATCH /api/teacher-leaves/:id/review — admin approves or rejects with remarks
  • Substitute management: assign substitute teacher, notes, assignedBy, assignedAt
  • GET /api/teacher-leaves/available-substitutes — teachers without conflicting approved leaves
  • Frontend: apply modal, cancel button for pending leaves, substitute info card
  • Mobile: status-filter chips, leave type selector, date inputs, Alert confirm for cancel

Teacher Analytics & Performance (§8.43–8.44)

  • GET /api/teacher-analytics/my — personal overview (sessions, completion rate, homework, quizzes, assignments, subjects, leave days, isClassTeacher)
  • Monthly session trend via MongoDB aggregation ($group by year+month)
  • Subject breakdown: sessions grouped by course name
  • GET /api/teacher-analytics/school — admin view: sessions per teacher this month
  • GET /api/teacher-analytics/workload — subject counts assignments per teacher
  • Frontend: stat cards grid, bar chart for monthly trend, progress bars for subject breakdown
  • Mobile: scrollable stats grid with colored left borders, bar chart, progress bars

Elite Tier — AI Copilot Tools (§8.45–8.51)

All AI endpoints POST to /api/teacher-ai/<tool> and require thecheckEliteTier middleware. Powered by Google Gemini 2.0 Flash. Responses are structured JSON for easy rendering.

Worksheet Generator (§8.46)

POST /api/teacher-ai/worksheet-generator — topic, subject, grade → structured worksheet JSON with title, instructions, and questions array.

Quiz Generator (§8.47)

POST /api/teacher-ai/quiz-generator — topic, subject, grade → quiz JSON with MCQ and short-answer questions including correct answers.

Evaluation Assistant (§8.48)

POST /api/teacher-ai/evaluation-assistant — expectedAnswer, studentAnswer, optional rubric → suggestedMarks, percentage, grade, detailedFeedback.

Report Card Comments (§8.49)

POST /api/teacher-ai/report-card-comments — studentName, grade, subject → 3 comment variations (encouraging / formal / balanced).

Observation Assistant (§8.50)

POST /api/teacher-ai/observation-assistant — raw teacher notes → structured observation JSON (type, title, content, tags, followUpRequired).

Teacher Copilot (§8.51)

POST /api/teacher-ai/copilot — free-form question + subject → answer, keyPoints[], tips[]. The general-purpose AI assistant for teachers.

Class Recording Summary (§8.45)

POST /api/teacher-ai/recording-summary — summarizes an uploaded class recording into key topics, homework mentioned, and action items (generateRecordingSummary in teacherAiCopilotController.js).

API Endpoints Summary

GET/POST/api/teacher-profilesList / create teacher profiles (admin)
GET/PUT/PATCH/api/teacher-profiles/:idGet / update / patch profile fields
PATCH/api/teacher-profiles/:id/subject-assignmentsReplace subject assignment array
PATCH/api/teacher-profiles/:id/class-teacherSet class teacher assignment
GET/api/teacher-profiles/dashboard-summaryTeacher dashboard stats
GET/POST/api/homeworkList / create homework
PATCH/api/homework/:id/publishPublish draft homework
POST/api/homework/:id/submitStudent submits homework
PATCH/api/homework/:id/review/:studentIdTeacher reviews submission
GET/api/homework/student/myStudent's own homework list
GET/POST/api/teacher-observationsList / create observations
PATCH/api/teacher-observations/:id/complete-followupMark follow-up done
GET/api/teacher-observations/student/:studentIdObservations for a student
GET/POST/api/teacher-leavesList / apply leave
PATCH/api/teacher-leaves/:id/reviewAdmin approve/reject leave
PATCH/api/teacher-leaves/:id/cancelTeacher cancels pending leave
PATCH/api/teacher-leaves/:id/assign-substituteAssign substitute teacher
GET/api/teacher-leaves/available-substitutesTeachers without conflicting leaves
GET/api/teacher-analytics/myPersonal analytics overview
GET/api/teacher-analytics/schoolSchool-wide teacher analytics (admin)
GET/api/teacher-analytics/workloadWorkload report per teacher
POST ★/api/teacher-ai/worksheet-generatorElite: AI worksheet
POST ★/api/teacher-ai/quiz-generatorElite: AI quiz
POST ★/api/teacher-ai/evaluation-assistantElite: AI evaluation
POST ★/api/teacher-ai/report-card-commentsElite: report card comments
POST ★/api/teacher-ai/observation-assistantElite: structure observations
POST ★/api/teacher-ai/copilotElite: teacher chat / Q&A
POST ★/api/teacher-ai/recording-summaryElite: summarize an uploaded class recording

Frontend Pages

Real pages under src/app/dashboard/teacher/. Note the folder is singularleave/, not leaves/. A separatedashboard/teacher/copilot page is a distinct Storybook-AI-style copilot (Chapter 24), not the same as the ai-tools page's Teacher Copilot tab documented above. Teacher-profile CRUD lives at dashboard/admin/teachers (admin-side).

dashboard/teacher/homework
dashboard/teacher/observations
dashboard/teacher/leave
dashboard/teacher/analytics
dashboard/teacher/ai-tools (Elite — all 7 AI copilot tools)
dashboard/admin/teachers (Teacher profile CRUD, admin-side)

Mobile Screens

(teacher)/index, attendance, courses, quizzes
(teacher)/sessions, lesson-plans, discussions, live-monitor
(teacher)/homework, observations, leave, analytics
(teacher)/assignments, syllabus-tracking, notifications, surveys, survey-detail
(teacher)/messages, notices, profile
(teacher)/ai-tools + ai-insights (Elite AI copilot tools)
(teacher)/ai-copilot (Elite — distinct from ai-tools, Chapter 24-style copilot)
(teacher)/my-hr (self-service HR/leave surface)
(teacher)/handwriting, handwriting-evaluate, handwriting-at-risk (Elite, Chapter 25)
(teacher)/storybook (Elite, Chapter 24)