root = Card([header, kpiRow, cohortSelector, enrollmentChart, engagementChart, riskTable, messageAction])
header = CardHeader("Training Platform Analytics", "Weekly cohort performance overview")
kpiRow = Card([activeLearners, completionRate, avgQuizScore], "clear", "row", "m", "stretch", "between")
activeLearners = Callout("success", "Active Learners This Week", "1,247 learners")
completionRate = Callout("info", "Course Completion Rate", "78.3%")
avgQuizScore = Callout("neutral", "Average Quiz Score", "84.2 / 100")
cohortSelector = Card([cohortLabel, cohortSelect], "clear", "row", "m", "center", "between")
cohortLabel = TextContent("Filter by cohort:", "small-heavy")
cohortSelect = Select("cohort_filter", cohortOptions, "All cohorts", null, "medium")
cohortOptions = [optAll, optQ1, optQ2, optQ3, optQ4]
optAll = SelectItem("all", "All cohorts")
optQ1 = SelectItem("q1-2024", "Q1 2024 Cohort")
optQ2 = SelectItem("q2-2024", "Q2 2024 Cohort")
optQ3 = SelectItem("q3-2024", "Q3 2024 Cohort")
optQ4 = SelectItem("q4-2024", "Q4 2024 Cohort")
enrollmentChart = Card([enrollmentHeading, enrollmentBar], "sunk")
enrollmentHeading = Heading("Courses Ranked by Enrollment", "h3")
enrollmentBar = HorizontalBarChart(enrollLabels, [enrollSeries], "grouped", "Enrollments", "Course")
enrollLabels = ["Python Fundamentals", "Data Science Bootcamp", "Web Dev Essentials", "ML Foundations", "Cloud Architecture", "DevOps Practitioner", "React Advanced", "SQL Mastery"]
enrollSeries = Series("Enrolled", [342, 287, 256, 213, 198, 174, 156, 134])
engagementChart = Card([engagementHeading, engagementLine], "sunk")
engagementHeading = Heading("Engagement Across Past 8 Weeks", "h3")
engagementLine = LineChart(engageLabels, [engageActive, engageCompleted, engageQuiz], "natural", "Week", "Count")
engageLabels = ["W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8"]
engageActive = Series("Active Learners", [1180, 1210, 1195, 1240, 1225, 1260, 1247, 1247])
engageCompleted = Series("Lessons Completed", [8420, 9150, 8980, 9620, 9410, 9870, 9750, 9920])
engageQuiz = Series("Quizzes Taken", [3120, 3450, 3380, 3610, 3540, 3720, 3680, 3750])
riskTable = Card([riskHeading, riskTableData], "sunk")
riskHeading = Heading("Learners at Risk of Dropping Out", "h3")
riskTableData = Table([riskName, riskCourse, riskLastActive, riskScore, riskStatus])
riskName = Col("Learner", ["A. Chen", "M. Rodriguez", "J. Kim", "S. Patel", "R. Okafor", "L. Nguyen", "D. Brooks", "K. Suzuki"])
riskCourse = Col("Course", ["Data Science Bootcamp", "ML Foundations", "Cloud Architecture", "Python Fundamentals", "DevOps Practitioner", "React Advanced", "Web Dev Essentials", "SQL Mastery"])
riskLastActive = Col("Last Active", ["12 days ago", "9 days ago", "14 days ago", "11 days ago", "10 days ago", "13 days ago", "8 days ago", "15 days ago"])
riskScore = Col("Avg Quiz Score", [52, 48, 55, 50, 47, 53, 51, 49])
riskStatus = Col("Risk Level", ["High", "High", "High", "Medium", "High", "Medium", "Medium", "High"])
messageAction = Card([messageHeading, messageBtn], "clear", "row", "m", "center", "between")
messageHeading = Heading("Communicate with Cohort", "h3")
messageBtn = Button("Message Selected Cohort", null, "primary", "normal", "medium")