feat(exercises): enhance gap exercise creation with contextual prompts and add migration for lesson 43
This commit is contained in:
@@ -598,7 +598,24 @@ function buildGapExercise(lessonTitle, pattern) {
|
||||
}
|
||||
|
||||
function buildContextGapExercise(lesson, didactics, pattern) {
|
||||
const gapExercise = buildGapExercise(lesson.title, pattern);
|
||||
const speakingPrompt = Array.isArray(didactics.speakingPrompts) ? didactics.speakingPrompts[0] : null;
|
||||
const cue = normalizeText(speakingPrompt?.cue || '').toLowerCase();
|
||||
// A contextual prompt must test a pattern that actually occurs in its
|
||||
// scenario. Otherwise a cultural keyword such as "respeto" can be paired
|
||||
// with an invitation-declining situation.
|
||||
const scenarioPattern = didactics.corePatterns
|
||||
.map((entry) => corePatternTarget(entry))
|
||||
.find((candidate) => candidate && cue.includes(normalizeText(candidate).toLowerCase()));
|
||||
const gapExercise = scenarioPattern
|
||||
? {
|
||||
exerciseTypeId: 1,
|
||||
title: `${lesson.title}: Kernmuster ergänzen`,
|
||||
instruction: 'Fülle die Lücke mit dem passenden Bisaya-Ausdruck.',
|
||||
questionData: { type: 'gap_fill', text: '{gap}', gaps: 1 },
|
||||
answerData: { type: 'gap_fill', answers: [scenarioPattern] },
|
||||
explanation: `Das Kernmuster lautet: "${scenarioPattern}".`
|
||||
}
|
||||
: buildGapExercise(lesson.title, pattern);
|
||||
if (!gapExercise) return null;
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user