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

@@ -11,14 +11,16 @@ interface Props {
export default function Checkbox({isChecked, onChange, children, disabled}: Props) {
return (
<div className="flex gap-3 items-center text-mti-gray-dim text-sm cursor-pointer" onClick={() => {
<div
className="flex gap-3 items-center text-mti-gray-dim text-sm cursor-pointer"
onClick={() => {
if (disabled) return;
onChange(!isChecked);
}}>
<input type="checkbox" className="hidden" />
<div
className={clsx(
"w-6 h-6 rounded-md flex items-center justify-center border border-mti-purple-light bg-white",
"w-6 h-6 min-w-6 min-h-6 rounded-md flex items-center justify-center border border-mti-purple-light bg-white",
"transition duration-300 ease-in-out",
isChecked && "!bg-mti-purple-light ",
)}>

View File

@@ -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 {
@@ -242,6 +243,7 @@ const LevelGeneration = ({ id } : Props) => {
const [difficulty, setDifficulty] = useState<Difficulty>(sample(DIFFICULTIES)!);
const [numberOfParts, setNumberOfParts] = useState(1);
const [parts, setParts] = useState<LevelSection[]>([{quantity: 10, type: "multiple_choice_4"}]);
const [isPrivate, setPrivate] = useState<boolean>(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;
@@ -456,8 +459,8 @@ const LevelGeneration = ({ id } : Props) => {
return (
<>
<div className="flex gap-4 w-full">
<div className="flex flex-col gap-3 w-full">
<div className="flex gap-4 w-full items-center">
<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) => ({
@@ -468,14 +471,20 @@ const LevelGeneration = ({ id } : Props) => {
value={{value: difficulty, label: capitalize(difficulty)}}
/>
</div>
<div className="flex flex-col gap-3 w-full">
<div className="flex flex-col gap-3 w-1/3">
<label className="font-normal text-base text-mti-gray-dim">Number of Parts</label>
<Input type="number" name="Number of Parts" onChange={(v) => setNumberOfParts(parseInt(v))} value={numberOfParts} />
</div>
<div className="flex flex-col gap-3 w-full">
<div className="flex flex-col gap-3 w-1/3">
<label className="font-normal text-base text-mti-gray-dim">Timer (in minutes)</label>
<Input type="number" name="Timer (in minutes)" onChange={(v) => setTimer(parseInt(v))} value={timer} />
</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-level/20 p-1">

View File

@@ -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"];
@@ -241,6 +242,7 @@ const ListeningGeneration = ({ id } : Props) => {
const [isLoading, setIsLoading] = useState(false);
const [resultingExam, setResultingExam] = useState<ListeningExam>();
const [difficulty, setDifficulty] = useState<Difficulty>(sample(DIFFICULTIES)!);
const [isPrivate, setPrivate] = useState<boolean>(false);
useEffect(() => {
const part1Timer = part1 ? 5 : 0;
@@ -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 (
<>
<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
@@ -324,7 +327,7 @@ const ListeningGeneration = ({ 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) => ({
@@ -336,6 +339,12 @@ const ListeningGeneration = ({ id } : Props) => {
disabled={!!part1 || !!part2 || !!part3 || !!part4}
/>
</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-listening/20 p-1">

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"];
@@ -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);
@@ -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">

View File

@@ -1,3 +1,4 @@
import Checkbox from "@/components/Low/Checkbox";
import Input from "@/components/Low/Input";
import Select from "@/components/Low/Select";
import {Difficulty, Exercise, InteractiveSpeakingExercise, SpeakingExam, SpeakingExercise} from "@/interfaces/exam";
@@ -233,6 +234,7 @@ const SpeakingGeneration = ({ id } : Props) => {
const [isLoading, setIsLoading] = useState(false);
const [resultingExam, setResultingExam] = useState<SpeakingExam>();
const [difficulty, setDifficulty] = useState<Difficulty>(sample(DIFFICULTIES)!);
const [isPrivate, setPrivate] = useState<boolean>(false);
useEffect(() => {
const parts = [part1, part2, part3].filter((x) => !!x);
@@ -272,6 +274,7 @@ const SpeakingGeneration = ({ id } : Props) => {
variant: minTimer >= 14 ? "full" : "partial",
module: "speaking",
instructorGender: genders.every((x) => x === "male") ? "male" : genders.every((x) => x === "female") ? "female" : "varied",
private: isPrivate,
};
axios
@@ -313,7 +316,7 @@ const SpeakingGeneration = ({ 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
@@ -324,7 +327,7 @@ const SpeakingGeneration = ({ 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) => ({
@@ -336,6 +339,13 @@ const SpeakingGeneration = ({ 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>

View File

@@ -1,3 +1,4 @@
import Checkbox from "@/components/Low/Checkbox";
import Input from "@/components/Low/Input";
import Select from "@/components/Low/Select";
import {Difficulty, WritingExam, WritingExercise} from "@/interfaces/exam";
@@ -86,6 +87,7 @@ const WritingGeneration = ({ id } : Props) => {
const [isLoading, setIsLoading] = useState(false);
const [resultingExam, setResultingExam] = useState<WritingExam>();
const [difficulty, setDifficulty] = useState<Difficulty>(sample(DIFFICULTIES)!);
const [isPrivate, setPrivate] = useState<boolean>(false);
useEffect(() => {
const task1Timer = task1 ? 20 : 0;
@@ -164,6 +166,7 @@ const WritingGeneration = ({ id } : Props) => {
id,
variant: exercise1 && exercise2 ? "full" : "partial",
difficulty,
private: isPrivate,
};
axios
@@ -188,7 +191,7 @@ const WritingGeneration = ({ 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
@@ -199,7 +202,7 @@ const WritingGeneration = ({ 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) => ({value: x, label: capitalize(x)}))}
@@ -208,6 +211,13 @@ const WritingGeneration = ({ id } : Props) => {
disabled={!!task1 || !!task2}
/>
</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>