Updated a bit more of the way the codes work

This commit is contained in:
Tiago Ribeiro
2023-10-10 21:17:46 +01:00
parent 0c9a49a9c3
commit 1aa4f0ddfd
9 changed files with 73 additions and 61 deletions

View File

@@ -3,7 +3,8 @@ import {BAND_SCORES} from "@/constants/ielts";
import {Module} from "@/interfaces";
import {User} from "@/interfaces/user";
import useExamStore from "@/stores/examStore";
import {getExamById} from "@/utils/exams";
import {getExam, getExamById} from "@/utils/exams";
import {MODULE_ARRAY} from "@/utils/moduleUtils";
import {writingMarking} from "@/utils/score";
import {Menu} from "@headlessui/react";
import axios from "axios";
@@ -20,13 +21,6 @@ interface Props {
onFinish: () => void;
}
const DIAGNOSTIC_EXAMS = [
["reading", "CurQtQoxWmHaJHeN0JW2"],
["listening", "Y6cMao8kUcVnPQOo6teV"],
["writing", "B1J90R4Lmdn2dwjdHEwj"],
["speaking", "QVFm4pdcziJQZN2iUTDo"],
];
export default function Diagnostic({onFinish}: Props) {
const [focus, setFocus] = useState<"academic" | "general">();
const [levels, setLevels] = useState({reading: -1, listening: -1, writing: -1, speaking: -1});
@@ -43,7 +37,7 @@ export default function Diagnostic({onFinish}: Props) {
};
const selectExam = () => {
const examPromises = DIAGNOSTIC_EXAMS.map((exam) => getExamById(exam[0] as Module, exam[1]));
const examPromises = MODULE_ARRAY.map((module) => getExam(module, true));
Promise.all(examPromises).then((exams) => {
if (exams.every((x) => !!x)) {