Merge branch 'develop' into ENCOA-83_MasterStatistical
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import {LevelScore} from "@/constants/ielts";
|
||||
import {Stat, User} from "@/interfaces/user";
|
||||
|
||||
type Type = "academic" | "general";
|
||||
|
||||
@@ -178,3 +179,28 @@ export const getLevelLabel = (level: number) => {
|
||||
|
||||
return ["Proficiency", "C2"];
|
||||
};
|
||||
|
||||
export const averageLevelCalculator = (users: User[], studentStats: Stat[]) => {
|
||||
const formattedStats = studentStats
|
||||
.map((s) => ({
|
||||
focus: users.find((u) => u.id === s.user)?.focus,
|
||||
score: s.score,
|
||||
module: s.module,
|
||||
}))
|
||||
.filter((f) => !!f.focus);
|
||||
const bandScores = formattedStats.map((s) => ({
|
||||
module: s.module,
|
||||
level: calculateBandScore(s.score.correct, s.score.total, s.module, s.focus!),
|
||||
}));
|
||||
|
||||
const levels: {[key in Module]: number} = {
|
||||
reading: 0,
|
||||
listening: 0,
|
||||
writing: 0,
|
||||
speaking: 0,
|
||||
level: 0,
|
||||
};
|
||||
bandScores.forEach((b) => (levels[b.module] += b.level));
|
||||
|
||||
return calculateAverageLevel(levels);
|
||||
};
|
||||
|
||||
@@ -137,5 +137,6 @@ export const convertToUserSolutions = (stats: Stat[]): UserSolution[] => {
|
||||
solutions: stat.solutions,
|
||||
type: stat.type,
|
||||
module: stat.module,
|
||||
shuffleMaps: stat.shuffleMaps
|
||||
}));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user