feat(bisaya): enhance situational response exercises with keyword hints and minimum match requirements
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
const OLD_QUESTION = 'Erzähle einen Tagesplan mit drei Schritten und einem Wunsch.';
|
||||
const REPAIRED_QUESTION = 'Schreibe vier kurze Sätze auf Bisaya. Verwende dabei alle diese Bausteine: Una, Pagkahuman, Unya und Gusto ko nga.';
|
||||
const KEYWORDS = ['una', 'pagkahuman', 'unya', 'gusto ko nga'];
|
||||
const MODEL_ANSWER = 'Una, moadto ko sa merkado. Pagkahuman, kuhaon nako ang bata. Unya, mouli mi sa balay. Gusto ko nga magkita ta ugma.';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.sequelize.transaction(async (transaction) => {
|
||||
// This was an open-ended production prompt, but the checker required four
|
||||
// hidden words. Make both the expected language and the four criteria
|
||||
// explicit, while still accepting every answer that fulfils them.
|
||||
await queryInterface.sequelize.query(`
|
||||
UPDATE community.vocab_grammar_exercise AS exercise
|
||||
SET question_data = JSONB_SET(
|
||||
JSONB_SET(
|
||||
JSONB_SET(exercise.question_data, '{question}', TO_JSONB(CAST(:repairedQuestion AS text))),
|
||||
'{keywords}', CAST(:keywords AS jsonb)
|
||||
),
|
||||
'{minKeywordMatches}', '4'::jsonb
|
||||
),
|
||||
answer_data = JSONB_SET(
|
||||
JSONB_SET(
|
||||
JSONB_SET(COALESCE(exercise.answer_data, '{}'::jsonb), '{modelAnswer}', TO_JSONB(CAST(:modelAnswer AS text))),
|
||||
'{keywords}', CAST(:keywords AS jsonb)
|
||||
),
|
||||
'{minKeywordMatches}', '4'::jsonb
|
||||
)
|
||||
FROM community.vocab_course_lesson AS lesson
|
||||
WHERE exercise.lesson_id = lesson.id
|
||||
AND (lesson.id = 39 OR (lesson.course_id = 1 AND lesson.lesson_number = 39))
|
||||
AND exercise.question_data->>'type' = 'situational_response'
|
||||
AND exercise.question_data->>'question' = :oldQuestion;
|
||||
`, {
|
||||
replacements: {
|
||||
oldQuestion: OLD_QUESTION,
|
||||
repairedQuestion: REPAIRED_QUESTION,
|
||||
keywords: JSON.stringify(KEYWORDS),
|
||||
modelAnswer: MODEL_ANSWER
|
||||
},
|
||||
transaction
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async down() {
|
||||
// Keep the unambiguous exercise wording once deployed.
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user