root = Card([header, kpiBlock, cohortSelector, engagementSection, coursesSection, riskSection, messageSection])
header = CardHeader("Training Platform Analytics", "Weekly cohort performance & learner health")
kpiBlock = SnippetCardBlock([kpiActive, kpiCompletion, kpiQuiz], "grid", true)
kpiActive = SnippetCardItem("active-learners", kpiActiveLhs, kpiActiveRhs)
kpiActiveLhs = IconText(kpiActiveIcon, "success", "m", "Active Learners", "This week", false, "horizontal")
kpiActiveIcon = Icon("users", "people")
kpiActiveRhs = BoldText("number", "1,247", "+8.2%", "metric")
kpiCompletion = SnippetCardItem("completion-rate", kpiCompletionLhs, kpiCompletionRhs)
kpiCompletionLhs = IconText(kpiCompletionIcon, "info", "m", "Completion Rate", "All courses", false, "horizontal")
kpiCompletionIcon = Icon("circle-check", "shapes")
kpiCompletionRhs = BoldText("number", "73.4%", "+2.1%", "metric")
kpiQuiz = SnippetCardItem("avg-quiz-score", kpiQuizLhs, kpiQuizRhs)
kpiQuizLhs = IconText(kpiQuizIcon, "neutral", "m", "Avg. Quiz Score", "Across all assessments", false, "horizontal")
kpiQuizIcon = Icon("award", "shapes")
kpiQuizRhs = BoldText("number", "84.7%", "+1.3%", "metric")
cohortSelector = Form("cohort-filter", cohortButtons, [fcCohort])
cohortButtons = Buttons([btnApply], "row")
btnApply = Button("Apply Filter", { type: "continue_conversation", context: "Filter all dashboard data to the selected cohort" }, "primary")
fcCohort = FormControl("Select Cohort", cohortSelect, "Narrow all metrics to a specific cohort")
cohortSelect = Select("cohort", [c1, c2, c3, c4, c5], "All Cohorts")
c1 = SelectItem("all", "All Cohorts")
c2 = SelectItem("cohort-2024-q1", "2024 Q1 — New Hires (342 learners)")
c3 = SelectItem("cohort-2024-q2", "2024 Q2 — Interns (187 learners)")
c4 = SelectItem("cohort-2024-q3", "2024 Q3 — Upskilling (415 learners)")
c5 = SelectItem("cohort-2024-q4", "2024 Q4 — Leadership (98 learners)")
engagementSection = SectionBlock([secEngagement], false)
secEngagement = SectionItem("engagement", "Engagement Across Past 8 Weeks", [engagementChart, engagementNote])
engagementChart = LineChart(engWeeks, [engSessions, engActive, engCompletion], "natural", "Week", "Count")
engWeeks = ["W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8"]
engSessions = Series("Sessions", [842, 915, 1023, 978, 1102, 1187, 1247, 1312])
engActive = Series("Active Learners", [892, 934, 1012, 987, 1056, 1102, 1178, 1247])
engCompletion = Series("Completions", [156, 189, 234, 212, 267, 298, 334, 371])
engagementNote = TextContent("Sessions and active learners show steady growth; completions accelerated in weeks 6–8 after the new micro-learning rollout.")
coursesSection = SectionBlock([secCourses], false)
secCourses = SectionItem("courses", "Courses Ranked by Enrollment", [coursesTable, coursesNote])
coursesTable = Table([colCourse, colEnrollment, colCompletion, colAvgScore, colStatus])
colCourse = Col("Course", courseNames, "string")
colEnrollment = Col("Enrollment", enrollments, "number")
colCompletion = Col("Completion %", completions, "string")
colAvgScore = Col("Avg. Quiz Score", avgScores, "string")
colStatus = Col("Status", statuses, "string")
courseNames = ["Data Fundamentals", "Python for Analytics", "SQL Mastery", "ML Foundations", "Data Visualization", "Cloud Basics", "Advanced Statistics", "Capstone Project"]
enrollments = [487, 423, 398, 356, 312, 289, 245, 187]
completions = ["78%", "74%", "71%", "68%", "76%", "82%", "65%", "59%"]
avgScores = ["87%", "84%", "82%", "79%", "86%", "89%", "78%", "81%"]
statuses = ["Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active"]
coursesNote = TextContent("Top 3 courses drive 54% of total enrollment. Capstone Project has lowest completion — consider adding milestone check-ins.")
riskSection = SectionBlock([secRisk], false)
secRisk = SectionItem("risk", "Learners at Risk of Dropping Out", [riskList, riskNote])
riskList = ListBlock([risk1, risk2, risk3, risk4, risk5], "number", "default")
risk1 = ListItem("Sarah Chen", "Cohort: 2024 Q3 • Last active: 14 days ago • 3 missed deadlines • Data Fundamentals", null, null, { type: "continue_conversation", context: "Show intervention options for Sarah Chen" })
risk2 = ListItem("Marcus Johnson", "Cohort: 2024 Q1 • Last active: 11 days ago • Quiz avg: 52% • Python for Analytics", null, null, { type: "continue_conversation", context: "Show intervention options for Marcus Johnson" })
risk3 = ListItem("Priya Patel", "Cohort: 2024 Q4 • Last active: 18 days ago • 2 failed quizzes • ML Foundations", null, null, { type: "continue_conversation", context: "Show intervention options for Priya Patel" })
risk4 = ListItem("James Wilson", "Cohort: 2024 Q2 • Last active: 9 days ago • No forum posts • SQL Mastery", null, null, { type: "continue_conversation", context: "Show intervention options for James Wilson" })
risk5 = ListItem("Aisha Rahman", "Cohort: 2024 Q3 • Last active: 16 days ago • 40% course progress • Data Visualization", null, null, { type: "continue_conversation", context: "Show intervention options for Aisha Rahman" })
riskNote = TextContent("5 learners flagged by the early-warning model (inactivity > 7 days + missed deadlines + low scores). Recommended: automated nudge + mentor outreach.")
messageSection = Form("message-cohort", messageButtons, [fcCohortMsg, fcSubject, fcMessage])
messageButtons = Buttons([btnSend, btnPreview], "row")
btnSend = Button("Send Message", { type: "continue_conversation", context: "Send the composed message to the selected cohort" }, "primary")
btnPreview = Button("Preview", { type: "continue_conversation", context: "Preview the message before sending" }, "secondary")
fcCohortMsg = FormControl("Recipient Cohort", msgCohortSelect, "Select which cohort receives this message")
msgCohortSelect = Select("msg-cohort", [mc1, mc2, mc3, mc4, mc5], "Choose cohort", { required: true })
mc1 = SelectItem("cohort-2024-q1", "2024 Q1 — New Hires (342 learners)")
mc2 = SelectItem("cohort-2024-q2", "2024 Q2 — Interns (187 learners)")
mc3 = SelectItem("cohort-2024-q3", "2024 Q3 — Upskilling (415 learners)")
mc4 = SelectItem("cohort-2024-q4", "2024 Q4 — Leadership (98 learners)")
mc5 = SelectItem("all", "All Learners (1,247 total)")
fcSubject = FormControl("Subject", msgSubjectInput, "Brief, clear subject line")
msgSubjectInput = Input("msg-subject", "e.g. Week 6 Check-in & Reminders", "text", { required: true, maxLength: 100 })
fcMessage = FormControl("Message", msgTextArea, "Markdown supported. Use {{first_name}} for personalization.")
msgTextArea = TextArea("msg-body", "Hi {{first_name}},\n\nQuick reminder: Module 3 deadline is this Friday. Your current progress looks great — keep it up!\n\nIf you're stuck, reply to this message or join office hours Thu 2pm.\n\n— The Learning Team", 8, { required: true, minLength: 20 })