-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmetricExplain.js
More file actions
22 lines (21 loc) · 828 Bytes
/
Copy pathmetricExplain.js
File metadata and controls
22 lines (21 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// metricExplain.js – Generate human‑readable explanations for drill‑down metrics
/**
* Generate an explanation string for a given metric based on provided data.
* Currently supports "topic", "type", and "improvement".
* The data argument should contain whatever is needed for the metric – for the
* demo implementation we pass a simple object with `summary` and optional
* `details` fields.
*/
window.explainMetric = function(metric, data) {
if (!metric) return "";
switch (metric) {
case "topic":
return `Top topics by attempts: ${data.summary}.`; // e.g. "Math (12), Science (8)"
case "type":
return `Question‑type breakdown: ${data.summary}.`;
case "improvement":
return `Overall improvement: ${data.summary}.`;
default:
return "No explanation available.";
}
}