add changes
This commit is contained in:
42
backend/tests/get-question-mapping.js
Normal file
42
backend/tests/get-question-mapping.js
Normal file
@@ -0,0 +1,42 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user