Removed unnecessary code
This commit is contained in:
@@ -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.",
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user