Updated the generation to allow for private exams

This commit is contained in:
Tiago Ribeiro
2024-08-28 10:46:02 +01:00
parent dbf262598f
commit e518323d99
6 changed files with 78 additions and 29 deletions

View File

@@ -20,6 +20,7 @@ import TrueFalseEdit from "@/components/Generation/true.false.edit";
import WriteBlanksEdit from "@/components/Generation/write.blanks.edit";
import MatchSentencesEdit from "@/components/Generation/match.sentences.edit";
import MultipleChoiceEdit from "@/components/Generation/multiple.choice.edit";
import Checkbox from "@/components/Low/Checkbox";
const DIFFICULTIES: Difficulty[] = ["easy", "medium", "hard"];
@@ -262,7 +263,7 @@ interface Props {
id: string;
}
const ReadingGeneration = ({ id } : Props) => {
const ReadingGeneration = ({id}: Props) => {
const [part1, setPart1] = useState<ReadingPart>();
const [part2, setPart2] = useState<ReadingPart>();
const [part3, setPart3] = useState<ReadingPart>();
@@ -270,6 +271,7 @@ const ReadingGeneration = ({ id } : Props) => {
const [isLoading, setIsLoading] = useState(false);
const [resultingExam, setResultingExam] = useState<ReadingExam>();
const [difficulty, setDifficulty] = useState<Difficulty>(sample(DIFFICULTIES)!);
const [isPrivate, setPrivate] = useState<boolean>(false);
useEffect(() => {
const parts = [part1, part2, part3].filter((x) => !!x);
@@ -304,7 +306,7 @@ const ReadingGeneration = ({ id } : Props) => {
return;
}
if(!id) {
if (!id) {
toast.error("Please insert a title before submitting");
return;
}
@@ -319,6 +321,7 @@ const ReadingGeneration = ({ id } : Props) => {
type: "academic",
variant: parts.length === 3 ? "full" : "partial",
difficulty,
private: isPrivate,
};
axios
@@ -344,7 +347,7 @@ const ReadingGeneration = ({ id } : Props) => {
return (
<>
<div className="flex gap-4 w-1/2">
<div className="flex gap-4 w-full items-center">
<div className="flex flex-col gap-3">
<label className="font-normal text-base text-mti-gray-dim">Timer</label>
<Input
@@ -355,7 +358,7 @@ const ReadingGeneration = ({ id } : Props) => {
className="max-w-[300px]"
/>
</div>
<div className="flex flex-col gap-3 w-full">
<div className="flex flex-col gap-3 w-1/2">
<label className="font-normal text-base text-mti-gray-dim">Difficulty</label>
<Select
options={DIFFICULTIES.map((x) => ({
@@ -367,6 +370,12 @@ const ReadingGeneration = ({ id } : Props) => {
disabled={!!part1 || !!part2 || !!part3}
/>
</div>
<div className="flex flex-col gap-3 w-fit h-fit">
<div className="h-6" />
<Checkbox isChecked={isPrivate} onChange={setPrivate}>
Privacy (Only available for Assignments)
</Checkbox>
</div>
</div>
<Tab.Group>
<Tab.List className="flex space-x-1 rounded-xl bg-ielts-reading/20 p-1">