Files
tasks-backend/tests/get-question-mapping.js
2025-12-26 23:56:32 +02:00

43 lines
1.2 KiB
JavaScript

const { Question, Category } = require('../models');
async function getQuestionMapping() {
try {
const questions = await Question.findAll({
where: { isActive: true },
attributes: ['id', 'questionText', 'difficulty', 'categoryId'],
include: [{
model: Category,
as: 'category',
attributes: ['name', 'guestAccessible']
}],
limit: 15
});
console.log('=== Question ID Mapping ===\n');
const mapping = {};
questions.forEach((q, index) => {
const key = `QUESTION_${index + 1}`;
const shortText = q.questionText.substring(0, 60);
console.log(`${key} (${q.category.name} - ${q.difficulty})${q.category.guestAccessible ? ' [GUEST]' : ' [AUTH]'}`);
console.log(` ID: ${q.id}`);
console.log(` Question: ${shortText}...\n`);
mapping[key] = q.id;
});
console.log('\nFor tests, use:');
console.log('const QUESTION_IDS = {');
Object.entries(mapping).forEach(([key, value]) => {
console.log(` ${key}: '${value}',`);
});
console.log('};');
} catch (error) {
console.error('Error:', error);
} finally {
process.exit(0);
}
}
getQuestionMapping();