From 6412482c063547908b84b15ddcf398ef0d5c7170 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 20 Apr 2020 17:59:24 -0400 Subject: [PATCH] [+] Encapsulate getLevelID() --- src/logic/utils/course-utils.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/logic/utils/course-utils.ts b/src/logic/utils/course-utils.ts index 2c86b4e..3ddf94b 100644 --- a/src/logic/utils/course-utils.ts +++ b/src/logic/utils/course-utils.ts @@ -1,5 +1,6 @@ import Navigation from '@/components/navigation/navigation'; import Constants from '@/constants'; +import {isNumeric} from '@/logic/utils/general-utils'; const LEVEL_AP = {level: 'AP', scaleUp: 1}; const LEVEL_H = {level: 'H', scaleUp: 0.75}; @@ -74,4 +75,23 @@ export class CourseUtils return selected == -1 ? Constants.TERMS[4] : Constants.TERMS[selected + 1]; } + + static getLevelID(level: string) + { + level = level.toLowerCase(); + + if (level == 'ap' || level == 'advanced placement') return 1; + if (level == 'h' || level == 'honors') return 2; + if (level == 'a' || level == 'acc' || level == 'accelerated') return 3; + if (level == 'cp' || level == 'college prep') return 4; + + if (level == 'club') return 101; + if (level == 'sport') return 102; + + if (level == 'none') return 201; + + if (isNumeric(level)) return +level; + + return -1; + } }