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

@@ -15,6 +15,7 @@ interface ExamBase {
shuffle?: boolean;
createdBy?: string; // option as it has been added later
createdAt?: string; // option as it has been added later
private?: boolean;
}
export interface ReadingExam extends ExamBase {
module: "reading";
@@ -67,7 +68,7 @@ export interface UserSolution {
};
exercise: string;
isDisabled?: boolean;
shuffleMaps?: ShuffleMap[]
shuffleMaps?: ShuffleMap[];
}
export interface WritingExam extends ExamBase {
@@ -103,7 +104,6 @@ export interface Evaluation {
misspelled_pairs?: {correction: string | null; misspelled: string}[];
}
type InteractivePerfectAnswerKey = `perfect_answer_${number}`;
type InteractiveTranscriptKey = `transcript_${number}`;
type InteractiveFixedTextKey = `fixed_text_${number}`;
@@ -112,11 +112,7 @@ type InteractivePerfectAnswerType = { [key in InteractivePerfectAnswerKey]: { an
type InteractiveTranscriptType = {[key in InteractiveTranscriptKey]?: string};
type InteractiveFixedTextType = {[key in InteractiveFixedTextKey]?: string};
interface InteractiveSpeakingEvaluation extends Evaluation,
InteractivePerfectAnswerType,
InteractiveTranscriptType,
InteractiveFixedTextType { }
interface InteractiveSpeakingEvaluation extends Evaluation, InteractivePerfectAnswerType, InteractiveTranscriptType, InteractiveFixedTextType {}
interface SpeakingEvaluation extends CommonEvaluation {
perfect_answer_1?: string;
@@ -208,7 +204,7 @@ export interface FillBlanksMCOption {
B: string;
C: string;
D: string;
}
};
}
export interface FillBlanksExercise {
@@ -306,10 +302,10 @@ export interface ShuffleMap {
questionID: string;
map: {
[key: string]: string;
}
};
}
export interface Shuffles {
exerciseID: string;
shuffles: ShuffleMap[]
shuffles: ShuffleMap[];
}

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(