fix(dashboard): cache org stats in Redis with versioned invalidation (#883)

* fix(dashboard): cache org stats in Redis with versioned invalidation

Replace the never-expiring process-local cache in the org dashboard page
load with API-side Redis caching keyed per org. A version stamp prevents
slow reads from writing pre-purge data back into the cache.

Invalidate on course create/update/delete, student enroll/remove, certificate
claim, and progress reset. Remove the dashboard SSR module cache so every
page load reads through the API cache layer.

Fixes #852

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix(dashboard): address PR review on stats cache invalidation

- Validate bust via ZDashStats instead of raw query access
- Use import type for OrganisationAnalytics
- Resolve orgId before course delete so invalidation is reliable
- Invalidate immediately after persisted writes, before fallible side effects
- Invalidate on member role changes and program course access enrollment

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix(dashboard): complete stats cache invalidation coverage

Wire org stats cache purge on lesson completion (manual toggle and
video-watch auto-complete) so topCourses completion percentages stay
fresh. Harden bulk member adds with sequential inserts and a finally
invalidation boundary, and only purge org invite enrollments when new
group memberships were actually inserted.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix(core): make lesson completion stats purge best-effort

Wrap org stats cache invalidation in try/catch so a lookup or Redis
failure cannot turn a successful lesson completion into a 500.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix(dashboard): keep org stats cache through lesson completion

Lesson complete is a high-frequency event and usually does not change
the rounded dashboard percentages. Rely on a 10 minute TTL instead of
purging the snapshot on every completion.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* docs: explain how admin dashboard numbers are calculated

Add a user-facing guide covering headline counts, top courses,
certificates, login activity, and when the 10 minute snapshot refreshes.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

---------
This commit is contained in:
Rotimi Best
2026-08-16 22:15:34 +01:00
committed by GitHub
co-authored by Rotimi Best
parent 9fb75e11d2
commit 2ebb544a81
22 changed files with 558 additions and 57 deletions
+1
View File
@@ -140,6 +140,7 @@ export default defineConfig({
{
label: 'Organization & team',
items: [
'/guides/admin-dashboard',
'/guides/customize-organization',
'/guides/invite-team-member',
'/guides/roles-and-permissions'
+1
View File
@@ -53,6 +53,7 @@ After enrolling, students open the course from **Home** or **My Learning** in th
## Related guides
- [How the Admin Dashboard Works](/guides/admin-dashboard)
- [Creating Your First Course](/guides/create-first-course)
- [Course Types](/guides/course-types)
- [How Course Enrollment Works](/guides/course-enrollment)
@@ -0,0 +1,100 @@
---
title: How the Admin Dashboard Works
description: What each number on your organization dashboard means, how it is calculated, and how quickly it updates.
---
The **admin dashboard** is the first page you see after signing in as an admin or tutor. It is a snapshot of your organization: how many courses you have, how many students are enrolled, who recently earned a certificate, and which courses are furthest along.
Open it from **Dashboard** in the left sidebar, or go to `/org/<your-org>/dash`.
This page is an overview. For a single course’s students, grades, and progress, open that course instead.
## The three headline numbers
These cards sit at the top of the dashboard.
| Card | What it counts | What it does not count |
| --- | --- | --- |
| **Certificates issued** | Every certificate a student has earned on an **active** course | Certificates on deleted courses. The same student earning two course certificates counts as two |
| **Number of courses** | **Active** courses in this organization | Deleted courses. Draft or unpublished courses still count if they have not been deleted |
| **Total students** | Unique students enrolled in at least one **active** course | Tutors and admins. Organization audience members who are not in a course. The same person in several courses still counts as one |
:::info[Students vs audience]
**Total students** is course enrollments, not your full audience list. Someone you imported into Audience but never enrolled in a course will not appear here. See [How Course Enrollment Works](/guides/course-enrollment).
:::
## Top courses
This list shows up to **five** active courses, ranked by how much lesson progress students have logged.
Each row includes:
| Field | Meaning |
| --- | --- |
| **Students** | How many students are enrolled in that course |
| **Completion** | Share of lessons finished across those students. If a course has 10 lessons and 2 students, there are 20 possible completions. Ten finished lessons show as 50% |
| **Certified** | Share of enrolled students who have earned a certificate for that course |
A few things this bar does **not** include:
- Exercises and quizzes — those affect course completion and certificates inside the course, but not this dashboard percentage
- Tutors taking the course
- Deleted courses
If every course has zero lesson completions, the list can look quiet even when enrollments are high. That is expected.
## Recent certifications
The five most recent students who earned a certificate on an active course, with the course name and when they earned it.
A name appears here only after the student meets that course’s certificate rules — not when they finish a single lesson. Configure those rules in [How to Create Certificates](/guides/certificates).
## Student login activity
The bar chart at the bottom answers: **which days of the week are students most active?**
It looks at the last **90 days**. Each student is counted at most once per day, so a student who logs in five times on Monday still adds one to Monday. The chart is a weekly pattern, not a raw login volume.
## How fresh the numbers are
The dashboard is a **snapshot**, not a live ticker. ClassroomIO keeps that snapshot for **10 minutes** so the page stays fast when several people open it.
Some changes skip the wait and refresh the snapshot right away:
| What you (or a student) just did | Dashboard updates |
| --- | --- |
| Create, delete, or change a course’s status | Immediately |
| Enroll or unenroll a student | Immediately |
| Change someone’s role to or from student | Immediately |
| A student earns a certificate | Immediately |
| Reset a student’s course progress | Immediately |
| A student marks a lesson complete | Within 10 minutes |
| Students log in | Login chart: within about a day |
That is why creating a course should bump **Number of courses** as soon as you return to the dashboard, while a lesson completion may take a few minutes to move the **Completion** bar.
:::tip[If a number looks wrong]
Refresh the page once. If you just created a course or enrolled someone, the headline cards should already match. If you are watching lesson completion, wait up to 10 minutes — one finished lesson often will not move a rounded percentage anyway.
:::
## Common questions
**Why is Total students smaller than my Audience list?**
Audience includes people you invited or imported who may not be in a course yet. The dashboard only counts students enrolled in an active course.
**Why did Number of courses not include a course I just deleted?**
Deleted courses are left out on purpose. Only active courses are counted.
**Why is Completion 0% when students are taking quizzes?**
The dashboard completion bar is lesson-based. Exercise progress shows inside the course, not on this overview.
**Why did a certificate not show up under Certificates issued?**
Certificates need to be enabled for your plan, and the student must meet that course’s rules (threshold, optional final exercise, optional deadline). Free-plan organizations do not issue certificates.
## Related guides
- [Creating Your First Course](/guides/create-first-course)
- [How Course Enrollment Works](/guides/course-enrollment)
- [How to Create Certificates](/guides/certificates)
- [Control Course Progression](/guides/course-progression)
- [Student Dashboard](/student-dashboard) — what learners see after they sign in
@@ -90,6 +90,7 @@ Once a student meets all the configured requirements, their certificate appears
## Related guides
- [How the Admin Dashboard Works](/guides/admin-dashboard) — certificates issued and recent certifications on the org dashboard
- [Creating Your First Course](/guides/create-first-course) — course setup overview
- [How to Create an Exercise](/guides/create-exercise) — create the exercise you reference as a final exercise
- [How to Grade an Exercise](/guides/grade-exercise) — grade submissions before certificates are issued
+3
View File
@@ -23,6 +23,9 @@ classes, enrolling students, publishing your landing pages, and managing your or
<Card title="Terminology" href="/terminology" icon="book-a">
The words ClassroomIO uses, and what they mean.
</Card>
<Card title="Admin dashboard" href="/guides/admin-dashboard" icon="chart-column">
What each dashboard number means, and how quickly it updates.
</Card>
</CardGroup>
## Developer Guides
+5
View File
@@ -23,6 +23,10 @@ On creation, each org gets `https://<siteName>.myclassroomio.com` as its academy
Share your academy URL with students. The generic `app.classroomio.com` host is for platform access when no org subdomain applies. Course and enroll links should use your academy when possible.
:::
## Dashboard numbers
The organization **Dashboard** is a snapshot of active courses, unique enrolled students, certificates, and login patterns. See [How the Admin Dashboard Works](/guides/admin-dashboard) for what each number includes and how quickly it refreshes.
## Courses and cohorts inside an org
- **Courses** are individual learning containers. See [Course](/course).
@@ -31,6 +35,7 @@ Share your academy URL with students. The generic `app.classroomio.com` host is
## Related guides
- [How the Admin Dashboard Works](/guides/admin-dashboard)
- [Customize Your Organization](/guides/customize-organization)
- [Customize Your Academy Landing Page](/guides/org-landing-page)
- [Set Up a Custom Domain](/guides/custom-domain)
@@ -82,5 +82,6 @@ If you added them from **People** but they have not signed in yet, they may show
- [How Course Enrollment Works](/guides/course-enrollment) — how students join courses and what settings control access
- [How to Invite Students](/guides/invite-students) — send enrollment links by email
- [How the Admin Dashboard Works](/guides/admin-dashboard) — org-level numbers admins see
- [Cohorts](/cohorts) — multi-course tracks and goals for admins
- [Create a Course Landing Page](/guides/course-landingpage) — what prospects see before enrolling