Solved a bug with calculations of the stats page
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import { LevelScore } from "@/constants/ielts";
|
||||
import {LevelScore} from "@/constants/ielts";
|
||||
|
||||
type Type = "academic" | "general";
|
||||
|
||||
@@ -96,7 +96,7 @@ const academicMarking: {[key: number]: number} = {
|
||||
|
||||
const levelMarking: {[key: number]: number} = {
|
||||
88: 9, // Advanced
|
||||
64: 8 , // Upper-Intermediate
|
||||
64: 8, // Upper-Intermediate
|
||||
52: 6, // Intermediate
|
||||
32: 4, // Pre-Intermediate
|
||||
16: 2, // Elementary
|
||||
@@ -142,23 +142,24 @@ export const calculateBandScore = (correct: number, total: number, module: Modul
|
||||
};
|
||||
|
||||
export const calculateAverageLevel = (levels: {[key in Module]: number}) => {
|
||||
return Object.keys(levels).reduce((accumulator, current) => levels[current as Module] + accumulator, 0) / 4;
|
||||
return Object.keys(levels).reduce((accumulator, current) => levels[current as Module] + accumulator, 0) / 5;
|
||||
};
|
||||
|
||||
export const getLevelScore = (level: number) => {
|
||||
switch(level) {
|
||||
switch (level) {
|
||||
case 0:
|
||||
return ['Beginner', 'Low A1'];
|
||||
return ["Beginner", "Low A1"];
|
||||
case 2:
|
||||
return ['Elementary', 'High A1/Low A2'];
|
||||
return ["Elementary", "High A1/Low A2"];
|
||||
case 4:
|
||||
return ['Pre-Intermediate', 'High A2/Low B1'];
|
||||
return ["Pre-Intermediate", "High A2/Low B1"];
|
||||
case 6:
|
||||
return ['Intermediate', 'High B1/Low B2'];
|
||||
return ["Intermediate", "High B1/Low B2"];
|
||||
case 8:
|
||||
return ['Upper-Intermediate', 'High B2/Low C1'];
|
||||
return ["Upper-Intermediate", "High B2/Low C1"];
|
||||
case 9:
|
||||
return ['Advanced', 'C1'];
|
||||
default: return [];
|
||||
return ["Advanced", "C1"];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user