- Implemented an image attachment to the Writing exercise;
- Made it so the exams are now sorted when going through the history; - Corrected some little mistakes;
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type {NextApiRequest, NextApiResponse} from "next";
|
||||
import {app} from "@/firebase";
|
||||
import {getFirestore, collection, getDocs} from "firebase/firestore";
|
||||
import {getFirestore, collection, getDocs, query, where} from "firebase/firestore";
|
||||
import {withIronSessionApiRoute} from "iron-session/next";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
|
||||
@@ -16,8 +16,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
}
|
||||
|
||||
const {module} = req.query as {module: string};
|
||||
const moduleRef = collection(db, module);
|
||||
const q = query(moduleRef, where("isDiagnostic", "==", false));
|
||||
|
||||
const snapshot = await getDocs(collection(db, module));
|
||||
const snapshot = await getDocs(q);
|
||||
|
||||
res.status(200).json(
|
||||
snapshot.docs.map((doc) => ({
|
||||
|
||||
@@ -41,7 +41,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
|
||||
export default function Page() {
|
||||
const [hasBeenUploaded, setHasBeenUploaded] = useState(false);
|
||||
const [moduleIndex, setModuleIndex] = useState(1);
|
||||
const [moduleIndex, setModuleIndex] = useState(0);
|
||||
const [sessionId, setSessionId] = useState("");
|
||||
const [exam, setExam] = useState<Exam>();
|
||||
const [timer, setTimer] = useState(-1);
|
||||
|
||||
@@ -26,6 +26,7 @@ import Icon from "@mdi/react";
|
||||
import {mdiArrowRight, mdiChevronRight} from "@mdi/js";
|
||||
import {uniqBy} from "lodash";
|
||||
import {getExamById} from "@/utils/exams";
|
||||
import {sortByModule} from "@/utils/moduleUtils";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
const user = req.session.user;
|
||||
@@ -87,8 +88,13 @@ export default function History({user}: {user: User}) {
|
||||
if (exams.every((x) => !!x)) {
|
||||
setUserSolutions(convertToUserSolutions(dateStats));
|
||||
setShowSolutions(true);
|
||||
setExams(exams.map((x) => x!));
|
||||
setSelectedModules(exams.map((x) => x!.module));
|
||||
setExams(exams.map((x) => x!).sort(sortByModule));
|
||||
setSelectedModules(
|
||||
exams
|
||||
.map((x) => x!)
|
||||
.sort(sortByModule)
|
||||
.map((x) => x!.module),
|
||||
);
|
||||
router.push("/exam");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user