Added the ability for some exams to be private and not chosen randomly

This commit is contained in:
Tiago Ribeiro
2024-08-28 10:17:01 +01:00
parent 7960e7d8fb
commit 951ca5736e
2 changed files with 20 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
import {collection, getDocs, query, where, setDoc, doc, Firestore, getDoc} from "firebase/firestore";
import {collection, getDocs, query, where, setDoc, doc, Firestore, getDoc, and} from "firebase/firestore";
import {shuffle} from "lodash";
import {Difficulty, Exam, InstructorGender, SpeakingExam, Variant, WritingExam} from "@/interfaces/exam";
import {DeveloperUser, Stat, StudentUser, User} from "@/interfaces/user";
@@ -17,7 +17,7 @@ export const getExams = async (
): Promise<Exam[]> => {
const moduleRef = collection(db, module);
const q = query(moduleRef, where("isDiagnostic", "==", false));
const q = query(moduleRef, and(where("isDiagnostic", "==", false), where("private", "!=", true)));
const snapshot = await getDocs(q);
const allExams = shuffle(