diff --git a/app/results/[id]/page.tsx b/app/results/[id]/page.tsx
index 1534287..021e298 100644
--- a/app/results/[id]/page.tsx
+++ b/app/results/[id]/page.tsx
@@ -10,12 +10,14 @@ interface data {
}
export default async function Page({ params }: { params: { id: string } }) {
- const grades = await Prisma.grade.findMany({ where: { testId: parseInt(params.id) } });
+ const teacherGrade = await Prisma.grade.findFirst({ where: { testId: parseInt(params.id), user: { isTeacher: true } } });
+
+ const grades = await Prisma.grade.findMany({where: {testId: parseInt(params.id), user: {isTeacher: false}}});
+
const allGrades = ['1', '1.5', '2', '2.5', '3', '3.5', '4', '4.5', '5', '5.5', '6'];
let gradeOccurences = new Array(allGrades.length).fill(0);
const gradeList = grades.map((grade) => grade.grade);
- const teacherGrade = await Prisma.grade.findFirst({ where: { testId: parseInt(params.id), user: { isTeacher: true } } });
for (let i = 0; i < gradeList.length; i++) {
gradeOccurences[allGrades.indexOf(gradeList[i].toString())]++;
@@ -31,13 +33,13 @@ export default async function Page({ params }: { params: { id: string } }) {
return (
+
{teacherGrade && (
Mme Tixhon :
{teacherGrade.grade}
)}
-
);
diff --git a/assets/end.mp3 b/assets/end.mp3
new file mode 100644
index 0000000..f66643c
Binary files /dev/null and b/assets/end.mp3 differ
diff --git a/components/custom/countdown.tsx b/components/custom/countdown.tsx
new file mode 100644
index 0000000..a60571f
--- /dev/null
+++ b/components/custom/countdown.tsx
@@ -0,0 +1,43 @@
+"use client";
+
+import React from 'react';
+import { useTimer } from 'react-timer-hook';
+
+import { Button } from "@components/ui/button";
+import { PauseIcon, Play} from "lucide-react";
+
+interface MyTimerProps {
+ expiryTimestamp: Date;
+ onEnd?: () => void;
+}
+
+export default function MyTimer({ expiryTimestamp, onEnd } : MyTimerProps) {
+ const {
+ seconds,
+ minutes,
+ isRunning,
+ pause,
+ resume,
+ } = useTimer({
+ expiryTimestamp,
+ onExpire: () => onEnd && onEnd()
+ })
+
+ return (
+
+
+ {String(minutes).padStart(2, "0")}:
+ {String(seconds).padStart(2, "0")}
+
+
{isRunning ? 'Running' : 'Not running'}
+
+
+ );
+}
diff --git a/package-lock.json b/package-lock.json
index 3f0538a..f976ea6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -23,6 +23,7 @@
"react": "^18",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18",
+ "react-timer-hook": "^3.0.7",
"socket.io": "^4.7.2",
"socket.io-client": "^4.7.2",
"swr": "^2.2.4",
@@ -4435,6 +4436,14 @@
}
}
},
+ "node_modules/react-timer-hook": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/react-timer-hook/-/react-timer-hook-3.0.7.tgz",
+ "integrity": "sha512-ATpNcU+PQRxxfNBPVqce2+REtjGAlwmfoNQfcEBMZFxPj0r3GYdKhyPHdStvqrejejEi0QvqaJZjy2lBlFvAsA==",
+ "peerDependencies": {
+ "react": ">=16.8.0"
+ }
+ },
"node_modules/read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
diff --git a/package.json b/package.json
index 84282f2..826bdc1 100644
--- a/package.json
+++ b/package.json
@@ -24,6 +24,7 @@
"react": "^18",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18",
+ "react-timer-hook": "^3.0.7",
"socket.io": "^4.7.2",
"socket.io-client": "^4.7.2",
"swr": "^2.2.4",
diff --git a/tsconfig.json b/tsconfig.json
index 709a6e8..66d7499 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -25,8 +25,9 @@
"@styles/*": ["/styles/*"],
"@santa/*": ["./images/santa/*"],
"@images/*": ["./images/*"],
+ "@assets/*": ["./assets/*"],
}
},
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "**/*.d.ts"],
"exclude": ["node_modules"]
}
diff --git a/types/sounds.d.ts b/types/sounds.d.ts
new file mode 100644
index 0000000..3f6ebdd
--- /dev/null
+++ b/types/sounds.d.ts
@@ -0,0 +1,4 @@
+declare module '*.mp3' {
+ const content: string;
+ export default content;
+}