Updated the writing evaluation to use the different endpoints

This commit is contained in:
Tiago Ribeiro
2024-03-26 21:46:53 +00:00
parent 259ed03ee4
commit bb7558afb8
3 changed files with 11 additions and 4 deletions

View File

@@ -286,10 +286,10 @@ export default function ExamPage({page}: Props) {
const responses: UserSolution[] = (
await Promise.all(
exam.exercises.map(async (exercise) => {
exam.exercises.map(async (exercise, index) => {
const evaluationID = uuidv4();
if (exercise.type === "writing")
return await evaluateWritingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!, evaluationID);
return await evaluateWritingAnswer(exercise, index + 1, solutions.find((x) => x.exercise === exercise.id)!, evaluationID);
if (exercise.type === "interactiveSpeaking" || exercise.type === "speaking")
return await evaluateSpeakingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!, evaluationID);

View File

@@ -11,6 +11,7 @@ import {writingReverseMarking} from "@/utils/score";
interface Body {
question: string;
answer: string;
task: 1 | 2;
id: string;
}
@@ -62,7 +63,7 @@ async function getCorrespondingStat(id: string, index: number): Promise<Stat> {
}
async function evaluate(body: Body): Promise<AxiosResponse> {
const backendRequest = await axios.post(`${process.env.BACKEND_URL}/writing_task2`, body as Body, {
const backendRequest = await axios.post(`${process.env.BACKEND_URL}/writing_task${body.task.toString() || "1"}`, body as Body, {
headers: {
Authorization: `Bearer ${process.env.BACKEND_JWT}`,
},