Updated the InteractiveSpeaking to also work with the session persistence

This commit is contained in:
Tiago Ribeiro
2024-02-08 11:43:01 +00:00
parent 2a9e204041
commit b09fe79cb7
12 changed files with 166 additions and 68 deletions

View File

@@ -181,8 +181,8 @@ export default function ExamPage({page}: Props) {
id: solution.id || uuidv4(),
timeSpent,
session: sessionId,
exam: solution.exam!,
module: solution.module!,
exam: exam!.id,
module: exam!.module,
user: user?.id || "",
date: new Date().getTime(),
...(assignment ? {assignment: assignment.id} : {}),
@@ -328,6 +328,8 @@ export default function ExamPage({page}: Props) {
};
answers.forEach((x) => {
console.log({x});
scores[x.module!] = {
total: scores[x.module!].total + x.score.total,
correct: scores[x.module!].correct + x.score.correct,
@@ -366,6 +368,8 @@ export default function ExamPage({page}: Props) {
onViewResults={() => {
setShowSolutions(true);
setModuleIndex(0);
setExerciseIndex(["reading", "listening"].includes(exams[0].module) ? -1 : 0);
setPartIndex(exams[0].module === "listening" ? -1 : 0);
setExam(exams[0]);
}}
scores={aggregateScoresByModule(userSolutions)}

View File

@@ -28,7 +28,6 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
}
const audioFile = files.audio;
console.log({fields}, (audioFile as any).path);
const audioFileRef = ref(storage, `${fields.root}/${(audioFile as any).path.split("/").pop()!.replace("upload_", "")}`);
const binary = fs.readFileSync((audioFile as any).path).buffer;

View File

@@ -178,7 +178,10 @@ export default function History({user}: {user: User}) {
const {timeSpent, session} = dateStats[0];
const selectExam = () => {
const examPromises = uniqBy(dateStats, "exam").map((stat) => getExamById(stat.module, stat.exam));
const examPromises = uniqBy(dateStats, "exam").map((stat) => {
console.log({stat});
return getExamById(stat.module, stat.exam);
});
Promise.all(examPromises).then((exams) => {
if (exams.every((x) => !!x)) {