ENCOA-312
This commit is contained in:
@@ -43,12 +43,14 @@ const ExerciseWizard: React.FC<Props> = ({
|
|||||||
const { difficulty } = useExamEditorStore(state => state.modules[currentModule]);
|
const { difficulty } = useExamEditorStore(state => state.modules[currentModule]);
|
||||||
|
|
||||||
const randomDiff = difficulty.length === 1
|
const randomDiff = difficulty.length === 1
|
||||||
? capitalize(difficulty[0])
|
? capitalize(difficulty[0])
|
||||||
: `Random (${difficulty.map(dif => capitalize(dif)).join(", ")})` as Difficulty;
|
: difficulty.length == 0 ?
|
||||||
|
"Random" :
|
||||||
|
`Selected (${difficulty.sort().map(dif => capitalize(dif)).join(", ")})` as Difficulty;
|
||||||
|
|
||||||
const DIFFICULTIES = difficulty.length === 1
|
const DIFFICULTIES = difficulty.length === 1
|
||||||
? ["A1", "A2", "B1", "B2", "C1", "C2"]
|
? ["A1", "A2", "B1", "B2", "C1", "C2", "Random"]
|
||||||
: ["A1", "A2", "B1", "B2", "C1", "C2", randomDiff];
|
: ["A1", "A2", "B1", "B2", "C1", "C2", randomDiff, "Random"];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const initialConfigs = selectedExercises.map(exerciseType => {
|
const initialConfigs = selectedExercises.map(exerciseType => {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const ExercisePicker: React.FC<ExercisePickerProps> = ({
|
|||||||
...(config.params.max_words !== undefined && {
|
...(config.params.max_words !== undefined && {
|
||||||
max_words: Number(config.params.max_words)
|
max_words: Number(config.params.max_words)
|
||||||
}),
|
}),
|
||||||
...(DIFFICULTIES.includes(config.params.difficulty as string) && {
|
...((DIFFICULTIES.includes(config.params.difficulty as string) || config.params.difficulty === "Random") && {
|
||||||
difficulty: config.params.difficulty
|
difficulty: config.params.difficulty
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,12 +41,14 @@ const SpeakingComponents: React.FC<Props> = ({ localSettings, updateLocalAndSche
|
|||||||
const [selectedAvatar, setSelectedAvatar] = useState<Avatar | null>(null);
|
const [selectedAvatar, setSelectedAvatar] = useState<Avatar | null>(null);
|
||||||
|
|
||||||
const randomDiff = difficulty.length === 1
|
const randomDiff = difficulty.length === 1
|
||||||
? capitalize(difficulty[0])
|
? capitalize(difficulty[0])
|
||||||
: `Random (${difficulty.map(dif => capitalize(dif)).join(", ")})` as Difficulty;
|
: difficulty.length == 0 ?
|
||||||
|
"Random" :
|
||||||
const DIFFICULTIES = difficulty.length === 1
|
`Selected (${difficulty.sort().map(dif => capitalize(dif)).join(", ")})` as Difficulty;
|
||||||
? ["A1", "A2", "B1", "B2", "C1", "C2"]
|
|
||||||
: ["A1", "A2", "B1", "B2", "C1", "C2", randomDiff];
|
const DIFFICULTIES = difficulty.length === 1
|
||||||
|
? ["A1", "A2", "B1", "B2", "C1", "C2", "Random"]
|
||||||
|
: ["A1", "A2", "B1", "B2", "C1", "C2", randomDiff, "Random"];
|
||||||
|
|
||||||
const difficultyOptions: Option[] = DIFFICULTIES.map(level => ({
|
const difficultyOptions: Option[] = DIFFICULTIES.map(level => ({
|
||||||
label: level,
|
label: level,
|
||||||
|
|||||||
@@ -31,12 +31,14 @@ const WritingComponents: React.FC<Props> = ({ localSettings, updateLocalAndSched
|
|||||||
} = useExamEditorStore((store) => store.modules["writing"]);
|
} = useExamEditorStore((store) => store.modules["writing"]);
|
||||||
|
|
||||||
const randomDiff = difficulty.length === 1
|
const randomDiff = difficulty.length === 1
|
||||||
? capitalize(difficulty[0])
|
? capitalize(difficulty[0])
|
||||||
: `Random (${difficulty.map(dif => capitalize(dif)).join(", ")})` as Difficulty;
|
: difficulty.length == 0 ?
|
||||||
|
"Random" :
|
||||||
|
`Selected (${difficulty.sort().map(dif => capitalize(dif)).join(", ")})` as Difficulty;
|
||||||
|
|
||||||
const DIFFICULTIES = difficulty.length === 1
|
const DIFFICULTIES = difficulty.length === 1
|
||||||
? ["A1", "A2", "B1", "B2", "C1", "C2"]
|
? ["A1", "A2", "B1", "B2", "C1", "C2", "Random"]
|
||||||
: ["A1", "A2", "B1", "B2", "C1", "C2", randomDiff];
|
: ["A1", "A2", "B1", "B2", "C1", "C2", randomDiff, "Random"];
|
||||||
|
|
||||||
const difficultyOptions: Option[] = DIFFICULTIES.map(level => ({
|
const difficultyOptions: Option[] = DIFFICULTIES.map(level => ({
|
||||||
label: level,
|
label: level,
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ const ResetModule: React.FC<Props> = ({ module, isOpen, setIsOpen, setNumberOfLe
|
|||||||
const handleResetModule = () => {
|
const handleResetModule = () => {
|
||||||
dispatch({ type: 'RESET_MODULE', payload: { module } });
|
dispatch({ type: 'RESET_MODULE', payload: { module } });
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
setNumberOfLevelParts(1);
|
if (module === "level") {
|
||||||
|
setNumberOfLevelParts(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -216,9 +216,13 @@ const ExamEditor: React.FC<{ levelParts?: number }> = ({ levelParts = 0 }) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{currentModule === "listening" && <ListeningInstructions />}
|
{currentModule === "listening" && <ListeningInstructions />}
|
||||||
{["reading", "listening", "level"].includes(currentModule) && <Button onClick={() => setIsResetModuleOpen(true)} customColor={`bg-ielts-${currentModule}/70 hover:bg-ielts-${currentModule} border-ielts-${currentModule}`} className={`text-white self-end`}>
|
<Button
|
||||||
Reset Module
|
onClick={() => setIsResetModuleOpen(true)}
|
||||||
</Button>}
|
customColor={`bg-ielts-${currentModule}/70 hover:bg-ielts-${currentModule} border-ielts-${currentModule}`}
|
||||||
|
className={`text-white self-end`}
|
||||||
|
>
|
||||||
|
Reset Module
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row gap-8">
|
<div className="flex flex-row gap-8">
|
||||||
<Settings />
|
<Settings />
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ async function patch(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
await Promise.all(newParticipants.map(async (p) => await updateExpiryDateOnGroup(p, group.admin)));
|
await Promise.all(newParticipants.map(async (p) => await updateExpiryDateOnGroup(p, group.admin)));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(req.body);
|
|
||||||
await db.collection("groups").updateOne({id}, {$set: {id, ...req.body}}, {upsert: true});
|
await db.collection("groups").updateOne({id}, {$set: {id, ...req.body}}, {upsert: true});
|
||||||
|
|
||||||
res.status(200).json({ok: true});
|
res.status(200).json({ok: true});
|
||||||
|
|||||||
@@ -153,14 +153,14 @@ export const defaultSectionSettings = (module: Module, sectionId: number, part?:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const defaultModuleSettings = (module: Module, minTimer: number): ModuleState => {
|
const defaultModuleSettings = (module: Module, minTimer: number, reset: boolean = false): ModuleState => {
|
||||||
const state: ModuleState = {
|
const state: ModuleState = {
|
||||||
examLabel: defaultExamLabel(module),
|
examLabel: defaultExamLabel(module),
|
||||||
minTimer,
|
minTimer,
|
||||||
difficulty: [sample(["A1", "A2", "B1", "B2", "C1", "C2"] as Difficulty[])!],
|
difficulty: [sample(["A1", "A2", "B1", "B2", "C1", "C2"] as Difficulty[])!],
|
||||||
isPrivate: true,
|
isPrivate: true,
|
||||||
sectionLabels: sectionLabels(module),
|
sectionLabels: sectionLabels(module),
|
||||||
expandedSections: [1],
|
expandedSections: [(reset && (module === "writing" || module === "speaking")) ? 0 : 1],
|
||||||
focusedSection: 1,
|
focusedSection: 1,
|
||||||
sections: [defaultSectionSettings(module, 1)],
|
sections: [defaultSectionSettings(module, 1)],
|
||||||
importModule: true,
|
importModule: true,
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export const rootReducer = (
|
|||||||
return {
|
return {
|
||||||
modules: {
|
modules: {
|
||||||
...state.modules,
|
...state.modules,
|
||||||
[module]: defaultModuleSettings(module, timer),
|
[module]: defaultModuleSettings(module, timer, true),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
case 'FULL_RESET':
|
case 'FULL_RESET':
|
||||||
|
|||||||
Reference in New Issue
Block a user