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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 2x 2x 2x 9x 9x 2x 1x 2x 7x 47x 47x 7x 47x 112x 2x 6x 6x 2256x 2256x 2256x 834x 6x 435x 435x 435x 6x | // GradeHistoryHelper.js
export const allGrades = [
"A+",
"A",
"A-",
"B+",
"B",
"B-",
"C+",
"C",
"C-",
"D+",
"D",
"D-",
"F",
"P",
"W",
"NP",
];
export const qtrNumToQuarter = {
1: "Winter",
2: "Spring",
3: "Summer",
4: "Fall",
};
export const yyyyqToPrettyStr = (yyyyq) => {
const [year, qtr] = [yyyyq.slice(0, 4), yyyyq[4]];
return `${qtrNumToQuarter[qtr]} ${year}`;
};
export const formatTooltip = (value, _, props) => {
return [`Percentage: ${value.toFixed(1)}%, Count: ${props.payload.count}`];
};
export const createCompleteGradeData = (data) => {
const gradeCounts = data.reduce((acc, item) => {
acc[item.grade] = item.count;
return acc;
}, {});
const totalCount = Object.values(gradeCounts).reduce(
(acc, count) => acc + count,
0,
);
return allGrades.map((grade) => ({
grade,
count: gradeCounts[grade] || 0,
percentage:
totalCount > 0 ? ((gradeCounts[grade] || 0) / totalCount) * 100 : 0,
}));
};
export const groupDataByQuarterAndInstructor = (data) => {
const groupedData = {};
data.sort((a, b) => {
const [yearA, qtrA] = [a.yyyyq.slice(0, 4), a.yyyyq[4]];
const [yearB, qtrB] = [b.yyyyq.slice(0, 4), b.yyyyq[4]];
if (yearA !== yearB) return yearB - yearA;
return qtrB - qtrA;
});
data.forEach((item) => {
const key = `${item.yyyyq}-${item.instructor}`;
if (!groupedData[key]) groupedData[key] = [];
groupedData[key].push(item);
});
return groupedData;
};
|