feat(b2b-analytics): add a Learner progress section to org/contract analytics - #4004
Open
daniellefrappier18 wants to merge 5 commits into
Open
daniellefrappier18 wants to merge 5 commits into
daniellefrappier18 wants to merge 5 commits into
Conversation
OpenAPI Changes44 changes: 0 error, 24 warning, 20 info Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Enrollment scope, API documentation, and touch-device link visibility need correction.
Review effort: Balanced
Findings: 2
Open (4)
What changed in this PR
Adds contract-scoped learner progress analytics to the B2B dashboard.
Changes:
- Adds enrollment-status KPI tiles and distribution bars.
- Extends analytics API types, exports, colors, and test factories.
- Tests rendering, organization-level omission, links, and accessibility context.
| File | Description |
|---|---|
AnalyticsContent.tsx |
Queries and renders learner progress. |
AnalyticsContent.test.tsx |
Tests dashboard integration. |
LearnerProgressCard.tsx |
Implements KPIs and distribution UI. |
chartPalette.ts |
Adds progress-status colors. |
types.ts |
Defines status-count response data. |
factories.ts |
Generates status-count fixtures. |
organizations/index.ts |
Exports the new type. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- keep the "View all learners" tile link visible on touch devices — opacity: 0 is now gated to @media (hover: hover), since there's no hover state to reveal it and no other way to discover the control - fix CompletionStatusCounts' doc comment: the four buckets sum to total_count minus outcomes_withheld_count, not total_count itself (only looks otherwise today because outcomes_withheld_count is currently always zero) - scope the section's copy and comment to active enrollments, matching include_inactive being deliberately left unset — a deactivated or refunded seat shouldn't count as "enrolled" Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What are the relevant tickets?
N/A — no mit-learn issue tracks this directly
learner-progressendpoint'scompletion_status_countsfield this section reads was added in ol-analytics-api PR ContentFiles for edx/ocw learning resources #68.Description (What does it do?)
Adds a "Learner progress" section to the org/contract analytics dashboard (
AnalyticsContent), directly under "Contract utilization". Contract-scoped only — there's no org-wide equivalent endpoint, so the section is absent entirely on the org-wide aggregate page (same restriction as the existing "Learner analytics" link).Four KPI tiles (Enrolled / Not started / In progress / Completed) plus a directly-labeled distribution row per status, each showing a proportional bar, count, and percent of total.
passedandcertifiedare folded into one "Completed" bucket/tile, matching the grouping the learner directory's Status filter already uses.This matches the shape of Ferdi's prototype at mit-learn-prototypes.vercel.app/b2b-stats, but ships a deliberately smaller surface — only what a real backend field supports today. Compared to the prototype, this PR does not render:
not_started OR 30+ days since last activity. No such aggregate exists yet;last_active_onis hardcoded null on every row today. Tracked as follow-up backend work, not fabricated here.Screenshots (if appropriate):
Hover:

Using NVDA
learners_NVDA.mp4
How can this be tested?
This assumes you're running local dev for this branch on the Tilt/k3d stack (
~/Desktop/work/ol-infrastructure), notdocker compose.Prerequisite: mitxonline manager access — this page won't resolve without a mitxonline user with
is_manager=Trueon some org with at least one contract.1. Confirm the analytics-api stub is running, and is the latest version. This section's data comes from a local-dev-only stub — not from anything set up in mitxonline. It needs the two most recent commits on
daniellef/analytics-api-stub(ol-infrastructure, PR #5788): one addscompletion_status_counts; the other reconciles the stub's course-level enrollment counts against the same learner fixture, so "Learner progress" and "Course performance" no longer show contradictory numbers for the same contract.If nothing's running, or it's running an older copy, either check out/pull
daniellef/analytics-api-stuband re-runtilt up, or apply the manifest below directly:analytics-api-stub.yaml (kubectl apply -f -, then kubectl rollout restart deployment analytics-api -n mit-learn)
Enable the b2b-analytics-dashboard PostHog feature flag, sign in at https://learn.mit.dev, open an org you manage, and go to a contract's analytics page (/organization//contract//analytics).
Additional Context