Merged with develop
This commit is contained in:
@@ -6,181 +6,181 @@ import { levelPart, listeningSection, readingPart, speakingTask, writingTask } f
|
||||
|
||||
|
||||
export const defaultSettings = (module: Module) => {
|
||||
const baseSettings = {
|
||||
category: '',
|
||||
introOption: { label: 'None', value: 'None' },
|
||||
customIntro: '',
|
||||
currentIntro: '',
|
||||
topic: '',
|
||||
isCategoryDropdownOpen: false,
|
||||
isIntroDropdownOpen: false,
|
||||
isExerciseDropdownOpen: false,
|
||||
isTypeDropdownOpen: false,
|
||||
}
|
||||
const baseSettings = {
|
||||
category: '',
|
||||
introOption: { label: 'None', value: 'None' },
|
||||
customIntro: '',
|
||||
currentIntro: '',
|
||||
topic: '',
|
||||
isCategoryDropdownOpen: false,
|
||||
isIntroDropdownOpen: false,
|
||||
isExerciseDropdownOpen: false,
|
||||
isTypeDropdownOpen: false,
|
||||
}
|
||||
|
||||
switch (module) {
|
||||
case 'writing':
|
||||
return {
|
||||
...baseSettings,
|
||||
writingTopic: '',
|
||||
isWritingTopicOpen: false,
|
||||
isImageUploadOpen: false,
|
||||
}
|
||||
case 'reading':
|
||||
return {
|
||||
...baseSettings,
|
||||
isPassageOpen: false,
|
||||
readingTopic: '',
|
||||
isReadingTopicOpean: false,
|
||||
}
|
||||
case 'listening':
|
||||
return {
|
||||
...baseSettings,
|
||||
isAudioContextOpen: false,
|
||||
isAudioGenerationOpen: false,
|
||||
listeningTopic: '',
|
||||
isListeningTopicOpen: false,
|
||||
}
|
||||
case 'speaking':
|
||||
return {
|
||||
...baseSettings,
|
||||
speakingTopic: '',
|
||||
speakingSecondTopic: '',
|
||||
isSpeakingTopicOpen: false,
|
||||
isGenerateVideoOpen: false,
|
||||
}
|
||||
case 'level':
|
||||
return {
|
||||
...baseSettings,
|
||||
isReadingDropdownOpen: false,
|
||||
isWritingDropdownOpen: false,
|
||||
isSpeakingDropdownOpen: false,
|
||||
isListeningDropdownOpen: false,
|
||||
switch (module) {
|
||||
case 'writing':
|
||||
return {
|
||||
...baseSettings,
|
||||
writingTopic: '',
|
||||
isWritingTopicOpen: false,
|
||||
isImageUploadOpen: false,
|
||||
}
|
||||
case 'reading':
|
||||
return {
|
||||
...baseSettings,
|
||||
isPassageOpen: false,
|
||||
readingTopic: '',
|
||||
isReadingTopicOpean: false,
|
||||
}
|
||||
case 'listening':
|
||||
return {
|
||||
...baseSettings,
|
||||
isAudioContextOpen: false,
|
||||
isAudioGenerationOpen: false,
|
||||
listeningTopic: '',
|
||||
isListeningTopicOpen: false,
|
||||
}
|
||||
case 'speaking':
|
||||
return {
|
||||
...baseSettings,
|
||||
speakingTopic: '',
|
||||
speakingSecondTopic: '',
|
||||
isSpeakingTopicOpen: false,
|
||||
isGenerateVideoOpen: false,
|
||||
}
|
||||
case 'level':
|
||||
return {
|
||||
...baseSettings,
|
||||
isReadingDropdownOpen: false,
|
||||
isWritingDropdownOpen: false,
|
||||
isSpeakingDropdownOpen: false,
|
||||
isListeningDropdownOpen: false,
|
||||
|
||||
isWritingTopicOpen: false,
|
||||
isImageUploadOpen: false,
|
||||
writingTopic: '',
|
||||
isWritingTopicOpen: false,
|
||||
isImageUploadOpen: false,
|
||||
writingTopic: '',
|
||||
|
||||
isPassageOpen: false,
|
||||
readingTopic: '',
|
||||
isReadingTopicOpean: false,
|
||||
isPassageOpen: false,
|
||||
readingTopic: '',
|
||||
isReadingTopicOpean: false,
|
||||
|
||||
isAudioContextOpen: false,
|
||||
isAudioGenerationOpen: false,
|
||||
listeningTopic: '',
|
||||
isListeningTopicOpen: false,
|
||||
isAudioContextOpen: false,
|
||||
isAudioGenerationOpen: false,
|
||||
listeningTopic: '',
|
||||
isListeningTopicOpen: false,
|
||||
|
||||
speakingTopic: '',
|
||||
speakingSecondTopic: '',
|
||||
isSpeakingTopicOpen: false,
|
||||
isGenerateVideoOpen: false,
|
||||
}
|
||||
default:
|
||||
return baseSettings;
|
||||
}
|
||||
speakingTopic: '',
|
||||
speakingSecondTopic: '',
|
||||
isSpeakingTopicOpen: false,
|
||||
isGenerateVideoOpen: false,
|
||||
}
|
||||
default:
|
||||
return baseSettings;
|
||||
}
|
||||
}
|
||||
|
||||
export const sectionLabels = (module: Module, levelParts?: number) => {
|
||||
switch (module) {
|
||||
case 'reading':
|
||||
return Array.from({ length: 3 }, (_, index) => ({
|
||||
id: index + 1,
|
||||
label: `Passage ${index + 1}`
|
||||
}));
|
||||
case 'writing':
|
||||
return [{ id: 1, label: "Task 1" }, { id: 2, label: "Task 2" }];
|
||||
case 'speaking':
|
||||
return [{ id: 1, label: "Speaking 1" }, { id: 2, label: "Speaking 2" }, { id: 3, label: "Interactive Speaking" }];
|
||||
case 'listening':
|
||||
return Array.from({ length: 4 }, (_, index) => ({
|
||||
id: index + 1,
|
||||
label: `Section ${index + 1}`
|
||||
}));
|
||||
case 'level':
|
||||
return levelParts !== undefined ?
|
||||
Array.from({ length: levelParts }, (_, index) => ({
|
||||
id: index + 1,
|
||||
label: `Part ${index + 1}`
|
||||
}))
|
||||
:
|
||||
[{ id: 1, label: "Part 1" }];
|
||||
}
|
||||
switch (module) {
|
||||
case 'reading':
|
||||
return Array.from({ length: 3 }, (_, index) => ({
|
||||
id: index + 1,
|
||||
label: `Passage ${index + 1}`
|
||||
}));
|
||||
case 'writing':
|
||||
return [{ id: 1, label: "Task 1" }, { id: 2, label: "Task 2" }];
|
||||
case 'speaking':
|
||||
return [{ id: 1, label: "Speaking 1" }, { id: 2, label: "Speaking 2" }, { id: 3, label: "Interactive Speaking" }];
|
||||
case 'listening':
|
||||
return Array.from({ length: 4 }, (_, index) => ({
|
||||
id: index + 1,
|
||||
label: `Section ${index + 1}`
|
||||
}));
|
||||
case 'level':
|
||||
return levelParts !== undefined ?
|
||||
Array.from({ length: levelParts }, (_, index) => ({
|
||||
id: index + 1,
|
||||
label: `Part ${index + 1}`
|
||||
}))
|
||||
:
|
||||
[{ id: 1, label: "Part 1" }];
|
||||
}
|
||||
}
|
||||
|
||||
const defaultExamLabel = (module: Module) => {
|
||||
switch (module) {
|
||||
case 'reading':
|
||||
return "Reading Exam";
|
||||
case 'writing':
|
||||
return "Writing Exam";
|
||||
case 'speaking':
|
||||
return "Speaking Exam";
|
||||
case 'listening':
|
||||
return "Listening Exam";
|
||||
case 'level':
|
||||
return "Placement Test";
|
||||
}
|
||||
switch (module) {
|
||||
case 'reading':
|
||||
return "Reading Exam";
|
||||
case 'writing':
|
||||
return "Writing Exam";
|
||||
case 'speaking':
|
||||
return "Speaking Exam";
|
||||
case 'listening':
|
||||
return "Listening Exam";
|
||||
case 'level':
|
||||
return "Placement Test";
|
||||
}
|
||||
}
|
||||
|
||||
const defaultSection = (module: Module, sectionId: number) => {
|
||||
switch (module) {
|
||||
case 'reading':
|
||||
return readingPart(sectionId);
|
||||
case 'writing':
|
||||
return writingTask(sectionId);
|
||||
case 'listening':
|
||||
return listeningSection(sectionId)
|
||||
case 'speaking':
|
||||
return speakingTask(sectionId)
|
||||
case 'level':
|
||||
return levelPart(sectionId)
|
||||
}
|
||||
switch (module) {
|
||||
case 'reading':
|
||||
return readingPart(sectionId);
|
||||
case 'writing':
|
||||
return writingTask(sectionId);
|
||||
case 'listening':
|
||||
return listeningSection(sectionId)
|
||||
case 'speaking':
|
||||
return speakingTask(sectionId)
|
||||
case 'level':
|
||||
return levelPart(sectionId)
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultSectionSettings = (module: Module, sectionId: number, part?: ExamPart) => {
|
||||
return {
|
||||
sectionId: sectionId,
|
||||
settings: defaultSettings(module),
|
||||
state: part !== undefined ? part : defaultSection(module, sectionId),
|
||||
generating: undefined,
|
||||
genResult: undefined,
|
||||
focusedExercise: undefined,
|
||||
expandedSubSections: [],
|
||||
levelGenerating: [],
|
||||
levelGenResults: [],
|
||||
scriptLoading: false,
|
||||
}
|
||||
return {
|
||||
sectionId: sectionId,
|
||||
settings: defaultSettings(module),
|
||||
state: part !== undefined ? part : defaultSection(module, sectionId),
|
||||
generating: undefined,
|
||||
genResult: undefined,
|
||||
focusedExercise: undefined,
|
||||
expandedSubSections: [],
|
||||
levelGenerating: [],
|
||||
levelGenResults: [],
|
||||
scriptLoading: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const defaultModuleSettings = (module: Module, minTimer: number): ModuleState => {
|
||||
const state: ModuleState = {
|
||||
examLabel: defaultExamLabel(module),
|
||||
minTimer,
|
||||
difficulty: sample(["A1", "A2", "B1", "B2", "C1", "C2"] as Difficulty[])!,
|
||||
isPrivate: false,
|
||||
sectionLabels: sectionLabels(module),
|
||||
expandedSections: [1],
|
||||
focusedSection: 1,
|
||||
sections: [defaultSectionSettings(module, 1)],
|
||||
importModule: true,
|
||||
importing: false,
|
||||
edit: [],
|
||||
instructionsState: {
|
||||
isInstructionsOpen: false,
|
||||
chosenOption: { value: "Automatic", label: "Automatic" },
|
||||
currentInstructions: "",
|
||||
presetInstructions: "",
|
||||
customInstructions: "",
|
||||
currentInstructionsURL: "",
|
||||
presetInstructionsURL: "",
|
||||
customInstructionsURL: "",
|
||||
},
|
||||
};
|
||||
if (["reading", "writing"].includes(module)) {
|
||||
state["type"] = "general";
|
||||
}
|
||||
return state;
|
||||
const state: ModuleState = {
|
||||
examLabel: defaultExamLabel(module),
|
||||
minTimer,
|
||||
difficulty: sample(["A1", "A2", "B1", "B2", "C1", "C2"] as Difficulty[])!,
|
||||
isPrivate: true,
|
||||
sectionLabels: sectionLabels(module),
|
||||
expandedSections: [1],
|
||||
focusedSection: 1,
|
||||
sections: [defaultSectionSettings(module, 1)],
|
||||
importModule: true,
|
||||
importing: false,
|
||||
edit: [],
|
||||
instructionsState: {
|
||||
isInstructionsOpen: false,
|
||||
chosenOption: { value: "Automatic", label: "Automatic" },
|
||||
currentInstructions: "",
|
||||
presetInstructions: "",
|
||||
customInstructions: "",
|
||||
currentInstructionsURL: "",
|
||||
presetInstructionsURL: "",
|
||||
customInstructionsURL: "",
|
||||
},
|
||||
};
|
||||
if (["reading", "writing"].includes(module)) {
|
||||
state["type"] = "general";
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
export default defaultModuleSettings;
|
||||
|
||||
Reference in New Issue
Block a user