root = Card([header, kpiRow, cohortFilter, engagementChart, enrollmentTable, atRiskList, messageDrawer])
header = CardHeader("Training Analytics", "Weekly cohort performance overview")
kpiRow = Card([activeLearners, completionRate, avgQuizScore], "clear", "row", "m")
activeLearners = Card([activeLabel, activeValue], "sunk", "column", "xs", "center")
activeLabel = TextContent("Active Learners This Week", "small")
activeValue = TextContent("1,247", "large-heavy")
completionRate = Card([completionLabel, completionValue], "sunk", "column", "xs", "center")
completionLabel = TextContent("Course Completion Rate", "small")
completionValue = TextContent("78.3%", "large-heavy")
avgQuizScore = Card([quizLabel, quizValue], "sunk", "column", "xs", "center")
quizLabel = TextContent("Average Quiz Score", "small")
quizValue = TextContent("84.6", "large-heavy")
cohortFilter = Card([filterLabel, cohortSelect], "clear", "row", "m")
filterLabel = TextContent("Filter by Cohort:", "small-heavy")
cohortSelect = Select("cohort_filter", [cohortAll, cohortQ1, cohortQ2, cohortQ3, cohortQ4], "All Cohorts")
cohortAll = SelectItem("all", "All Cohorts")
cohortQ1 = SelectItem("q1_2024", "Q1 2024 - New Hires")
cohortQ2 = SelectItem("q2_2024", "Q2 2024 - Engineering")
cohortQ3 = SelectItem("q3_2024", "Q3 2024 - Sales")
cohortQ4 = SelectItem("q4_2024", "Q4 2024 - Leadership")
engagementChart = Card([engagementTitle, engagementArea], "sunk", "column", "m")
engagementTitle = Heading("Engagement Across Past 8 Weeks", "h3")
engagementArea = AreaChart(engagementLabels, [activeSeries, completedSeries], "natural", "Week", "Active Learners")
engagementLabels = ["Week 1", "Week 2", "Week 3", "Week 4", "Week 5", "Week 6", "Week 7", "Week 8"]
activeSeries = Series("Active Learners", [1180, 1245, 1190, 1320, 1280, 1350, 1290, 1247])
completedSeries = Series("Sessions Completed", [890, 945, 910, 1020, 980, 1050, 1010, 975])
enrollmentTable = Card([enrollmentTitle, coursesTable], "sunk", "column", "m")
enrollmentTitle = Heading("Courses Ranked by Enrollment", "h3")
coursesTable = Table([courseCol, enrolledCol, completedCol, rateCol])
courseCol = Col("Course", ["Python Fundamentals", "Data Analysis with Pandas", "React Frontend Dev", "SQL for Analytics", "ML Foundations", "DevOps Basics", "UX Design Principles", "Cloud Architecture"])
enrolledCol = Col("Enrolled", [342, 287, 256, 234, 198, 176, 154, 123])
completedCol = Col("Completed", [267, 212, 189, 178, 142, 129, 108, 87])
rateCol = Col("Completion %", [78.1, 73.9, 73.8, 76.1, 71.7, 73.3, 70.1, 70.7])
atRiskList = Card([atRiskTitle, atRiskItems], "sunk", "column", "m")
atRiskTitle = Heading("Learners at Risk of Dropping Out", "h3")
atRiskItems = ListBlock([risk1, risk2, risk3, risk4, risk5], "number")
risk1 = ListItem("Sarah Chen", "Last active: 12 days ago • 3 incomplete modules • Score trend: declining", null, "Message")
risk2 = ListItem("Marcus Johnson", "Last active: 15 days ago • 5 incomplete modules • No quiz attempts", null, "Message")
risk3 = ListItem("Priya Patel", "Last active: 9 days ago • 2 incomplete modules • Recent scores below 60%", null, "Message")
risk4 = ListItem("James Wilson", "Last active: 18 days ago • 4 incomplete modules • No forum participation", null, "Message")
risk5 = ListItem("Emily Rodriguez", "Last active: 11 days ago • 3 incomplete modules • Missed 2 deadlines", null, "Message")
messageDrawer = DrawerBlock("Message Cohort", "Send a message to the selected cohort", "Select a cohort and compose your message", [messageForm])
messageForm = Form("message_cohort", messageButtons, [cohortField, subjectField, bodyField])
cohortField = FormControl("Cohort", cohortSelectInput, "Recipients will be filtered by this selection")
cohortSelectInput = Select("message_cohort", [msgCohortAll, msgCohortQ1, msgCohortQ2, msgCohortQ3, msgCohortQ4], "Select cohort")
msgCohortAll = SelectItem("all", "All Cohorts (1,247 learners)")
msgCohortQ1 = SelectItem("q1_2024", "Q1 2024 - New Hires (312 learners)")
msgCohortQ2 = SelectItem("q2_2024", "Q2 2024 - Engineering (289 learners)")
msgCohortQ3 = SelectItem("q3_2024", "Q3 2024 - Sales (345 learners)")
msgCohortQ4 = SelectItem("q4_2024", "Q4 2024 - Leadership (301 learners)")
subjectField = FormControl("Subject", subjectInput, "Brief, clear subject line")
subjectInput = Input("subject", "e.g., Upcoming deadline reminder")
bodyField = FormControl("Message", bodyTextarea, "Markdown supported")
bodyTextarea = TextArea("body", "Write your message here...", 6)
messageButtons = Buttons([sendBtn, cancelBtn])
sendBtn = Button("Send Message", null, "primary")
cancelBtn = Button("Cancel", null, "tertiary")