Added level export to excel
This commit is contained in:
23
src/utils/grading.be.ts
Normal file
23
src/utils/grading.be.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { app } from "@/firebase";
|
||||
import { getFirestore, doc, getDoc } from "firebase/firestore";
|
||||
import { CEFR_STEPS } from "@/resources/grading";
|
||||
import { getUserCorporate } from "@/utils/groups.be";
|
||||
import { User } from "@/interfaces/user";
|
||||
import { Grading } from "@/interfaces";
|
||||
const db = getFirestore(app);
|
||||
|
||||
export const getGradingSystem = async (user: User): Promise<Grading> => {
|
||||
const snapshot = await getDoc(doc(db, "grading", user.id));
|
||||
if (snapshot.exists()) return snapshot.data() as Grading;
|
||||
|
||||
if (user.type !== "teacher" && user.type !== "student")
|
||||
return { steps: CEFR_STEPS, user: user.id };
|
||||
|
||||
const corporate = await getUserCorporate(user.id);
|
||||
if (!corporate) return { steps: CEFR_STEPS, user: user.id };
|
||||
|
||||
const corporateSnapshot = await getDoc(doc(db, "grading", corporate.id));
|
||||
if (corporateSnapshot.exists()) return corporateSnapshot.data() as Grading;
|
||||
|
||||
return { steps: CEFR_STEPS, user: user.id };
|
||||
};
|
||||
Reference in New Issue
Block a user