Solved a bug where the speaking and interactive speaking were not being correctly evaluated
This commit is contained in:
@@ -81,7 +81,7 @@ export default function Speaking({id, title, text, video_url, type, prompts, use
|
|||||||
onNext({
|
onNext({
|
||||||
exercise: id,
|
exercise: id,
|
||||||
solutions: storagePath ? [{id, solution: storagePath}] : [],
|
solutions: storagePath ? [{id, solution: storagePath}] : [],
|
||||||
score: {correct: 100, total: 100, missing: 0},
|
score: {correct: 0, total: 100, missing: 0},
|
||||||
type,
|
type,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -94,7 +94,7 @@ export default function Speaking({id, title, text, video_url, type, prompts, use
|
|||||||
onBack({
|
onBack({
|
||||||
exercise: id,
|
exercise: id,
|
||||||
solutions: storagePath ? [{id, solution: storagePath}] : [],
|
solutions: storagePath ? [{id, solution: storagePath}] : [],
|
||||||
score: {correct: 100, total: 100, missing: 0},
|
score: {correct: 0, total: 100, missing: 0},
|
||||||
type,
|
type,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export interface UserSolution {
|
|||||||
missing: number;
|
missing: number;
|
||||||
};
|
};
|
||||||
exercise: string;
|
exercise: string;
|
||||||
|
isDisabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WritingExam {
|
export interface WritingExam {
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ export interface Stat {
|
|||||||
total: number;
|
total: number;
|
||||||
missing: number;
|
missing: number;
|
||||||
};
|
};
|
||||||
|
isDisabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Group {
|
export interface Group {
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ export default function ExamPage({page}: Props) {
|
|||||||
module: exam!.module,
|
module: exam!.module,
|
||||||
user: user?.id || "",
|
user: user?.id || "",
|
||||||
date: new Date().getTime(),
|
date: new Date().getTime(),
|
||||||
|
isDisabled: solution.isDisabled,
|
||||||
...(assignment ? {assignment: assignment.id} : {}),
|
...(assignment ? {assignment: assignment.id} : {}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
missing: 0,
|
missing: 0,
|
||||||
total: 100,
|
total: 100,
|
||||||
},
|
},
|
||||||
|
isDisabled: false,
|
||||||
},
|
},
|
||||||
{merge: true},
|
{merge: true},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -38,11 +38,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
console.log("🌱 - Process complete");
|
console.log("🌱 - Process complete");
|
||||||
|
|
||||||
const correspondingStat = (await getDoc(doc(db, "stats", fields.id))).data() as Stat;
|
const correspondingStat = (await getDoc(doc(db, "stats", fields.id))).data() as Stat;
|
||||||
|
|
||||||
const solutions = correspondingStat.solutions.map((x) => ({
|
const solutions = correspondingStat.solutions.map((x) => ({
|
||||||
...x,
|
...x,
|
||||||
evaluation: backendRequest.data,
|
evaluation: backendRequest.data,
|
||||||
solution: snapshot.metadata.fullPath,
|
solution: snapshot.metadata.fullPath,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await setDoc(
|
await setDoc(
|
||||||
doc(db, "stats", fields.id),
|
doc(db, "stats", fields.id),
|
||||||
{
|
{
|
||||||
@@ -52,6 +54,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
total: 100,
|
total: 100,
|
||||||
missing: 0,
|
missing: 0,
|
||||||
},
|
},
|
||||||
|
isDisabled: false,
|
||||||
},
|
},
|
||||||
{merge: true},
|
{merge: true},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
total: 100,
|
total: 100,
|
||||||
missing: 0,
|
missing: 0,
|
||||||
},
|
},
|
||||||
|
isDisabled: false,
|
||||||
},
|
},
|
||||||
{merge: true},
|
{merge: true},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
|||||||
redirect: {
|
redirect: {
|
||||||
destination: "/login",
|
destination: "/login",
|
||||||
permanent: false,
|
permanent: false,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
|||||||
redirect: {
|
redirect: {
|
||||||
destination: "/",
|
destination: "/",
|
||||||
permanent: false,
|
permanent: false,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +165,7 @@ export default function History({user}: {user: User}) {
|
|||||||
const aggregatedScores = aggregateScoresByModule(dateStats).filter((x) => x.total > 0);
|
const aggregatedScores = aggregateScoresByModule(dateStats).filter((x) => x.total > 0);
|
||||||
const assignmentID = dateStats.reduce((_, current) => current.assignment as any, "");
|
const assignmentID = dateStats.reduce((_, current) => current.assignment as any, "");
|
||||||
const assignment = assignments.find((a) => a.id === assignmentID);
|
const assignment = assignments.find((a) => a.id === assignmentID);
|
||||||
|
const isDisabled = dateStats.some((x) => x.isDisabled);
|
||||||
|
|
||||||
const aggregatedLevels = aggregatedScores.map((x) => ({
|
const aggregatedLevels = aggregatedScores.map((x) => ({
|
||||||
module: x.module,
|
module: x.module,
|
||||||
@@ -260,11 +261,13 @@ export default function History({user}: {user: User}) {
|
|||||||
key={uuidv4()}
|
key={uuidv4()}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"flex flex-col gap-4 border border-mti-gray-platinum p-4 cursor-pointer rounded-xl transition ease-in-out duration-300 -md:hidden",
|
"flex flex-col gap-4 border border-mti-gray-platinum p-4 cursor-pointer rounded-xl transition ease-in-out duration-300 -md:hidden",
|
||||||
|
isDisabled && "grayscale tooltip",
|
||||||
correct / total >= 0.7 && "hover:border-mti-purple",
|
correct / total >= 0.7 && "hover:border-mti-purple",
|
||||||
correct / total >= 0.3 && correct / total < 0.7 && "hover:border-mti-red",
|
correct / total >= 0.3 && correct / total < 0.7 && "hover:border-mti-red",
|
||||||
correct / total < 0.3 && "hover:border-mti-rose",
|
correct / total < 0.3 && "hover:border-mti-rose",
|
||||||
)}
|
)}
|
||||||
onClick={selectExam}
|
onClick={isDisabled ? () => null : selectExam}
|
||||||
|
data-tip="This exam is still being evaluated..."
|
||||||
role="button">
|
role="button">
|
||||||
{content}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export const evaluateWritingAnswer = async (exercise: WritingExercise, solution:
|
|||||||
total: 100,
|
total: 100,
|
||||||
},
|
},
|
||||||
solutions: [{id: exercise.id, solution: solution.solutions[0].solution, evaluation: response.data}],
|
solutions: [{id: exercise.id, solution: solution.solutions[0].solution, evaluation: response.data}],
|
||||||
|
isDisabled: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,12 +78,14 @@ const evaluateSpeakingExercise = async (exercise: SpeakingExercise, exerciseId:
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
return {
|
return {
|
||||||
...solution,
|
...solution,
|
||||||
|
id,
|
||||||
score: {
|
score: {
|
||||||
correct: response.data ? speakingReverseMarking[response.data.overall] : 0,
|
correct: 0,
|
||||||
missing: 0,
|
missing: 0,
|
||||||
total: 100,
|
total: 100,
|
||||||
},
|
},
|
||||||
solutions: [{id: exerciseId, solution: response.data ? response.data.fullPath : null, evaluation: response.data}],
|
solutions: [{id: exerciseId, solution: response.data ? response.data.fullPath : null, evaluation: response.data}],
|
||||||
|
isDisabled: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,18 +122,19 @@ const evaluateInteractiveSpeakingExercise = async (exerciseId: string, solution:
|
|||||||
};
|
};
|
||||||
|
|
||||||
const response = await axios.post("/api/evaluate/interactiveSpeaking", formData, config);
|
const response = await axios.post("/api/evaluate/interactiveSpeaking", formData, config);
|
||||||
console.log({data: response.data, status: response.status});
|
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
return {
|
return {
|
||||||
...solution,
|
...solution,
|
||||||
|
id,
|
||||||
score: {
|
score: {
|
||||||
correct: response.data ? speakingReverseMarking[response.data.overall] : 0,
|
correct: 0,
|
||||||
missing: 0,
|
missing: 0,
|
||||||
total: 100,
|
total: 100,
|
||||||
},
|
},
|
||||||
module: "speaking",
|
module: "speaking",
|
||||||
solutions: [{id: exerciseId, solution: response.data ? response.data.answer : null, evaluation: response.data}],
|
solutions: [{id: exerciseId, solution: response.data ? response.data.answer : null, evaluation: response.data}],
|
||||||
|
isDisabled: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user