Added Speaking to level, fixed a bug where it was causing level to crash if the listening was already created and the section was switched, added true false exercises to listening
This commit is contained in:
@@ -130,25 +130,51 @@ const ExercisePicker: React.FC<ExercisePickerProps> = ({
|
||||
);
|
||||
});
|
||||
} else {
|
||||
/*const newExercises = configurations.map((config) => {
|
||||
switch (config.type) {
|
||||
case 'writing_letter':
|
||||
return { ...writingTask(1), level: true };
|
||||
case 'writing_2':
|
||||
return { ...writingTask(2), level: true };
|
||||
}
|
||||
return undefined;
|
||||
}).filter((ex) => ex !== undefined);
|
||||
dispatch({
|
||||
type: "UPDATE_SECTION_STATE", payload: {
|
||||
module: level ? "level" : module as Module, sectionId, update: {
|
||||
exercises: [
|
||||
...(sections.find((s) => s.sectionId = sectionId)?.state as LevelPart).exercises,
|
||||
...newExercises
|
||||
]
|
||||
}
|
||||
}
|
||||
})*/
|
||||
configurations.forEach((config) => {
|
||||
let queryParams = Object.fromEntries(
|
||||
Object.entries({
|
||||
topic: config.params.topic as string,
|
||||
first_topic: config.params.first_topic as string,
|
||||
second_topic: config.params.second_topic as string,
|
||||
}).filter(([_, value]) => value && value !== '')
|
||||
);
|
||||
let query = Object.keys(queryParams).length === 0 ? undefined : queryParams;
|
||||
generate(
|
||||
Number(config.type.split('_')[1]),
|
||||
"speaking",
|
||||
config.type,
|
||||
{
|
||||
method: 'GET',
|
||||
queryParams: query
|
||||
},
|
||||
(data: any) => {
|
||||
switch (Number(config.type.split('_')[1])) {
|
||||
case 1:
|
||||
return [{
|
||||
prompts: data.questions,
|
||||
first_topic: data.first_topic,
|
||||
second_topic: data.second_topic
|
||||
}];
|
||||
case 2:
|
||||
return [{
|
||||
topic: data.topic,
|
||||
question: data.question,
|
||||
prompts: data.prompts,
|
||||
suffix: data.suffix
|
||||
}];
|
||||
case 3:
|
||||
return [{
|
||||
topic: data.topic,
|
||||
questions: data.questions
|
||||
}];
|
||||
default:
|
||||
return [data];
|
||||
}
|
||||
},
|
||||
levelSectionId,
|
||||
level
|
||||
);
|
||||
});
|
||||
}
|
||||
setLocalSelectedExercises([]);
|
||||
setPickerOpen(false);
|
||||
|
||||
Reference in New Issue
Block a user