diff --git a/src/components/Low/Checkbox.tsx b/src/components/Low/Checkbox.tsx index d5a7298d..fa90951f 100644 --- a/src/components/Low/Checkbox.tsx +++ b/src/components/Low/Checkbox.tsx @@ -11,14 +11,16 @@ interface Props { export default function Checkbox({isChecked, onChange, children, disabled}: Props) { return ( -
{ - if(disabled) return; - onChange(!isChecked); - }}> +
{ + if (disabled) return; + onChange(!isChecked); + }}>
diff --git a/src/pages/(generation)/LevelGeneration.tsx b/src/pages/(generation)/LevelGeneration.tsx index 09b1615a..480ca61a 100644 --- a/src/pages/(generation)/LevelGeneration.tsx +++ b/src/pages/(generation)/LevelGeneration.tsx @@ -1,6 +1,7 @@ import FillBlanksEdit from "@/components/Generation/fill.blanks.edit"; import MultipleChoiceEdit from "@/components/Generation/multiple.choice.edit"; import WriteBlankEdits from "@/components/Generation/write.blanks.edit"; +import Checkbox from "@/components/Low/Checkbox"; import Input from "@/components/Low/Input"; import Select from "@/components/Low/Select"; import { @@ -234,7 +235,7 @@ interface Props { id: string; } -const LevelGeneration = ({ id } : Props) => { +const LevelGeneration = ({id}: Props) => { const [generatedExam, setGeneratedExam] = useState(); const [isLoading, setIsLoading] = useState(false); const [resultingExam, setResultingExam] = useState(); @@ -242,6 +243,7 @@ const LevelGeneration = ({ id } : Props) => { const [difficulty, setDifficulty] = useState(sample(DIFFICULTIES)!); const [numberOfParts, setNumberOfParts] = useState(1); const [parts, setParts] = useState([{quantity: 10, type: "multiple_choice_4"}]); + const [isPrivate, setPrivate] = useState(false); useEffect(() => { setParts((prev) => Array.from(Array(numberOfParts)).map((_, i) => (!!prev.at(i) ? prev.at(i)! : {quantity: 10, type: "multiple_choice_4"}))); @@ -301,6 +303,7 @@ const LevelGeneration = ({ id } : Props) => { difficulty, variant: "full", isDiagnostic: false, + private: isPrivate, parts: parts .map((part, index) => { const currentExercise = result.data.exercises[`exercise_${index + 1}`] as any; @@ -424,7 +427,7 @@ const LevelGeneration = ({ id } : Props) => { return; } - if(!id) { + if (!id) { toast.error("Please insert a title before submitting"); return; } @@ -456,8 +459,8 @@ const LevelGeneration = ({ id } : Props) => { return ( <> -
-
+
+
setNumberOfParts(parseInt(v))} value={numberOfParts} />
-
+
setTimer(parseInt(v))} value={timer} />
+
+
+ + Privacy (Only available for Assignments) + +
diff --git a/src/pages/(generation)/ListeningGeneration.tsx b/src/pages/(generation)/ListeningGeneration.tsx index 5388b183..ef17c4ca 100644 --- a/src/pages/(generation)/ListeningGeneration.tsx +++ b/src/pages/(generation)/ListeningGeneration.tsx @@ -16,6 +16,7 @@ import {BsArrowRepeat, BsCheck} from "react-icons/bs"; import {toast} from "react-toastify"; import WriteBlanksEdit from "@/components/Generation/write.blanks.edit"; import {generate} from "random-words"; +import Checkbox from "@/components/Low/Checkbox"; const DIFFICULTIES: Difficulty[] = ["easy", "medium", "hard"]; @@ -232,7 +233,7 @@ interface Props { id: string; } -const ListeningGeneration = ({ id } : Props) => { +const ListeningGeneration = ({id}: Props) => { const [part1, setPart1] = useState(); const [part2, setPart2] = useState(); const [part3, setPart3] = useState(); @@ -241,6 +242,7 @@ const ListeningGeneration = ({ id } : Props) => { const [isLoading, setIsLoading] = useState(false); const [resultingExam, setResultingExam] = useState(); const [difficulty, setDifficulty] = useState(sample(DIFFICULTIES)!); + const [isPrivate, setPrivate] = useState(false); useEffect(() => { const part1Timer = part1 ? 5 : 0; @@ -262,11 +264,11 @@ const ListeningGeneration = ({ id } : Props) => { console.log({parts}); if (parts.length === 0) return toast.error("Please generate at least one section!"); - if(!id) { + if (!id) { toast.error("Please insert a title before submitting"); return; } - + setIsLoading(true); axios @@ -275,6 +277,7 @@ const ListeningGeneration = ({ id } : Props) => { parts, minTimer, difficulty, + private: isPrivate, }) .then((result) => { playSound("sent"); @@ -313,7 +316,7 @@ const ListeningGeneration = ({ id } : Props) => { return ( <> -
+
{ className="max-w-[300px]" />
-
+
{ className="max-w-[300px]" />
-
+
{ className="max-w-[300px]" />
-
+
{ className="max-w-[300px]" />
-
+