Updated the writing evaluation to use the different endpoints
This commit is contained in:
@@ -286,10 +286,10 @@ export default function ExamPage({page}: Props) {
|
|||||||
|
|
||||||
const responses: UserSolution[] = (
|
const responses: UserSolution[] = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
exam.exercises.map(async (exercise) => {
|
exam.exercises.map(async (exercise, index) => {
|
||||||
const evaluationID = uuidv4();
|
const evaluationID = uuidv4();
|
||||||
if (exercise.type === "writing")
|
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")
|
if (exercise.type === "interactiveSpeaking" || exercise.type === "speaking")
|
||||||
return await evaluateSpeakingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!, evaluationID);
|
return await evaluateSpeakingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!, evaluationID);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {writingReverseMarking} from "@/utils/score";
|
|||||||
interface Body {
|
interface Body {
|
||||||
question: string;
|
question: string;
|
||||||
answer: string;
|
answer: string;
|
||||||
|
task: 1 | 2;
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ async function getCorrespondingStat(id: string, index: number): Promise<Stat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function evaluate(body: Body): Promise<AxiosResponse> {
|
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: {
|
headers: {
|
||||||
Authorization: `Bearer ${process.env.BACKEND_JWT}`,
|
Authorization: `Bearer ${process.env.BACKEND_JWT}`,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,10 +11,16 @@ import {
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {speakingReverseMarking, writingReverseMarking} from "./score";
|
import {speakingReverseMarking, writingReverseMarking} from "./score";
|
||||||
|
|
||||||
export const evaluateWritingAnswer = async (exercise: WritingExercise, solution: UserSolution, id: string): Promise<UserSolution | undefined> => {
|
export const evaluateWritingAnswer = async (
|
||||||
|
exercise: WritingExercise,
|
||||||
|
task: number,
|
||||||
|
solution: UserSolution,
|
||||||
|
id: string,
|
||||||
|
): Promise<UserSolution | undefined> => {
|
||||||
const response = await axios.post<Evaluation>("/api/evaluate/writing", {
|
const response = await axios.post<Evaluation>("/api/evaluate/writing", {
|
||||||
question: `${exercise.prompt} ${exercise.attachment ? exercise.attachment.description : ""}`.replaceAll("\n", ""),
|
question: `${exercise.prompt} ${exercise.attachment ? exercise.attachment.description : ""}`.replaceAll("\n", ""),
|
||||||
answer: solution.solutions[0].solution.trim().replaceAll("\n", " "),
|
answer: solution.solutions[0].solution.trim().replaceAll("\n", " "),
|
||||||
|
task,
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user