feat(exercises): enhance gap exercise creation with contextual prompts and add migration for lesson 43

This commit is contained in:
Torsten Schulz (local)
2026-08-26 12:10:29 +02:00
parent 6708162a62
commit 4d478df181
2 changed files with 46 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
'use strict';
const LESSON_TITLE = 'Kultur: Höflichkeit, Familie, Alltag';
module.exports = {
async up(queryInterface) {
await queryInterface.sequelize.transaction(async (transaction) => {
// The old task asked for a soft refusal to an invitation, but expected
// the unrelated cultural keyword "respeto". Test the matching phrase.
await queryInterface.sequelize.query(`
UPDATE community.vocab_grammar_exercise AS exercise
SET question_data = '{"type":"gap_fill","text":"{gap}","gaps":1}'::jsonb,
answer_data = '{"type":"gap_fill","answers":["Dili lang sa karon."]}'::jsonb,
explanation = 'Das Kernmuster lautet: "Dili lang sa karon."'
FROM community.vocab_course_lesson AS lesson
WHERE exercise.lesson_id = lesson.id
AND (lesson.id = 40 OR (lesson.course_id = 1 AND lesson.lesson_number = 43))
AND exercise.title = :lessonTitle || ': Kernmuster ergänzen'
AND exercise.question_data->>'type' = 'gap_fill'
AND exercise.answer_data->'answers' @> '["respeto"]'::jsonb;
`, { replacements: { lessonTitle: LESSON_TITLE }, transaction });
});
},
async down() {
// Do not restore the semantically mismatched task.
}
};