All files / src/app/student-page/page/my-grade gradeBands.js

100% Statements 22/22
100% Branches 22/22
100% Functions 3/3
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28              79x 62x 47x 27x 15x       53x 43x 32x 13x 7x       47x 47x 38x    
/**
 * Score-band thresholds shared by the gauge, bar chart, and stat cards on the
 * "My Grade" tab. Mirrors the bands already used by the dashboard GpaCard
 * (`formatGpa.js`) so a grade reads the same qualitative way across the app.
 */
 
export function bandColorKey(value) {
    if (typeof value !== "number" || !Number.isFinite(value)) return null;
    if (value >= 90) return "success";
    if (value >= 80) return "primary";
    if (value >= 70) return "warning";
    return "error";
}
 
export function bandLabel(value) {
    if (typeof value !== "number" || !Number.isFinite(value)) return null;
    if (value >= 90) return "Excellent";
    if (value >= 80) return "Good";
    if (value >= 70) return "Passing";
    return "Needs work";
}
 
export function bandColor(theme, value) {
    const key = bandColorKey(value);
    if (!key) return theme.palette.grey[400];
    return theme.palette[key].main;
}