Added the ability to choose between partial and full exams
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import {Exam, ReadingExam, ListeningExam, WritingExam, SpeakingExam, Exercise, UserSolution, LevelExam} from "@/interfaces/exam";
|
||||
import {Exam, ReadingExam, ListeningExam, WritingExam, SpeakingExam, Exercise, UserSolution, LevelExam, Variant} from "@/interfaces/exam";
|
||||
import axios from "axios";
|
||||
|
||||
export const getExam = async (module: Module, avoidRepeated: boolean): Promise<Exam | undefined> => {
|
||||
const examRequest = await axios<Exam[]>(`/api/exam/${module}?avoidRepeated=${avoidRepeated}`);
|
||||
export const getExam = async (module: Module, avoidRepeated: boolean, variant?: Variant): Promise<Exam | undefined> => {
|
||||
const url = new URLSearchParams();
|
||||
url.append("avoidRepeated", avoidRepeated.toString());
|
||||
if (variant) url.append("variant", variant);
|
||||
|
||||
const examRequest = await axios<Exam[]>(`/api/exam/${module}?${url.toString()}`);
|
||||
if (examRequest.status !== 200) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user