39 lines
1.6 KiB
JavaScript
39 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const AMBIGUOUS_QUESTION = 'Erzähle einen Tagesplan mit drei Schritten und einem Wunsch. Welche Bisaya-Formulierung passt am besten?';
|
|
const REPAIRED_QUESTION = 'Wie sagt man auf Bisaya: „Zuerst gehe ich zum Markt.“?';
|
|
|
|
module.exports = {
|
|
async up(queryInterface) {
|
|
await queryInterface.sequelize.transaction(async (transaction) => {
|
|
// The former free-production prompt has more than one defensible answer,
|
|
// while its multiple-choice data accepts only the first core pattern.
|
|
await queryInterface.sequelize.query(`
|
|
UPDATE community.vocab_grammar_exercise AS exercise
|
|
SET question_data = JSONB_SET(exercise.question_data, '{question}', TO_JSONB(CAST(:repairedQuestion AS text)))
|
|
FROM community.vocab_course_lesson AS lesson
|
|
WHERE exercise.lesson_id = lesson.id
|
|
AND (lesson.id = 38 OR (lesson.course_id = 1 AND lesson.lesson_number = 38))
|
|
AND exercise.question_data->>'type' = 'multiple_choice'
|
|
AND exercise.question_data->>'question' = :ambiguousQuestion;
|
|
`, {
|
|
replacements: { ambiguousQuestion: AMBIGUOUS_QUESTION, repairedQuestion: REPAIRED_QUESTION },
|
|
transaction
|
|
});
|
|
|
|
// This lesson is designed for a 78% target. With six questions, five
|
|
// correct answers (83%) must therefore pass.
|
|
await queryInterface.sequelize.query(`
|
|
UPDATE community.vocab_course_lesson
|
|
SET target_score_percent = 78
|
|
WHERE id = 38
|
|
OR (course_id = 1 AND lesson_number = 38);
|
|
`, { transaction });
|
|
});
|
|
},
|
|
|
|
async down() {
|
|
// The repair is intentionally not reverted: the old data is ambiguous.
|
|
}
|
|
};
|