Updated the eval calls to the backend, passed the navigation logic of level to useExamNavigation hook

This commit is contained in:
Carlos-Mesquita
2024-11-26 09:04:38 +00:00
parent bb5326a331
commit 2ed4e6509e
14 changed files with 452 additions and 493 deletions

View File

@@ -5,10 +5,12 @@ import { sessionOptions } from "@/lib/session";
import axios from "axios";
interface Body {
userId: string;
sessionId: string;
question: string;
answer: string;
exerciseId: string;
task: 1 | 2;
id: string;
}
export default withIronSessionApiRoute(handler, sessionOptions);
@@ -20,13 +22,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
return;
}
const body = req.body as Body;
const taskNumber = body.task.toString() !== "1" && body.task.toString() !== "2" ? "1" : body.task.toString();
const { task, ...body} = req.body as Body;
const taskNumber = task.toString() !== "1" && task.toString() !== "2" ? "1" : task.toString();
await axios.post(`${process.env.BACKEND_URL}/grade/writing/${taskNumber}`, body, {
headers: {
Authorization: `Bearer ${process.env.BACKEND_JWT}`,
},
});
res.status(200);
res.status(200).json({ok: true});
}