Updated and fixed part of the partial test generation
This commit is contained in:
BIN
public/audio/error.mp3
Normal file
BIN
public/audio/error.mp3
Normal file
Binary file not shown.
@@ -19,8 +19,8 @@ const TaskTab = ({exam, setExam}: {exam?: LevelExam; setExam: (exam: LevelExam)
|
|||||||
axios
|
axios
|
||||||
.get(`/api/exam/level/generate/level`)
|
.get(`/api/exam/level/generate/level`)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
playSound("check");
|
playSound(typeof result.data === "string" ? "error" : "check");
|
||||||
console.log(result.data);
|
if (typeof result.data === "string") return toast.error("Something went wrong, please try to generate again.");
|
||||||
setExam(result.data);
|
setExam(result.data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ const PartTab = ({part, types, index, setPart}: {part?: ListeningPart; types: st
|
|||||||
axios
|
axios
|
||||||
.get(`/api/exam/listening/generate/listening_section_${index}${topic || types ? `?${url.toString()}` : ""}`)
|
.get(`/api/exam/listening/generate/listening_section_${index}${topic || types ? `?${url.toString()}` : ""}`)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
playSound("check");
|
playSound(typeof result.data === "string" ? "error" : "check");
|
||||||
|
if (typeof result.data === "string") return toast.error("Something went wrong, please try to generate again.");
|
||||||
setPart(result.data);
|
setPart(result.data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@@ -110,14 +111,19 @@ const ListeningGeneration = () => {
|
|||||||
const [part2, setPart2] = useState<ListeningPart>();
|
const [part2, setPart2] = useState<ListeningPart>();
|
||||||
const [part3, setPart3] = useState<ListeningPart>();
|
const [part3, setPart3] = useState<ListeningPart>();
|
||||||
const [part4, setPart4] = useState<ListeningPart>();
|
const [part4, setPart4] = useState<ListeningPart>();
|
||||||
const [minTimer, setMinTimer] = useState(60);
|
const [minTimer, setMinTimer] = useState(30);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [resultingExam, setResultingExam] = useState<ListeningExam>();
|
const [resultingExam, setResultingExam] = useState<ListeningExam>();
|
||||||
const [types, setTypes] = useState<string[]>([]);
|
const [types, setTypes] = useState<string[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const parts = [part1, part2, part3, part4].filter((x) => !!x);
|
const part1Timer = part1 ? 5 : 0;
|
||||||
setMinTimer(parts.length === 0 ? 60 : parts.length * 15);
|
const part2Timer = part2 ? 8 : 0;
|
||||||
|
const part3Timer = part3 ? 8 : 0;
|
||||||
|
const part4Timer = part4 ? 9 : 0;
|
||||||
|
|
||||||
|
const sum = part1Timer + part2Timer + part3Timer + part4Timer;
|
||||||
|
setMinTimer(sum > 0 ? sum : 5);
|
||||||
}, [part1, part2, part3, part4]);
|
}, [part1, part2, part3, part4]);
|
||||||
|
|
||||||
const availableTypes = [
|
const availableTypes = [
|
||||||
@@ -136,6 +142,7 @@ const ListeningGeneration = () => {
|
|||||||
|
|
||||||
const submitExam = () => {
|
const submitExam = () => {
|
||||||
const parts = [part1, part2, part3, part4].filter((x) => !!x);
|
const parts = [part1, part2, part3, part4].filter((x) => !!x);
|
||||||
|
console.log({parts});
|
||||||
if (parts.length === 0) return toast.error("Please generate at least one section!");
|
if (parts.length === 0) return toast.error("Please generate at least one section!");
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ const PartTab = ({part, types, index, setPart}: {part?: ReadingPart; types: stri
|
|||||||
axios
|
axios
|
||||||
.get(`/api/exam/reading/generate/reading_passage_${index}${topic || types ? `?${url.toString()}` : ""}`)
|
.get(`/api/exam/reading/generate/reading_passage_${index}${topic || types ? `?${url.toString()}` : ""}`)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
playSound("check");
|
playSound(typeof result.data === "string" ? "error" : "check");
|
||||||
|
if (typeof result.data === "string") return toast.error("Something went wrong, please try to generate again.");
|
||||||
setPart(result.data);
|
setPart(result.data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ const PartTab = ({part, index, setPart}: {part?: SpeakingPart; index: number; se
|
|||||||
axios
|
axios
|
||||||
.get(`/api/exam/speaking/generate/speaking_task_${index}`)
|
.get(`/api/exam/speaking/generate/speaking_task_${index}`)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
playSound("check");
|
playSound(typeof result.data === "string" ? "error" : "check");
|
||||||
|
if (typeof result.data === "string") return toast.error("Something went wrong, please try to generate again.");
|
||||||
setPart(result.data);
|
setPart(result.data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ const TaskTab = ({task, index, setTask}: {task?: string; index: number; setTask:
|
|||||||
axios
|
axios
|
||||||
.get(`/api/exam/writing/generate/writing_task${index}_general`)
|
.get(`/api/exam/writing/generate/writing_task${index}_general`)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
playSound("check");
|
playSound(typeof result.data === "string" ? "error" : "check");
|
||||||
|
if (typeof result.data === "string") return toast.error("Something went wrong, please try to generate again.");
|
||||||
setTask(result.data.question);
|
setTask(result.data.question);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -46,6 +46,6 @@ export const getExams = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const filterByVariant = (exams: Exam[], variant?: Variant) => {
|
const filterByVariant = (exams: Exam[], variant?: Variant) => {
|
||||||
const filtered = variant && variant === "partial" ? exams.filter((x) => x.variant === "partial") : exams;
|
const filtered = variant && variant === "partial" ? exams.filter((x) => x.variant === "partial") : exams.filter((x) => x.variant !== "partial");
|
||||||
return filtered.length > 0 ? filtered : exams;
|
return filtered.length > 0 ? filtered : exams;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {Howl, Howler} from "howler";
|
import {Howl, Howler} from "howler";
|
||||||
|
|
||||||
export type Sound = "check" | "sent";
|
export type Sound = "check" | "sent" | "error";
|
||||||
export const playSound = (path: Sound) => {
|
export const playSound = (path: Sound) => {
|
||||||
const sound = new Howl({
|
const sound = new Howl({
|
||||||
src: [`audio/${path}.mp3`],
|
src: [`audio/${path}.mp3`],
|
||||||
|
|||||||
Reference in New Issue
Block a user