Created the stats page where a user can select another user to view their stats;

Improved the whole stats and the home page
This commit is contained in:
Tiago Ribeiro
2023-04-20 22:43:30 +01:00
parent e60130069d
commit 02d76e4c3c
13 changed files with 361 additions and 124 deletions

View File

@@ -16,6 +16,7 @@ import {withIronSessionSsr} from "iron-session/next";
import {sessionOptions} from "@/lib/session";
import {Stat, User} from "@/interfaces/user";
import Speaking from "@/exams/Speaking";
import {v4 as uuidv4} from "uuid";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
@@ -42,9 +43,12 @@ export default function Page({user}: {user: User}) {
const [hasBeenUploaded, setHasBeenUploaded] = useState(false);
const [showSolutions, setShowSolutions] = useState(false);
const [moduleIndex, setModuleIndex] = useState(0);
const [sessionId, setSessionId] = useState("");
const [exam, setExam] = useState<Exam>();
const [timer, setTimer] = useState(-1);
useEffect(() => setSessionId(uuidv4()), []);
useEffect(() => {
(async () => {
if (selectedModules.length > 0 && moduleIndex < selectedModules.length) {
@@ -60,6 +64,7 @@ export default function Page({user}: {user: User}) {
if (selectedModules.length > 0 && moduleIndex >= selectedModules.length && !hasBeenUploaded) {
const stats: Stat[] = userSolutions.map((solution) => ({
...solution,
session: sessionId,
exam: solution.exam!,
module: solution.module!,
user: user.id,