diff --git a/src/components/Exercises/Speaking.tsx b/src/components/Exercises/Speaking.tsx index 2adea802..c53f88cb 100644 --- a/src/components/Exercises/Speaking.tsx +++ b/src/components/Exercises/Speaking.tsx @@ -81,7 +81,7 @@ export default function Speaking({id, title, text, video_url, type, prompts, use onNext({ exercise: id, solutions: storagePath ? [{id, solution: storagePath}] : [], - score: {correct: 100, total: 100, missing: 0}, + score: {correct: 0, total: 100, missing: 0}, type, }); }; @@ -94,7 +94,7 @@ export default function Speaking({id, title, text, video_url, type, prompts, use onBack({ exercise: id, solutions: storagePath ? [{id, solution: storagePath}] : [], - score: {correct: 100, total: 100, missing: 0}, + score: {correct: 0, total: 100, missing: 0}, type, }); }; diff --git a/src/interfaces/exam.ts b/src/interfaces/exam.ts index 775655d1..b42675ca 100644 --- a/src/interfaces/exam.ts +++ b/src/interfaces/exam.ts @@ -64,6 +64,7 @@ export interface UserSolution { missing: number; }; exercise: string; + isDisabled?: boolean; } export interface WritingExam { diff --git a/src/interfaces/user.ts b/src/interfaces/user.ts index f74b42fc..e3a54a3e 100644 --- a/src/interfaces/user.ts +++ b/src/interfaces/user.ts @@ -123,6 +123,7 @@ export interface Stat { total: number; missing: number; }; + isDisabled?: boolean; } export interface Group { diff --git a/src/pages/(exam)/ExamPage.tsx b/src/pages/(exam)/ExamPage.tsx index fa5505dd..ed6253f5 100644 --- a/src/pages/(exam)/ExamPage.tsx +++ b/src/pages/(exam)/ExamPage.tsx @@ -193,6 +193,7 @@ export default function ExamPage({page}: Props) { module: exam!.module, user: user?.id || "", date: new Date().getTime(), + isDisabled: solution.isDisabled, ...(assignment ? {assignment: assignment.id} : {}), })); diff --git a/src/pages/api/evaluate/interactiveSpeaking.ts b/src/pages/api/evaluate/interactiveSpeaking.ts index bc97a885..2ee90fdd 100644 --- a/src/pages/api/evaluate/interactiveSpeaking.ts +++ b/src/pages/api/evaluate/interactiveSpeaking.ts @@ -57,6 +57,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { missing: 0, total: 100, }, + isDisabled: false, }, {merge: true}, ); diff --git a/src/pages/api/evaluate/speaking.ts b/src/pages/api/evaluate/speaking.ts index 08a7d4f9..81842e45 100644 --- a/src/pages/api/evaluate/speaking.ts +++ b/src/pages/api/evaluate/speaking.ts @@ -38,11 +38,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { console.log("🌱 - Process complete"); const correspondingStat = (await getDoc(doc(db, "stats", fields.id))).data() as Stat; + const solutions = correspondingStat.solutions.map((x) => ({ ...x, evaluation: backendRequest.data, solution: snapshot.metadata.fullPath, })); + await setDoc( doc(db, "stats", fields.id), { @@ -52,6 +54,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { total: 100, missing: 0, }, + isDisabled: false, }, {merge: true}, ); diff --git a/src/pages/api/evaluate/writing.ts b/src/pages/api/evaluate/writing.ts index 841b4c92..787ba404 100644 --- a/src/pages/api/evaluate/writing.ts +++ b/src/pages/api/evaluate/writing.ts @@ -40,6 +40,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { total: 100, missing: 0, }, + isDisabled: false, }, {merge: true}, ); diff --git a/src/pages/record.tsx b/src/pages/record.tsx index c12888c6..80eba79f 100644 --- a/src/pages/record.tsx +++ b/src/pages/record.tsx @@ -34,7 +34,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => { redirect: { destination: "/login", permanent: false, - } + }, }; } @@ -43,7 +43,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => { redirect: { destination: "/", permanent: false, - } + }, }; } @@ -165,6 +165,7 @@ export default function History({user}: {user: User}) { const aggregatedScores = aggregateScoresByModule(dateStats).filter((x) => x.total > 0); const assignmentID = dateStats.reduce((_, current) => current.assignment as any, ""); const assignment = assignments.find((a) => a.id === assignmentID); + const isDisabled = dateStats.some((x) => x.isDisabled); const aggregatedLevels = aggregatedScores.map((x) => ({ module: x.module, @@ -260,11 +261,13 @@ export default function History({user}: {user: User}) { key={uuidv4()} 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", + isDisabled && "grayscale tooltip", correct / total >= 0.7 && "hover:border-mti-purple", correct / total >= 0.3 && correct / total < 0.7 && "hover:border-mti-red", correct / total < 0.3 && "hover:border-mti-rose", )} - onClick={selectExam} + onClick={isDisabled ? () => null : selectExam} + data-tip="This exam is still being evaluated..." role="button"> {content} diff --git a/src/utils/evaluation.ts b/src/utils/evaluation.ts index 453236c6..e92bf0d3 100644 --- a/src/utils/evaluation.ts +++ b/src/utils/evaluation.ts @@ -28,6 +28,7 @@ export const evaluateWritingAnswer = async (exercise: WritingExercise, solution: total: 100, }, 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) { return { ...solution, + id, score: { - correct: response.data ? speakingReverseMarking[response.data.overall] : 0, + correct: 0, missing: 0, total: 100, }, 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); - console.log({data: response.data, status: response.status}); if (response.status === 200) { return { ...solution, + id, score: { - correct: response.data ? speakingReverseMarking[response.data.overall] : 0, + correct: 0, missing: 0, total: 100, }, module: "speaking", solutions: [{id: exerciseId, solution: response.data ? response.data.answer : null, evaluation: response.data}], + isDisabled: true, }; }