Removed unnecessary code

This commit is contained in:
Tiago Ribeiro
2024-09-02 15:32:15 +01:00
parent 7c0e7ef53e
commit 65fa6e64e6
2 changed files with 50 additions and 71 deletions

View File

@@ -341,8 +341,6 @@ const LevelGeneration = ({id}: Props) => {
} }
if (part.type === "blank_space_text") { if (part.type === "blank_space_text") {
console.log({currentExercise});
const exercise: WriteBlanksExercise = { const exercise: WriteBlanksExercise = {
id: v4(), id: v4(),
prompt: "Complete the text below.", prompt: "Complete the text below.",

View File

@@ -1,16 +1,7 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type {NextApiRequest, NextApiResponse} from "next"; import type {NextApiRequest, NextApiResponse} from "next";
import {app} from "@/firebase"; import {app} from "@/firebase";
import { import {getFirestore, setDoc, doc, runTransaction, collection, query, where, getDocs} from "firebase/firestore";
getFirestore,
setDoc,
doc,
runTransaction,
collection,
query,
where,
getDocs,
} from "firebase/firestore";
import {withIronSessionApiRoute} from "iron-session/next"; import {withIronSessionApiRoute} from "iron-session/next";
import {sessionOptions} from "@/lib/session"; import {sessionOptions} from "@/lib/session";
import {Exam, InstructorGender, Variant} from "@/interfaces/exam"; import {Exam, InstructorGender, Variant} from "@/interfaces/exam";
@@ -40,14 +31,7 @@ async function GET(req: NextApiRequest, res: NextApiResponse) {
instructorGender?: InstructorGender; instructorGender?: InstructorGender;
}; };
const exams: Exam[] = await getExams( const exams: Exam[] = await getExams(db, module, avoidRepeated, req.session.user.id, variant, instructorGender);
db,
module,
avoidRepeated,
req.session.user.id,
variant,
instructorGender
);
res.status(200).json(exams); res.status(200).json(exams);
} }
@@ -57,10 +41,6 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
return; return;
} }
if (req.session.user.type !== "developer") {
res.status(403).json({ ok: false });
return;
}
const {module} = req.query as {module: string}; const {module} = req.query as {module: string};
try { try {
@@ -70,6 +50,7 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
createdBy: req.session.user.id, createdBy: req.session.user.id,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
}; };
await runTransaction(db, async (transaction) => { await runTransaction(db, async (transaction) => {
const docRef = doc(db, module, req.body.id); const docRef = doc(db, module, req.body.id);
const docSnap = await transaction.get(docRef); const docSnap = await transaction.get(docRef);