43 lines
1.2 KiB
JavaScript
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();
|