Files
tasks-backend/seeders/20251110193134-demo-questions.js
2025-12-26 23:56:32 +02:00

948 lines
40 KiB
JavaScript

'use strict';
const { v4: uuidv4 } = require('uuid');
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
// First, get the category IDs we need
const [categories] = await queryInterface.sequelize.query(
`SELECT id, slug FROM categories WHERE slug IN ('javascript', 'angular', 'react', 'nodejs', 'typescript', 'sql-databases', 'system-design')`
);
const categoryMap = {};
categories.forEach(cat => {
categoryMap[cat.slug] = cat.id;
});
// Get admin user ID for created_by
const [users] = await queryInterface.sequelize.query(
`SELECT id FROM users WHERE email = 'admin@quiz.com' LIMIT 1`
);
const adminId = users[0]?.id || null;
const questions = [];
// JavaScript Questions (15 questions)
const jsQuestions = [
{
id: uuidv4(),
category_id: categoryMap['javascript'],
question_text: 'What is the difference between let and var in JavaScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'let has block scope, var has function scope' },
{ id: 'b', text: 'var has block scope, let has function scope' },
{ id: 'c', text: 'They are exactly the same' },
{ id: 'd', text: 'let cannot be reassigned' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'let has block scope (only accessible within {}), while var has function scope (accessible anywhere in the function).',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['scope', 'let', 'var', 'es6']),
tags: JSON.stringify(['variables', 'scope', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['javascript'],
question_text: 'What is a closure in JavaScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A function that returns another function' },
{ id: 'b', text: 'A function that has access to variables from its outer scope' },
{ id: 'c', text: 'A function that closes the browser' },
{ id: 'd', text: 'A method to close database connections' }
]),
correct_answer: JSON.stringify(['b']),
explanation: 'A closure is a function that remembers and can access variables from its outer (enclosing) scope, even after the outer function has finished executing.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['closure', 'scope', 'lexical']),
tags: JSON.stringify(['functions', 'scope', 'advanced']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['javascript'],
question_text: 'What does the spread operator (...) do in JavaScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Creates a copy of an array or object' },
{ id: 'b', text: 'Expands an iterable into individual elements' },
{ id: 'c', text: 'Both A and B' },
{ id: 'd', text: 'Performs mathematical operations' }
]),
correct_answer: JSON.stringify(['c']),
explanation: 'The spread operator (...) can expand iterables into individual elements and is commonly used to copy arrays/objects or pass elements as function arguments.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['spread', 'operator', 'es6', 'array']),
tags: JSON.stringify(['operators', 'es6', 'arrays']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['javascript'],
question_text: 'What is the purpose of Promise.all()?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Waits for all promises to resolve or any to reject' },
{ id: 'b', text: 'Runs promises sequentially' },
{ id: 'c', text: 'Cancels all promises' },
{ id: 'd', text: 'Returns the first resolved promise' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Promise.all() takes an array of promises and returns a single promise that resolves when all promises resolve, or rejects when any promise rejects.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['promise', 'async', 'concurrent']),
tags: JSON.stringify(['promises', 'async', 'concurrency']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['javascript'],
question_text: 'What is event delegation in JavaScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Attaching event listeners to parent elements to handle events on children' },
{ id: 'b', text: 'Creating custom events' },
{ id: 'c', text: 'Removing event listeners' },
{ id: 'd', text: 'Preventing event propagation' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Event delegation uses event bubbling to handle events on child elements by attaching a single listener to a parent element, improving performance.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['event', 'delegation', 'bubbling', 'dom']),
tags: JSON.stringify(['events', 'dom', 'patterns']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
}
];
// Angular Questions (12 questions)
const angularQuestions = [
{
id: uuidv4(),
category_id: categoryMap['angular'],
question_text: 'What is the purpose of NgModule in Angular?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'To organize application structure and define compilation context' },
{ id: 'b', text: 'To create components' },
{ id: 'c', text: 'To handle routing' },
{ id: 'd', text: 'To manage state' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'NgModule is a decorator that defines a module - a cohesive block of code with related components, directives, pipes, and services. It organizes the application.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['ngmodule', 'module', 'decorator']),
tags: JSON.stringify(['modules', 'architecture', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['angular'],
question_text: 'What is dependency injection in Angular?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A design pattern where dependencies are provided to a class instead of creating them internally' },
{ id: 'b', text: 'A way to import modules' },
{ id: 'c', text: 'A routing technique' },
{ id: 'd', text: 'A method to create components' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Dependency Injection (DI) is a design pattern where Angular provides dependencies (services) to components/services through their constructors, promoting loose coupling.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['di', 'dependency injection', 'service', 'provider']),
tags: JSON.stringify(['di', 'services', 'architecture']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['angular'],
question_text: 'What is the difference between @Input() and @Output() decorators?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: '@Input() receives data from parent, @Output() emits events to parent' },
{ id: 'b', text: '@Input() emits events, @Output() receives data' },
{ id: 'c', text: 'They are the same' },
{ id: 'd', text: '@Input() is for services, @Output() is for components' }
]),
correct_answer: JSON.stringify(['a']),
explanation: '@Input() allows a child component to receive data from its parent, while @Output() with EventEmitter allows a child to emit events to its parent.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['input', 'output', 'decorator', 'communication']),
tags: JSON.stringify(['decorators', 'component-communication', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['angular'],
question_text: 'What is RxJS used for in Angular?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Reactive programming with Observables for async operations' },
{ id: 'b', text: 'Styling components' },
{ id: 'c', text: 'Creating animations' },
{ id: 'd', text: 'Testing components' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'RxJS provides reactive programming capabilities using Observables, which are used extensively in Angular for handling async operations like HTTP requests and events.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['rxjs', 'observable', 'reactive', 'async']),
tags: JSON.stringify(['rxjs', 'async', 'observables']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['angular'],
question_text: 'What is the purpose of Angular lifecycle hooks?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'To tap into key moments in component/directive lifecycle' },
{ id: 'b', text: 'To create routes' },
{ id: 'c', text: 'To style components' },
{ id: 'd', text: 'To handle errors' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Lifecycle hooks like ngOnInit, ngOnChanges, and ngOnDestroy allow you to execute code at specific points in a component or directive\'s lifecycle.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['lifecycle', 'hooks', 'ngoninit']),
tags: JSON.stringify(['lifecycle', 'hooks', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
}
];
// React Questions (12 questions)
const reactQuestions = [
{
id: uuidv4(),
category_id: categoryMap['react'],
question_text: 'What is the virtual DOM in React?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A lightweight copy of the real DOM kept in memory' },
{ id: 'b', text: 'A database for storing component state' },
{ id: 'c', text: 'A routing mechanism' },
{ id: 'd', text: 'A testing library' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'The virtual DOM is a lightweight JavaScript representation of the real DOM. React uses it to optimize updates by comparing changes and updating only what\'s necessary.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['virtual dom', 'reconciliation', 'performance']),
tags: JSON.stringify(['fundamentals', 'performance', 'dom']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['react'],
question_text: 'What is the purpose of useEffect hook?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'To perform side effects in function components' },
{ id: 'b', text: 'To create state variables' },
{ id: 'c', text: 'To handle routing' },
{ id: 'd', text: 'To optimize performance' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'useEffect allows you to perform side effects (data fetching, subscriptions, DOM manipulation) in function components. It runs after render.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['useeffect', 'hook', 'side effects']),
tags: JSON.stringify(['hooks', 'side-effects', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['react'],
question_text: 'What is prop drilling in React?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Passing props through multiple component layers' },
{ id: 'b', text: 'Creating new props' },
{ id: 'c', text: 'Validating prop types' },
{ id: 'd', text: 'Drilling holes in components' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Prop drilling is when you pass props through multiple intermediate components that don\'t need them, just to get them to a deeply nested component.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['props', 'drilling', 'context']),
tags: JSON.stringify(['props', 'patterns', 'architecture']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['react'],
question_text: 'What is the difference between useMemo and useCallback?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'useMemo memoizes values, useCallback memoizes functions' },
{ id: 'b', text: 'useMemo is for functions, useCallback is for values' },
{ id: 'c', text: 'They are exactly the same' },
{ id: 'd', text: 'useMemo is deprecated' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'useMemo returns and memoizes a computed value, while useCallback returns and memoizes a function. Both are used for performance optimization.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['usememo', 'usecallback', 'memoization', 'performance']),
tags: JSON.stringify(['hooks', 'performance', 'optimization']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['react'],
question_text: 'What is React Context API used for?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Sharing data across components without prop drilling' },
{ id: 'b', text: 'Creating routes' },
{ id: 'c', text: 'Managing component lifecycle' },
{ id: 'd', text: 'Optimizing performance' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Context API provides a way to share values between components without explicitly passing props through every level of the tree.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['context', 'api', 'state management']),
tags: JSON.stringify(['context', 'state-management', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
}
];
// Node.js Questions (10 questions)
const nodejsQuestions = [
{
id: uuidv4(),
category_id: categoryMap['nodejs'],
question_text: 'What is the event loop in Node.js?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A mechanism that handles async operations by queuing callbacks' },
{ id: 'b', text: 'A for loop that runs forever' },
{ id: 'c', text: 'A routing system' },
{ id: 'd', text: 'A testing framework' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'The event loop is Node.js\'s mechanism for handling async operations. It continuously checks for and executes callbacks from different phases.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['event loop', 'async', 'callbacks']),
tags: JSON.stringify(['event-loop', 'async', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['nodejs'],
question_text: 'What is middleware in Express.js?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Functions that have access to request, response, and next in the pipeline' },
{ id: 'b', text: 'Database connection code' },
{ id: 'c', text: 'Front-end components' },
{ id: 'd', text: 'Testing utilities' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Middleware functions have access to request and response objects and the next() function. They can execute code, modify req/res, and control the flow.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['middleware', 'express', 'request', 'response']),
tags: JSON.stringify(['express', 'middleware', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['nodejs'],
question_text: 'What is the purpose of package.json in Node.js?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Metadata file containing project info, dependencies, and scripts' },
{ id: 'b', text: 'Configuration for the database' },
{ id: 'c', text: 'Main application entry point' },
{ id: 'd', text: 'Testing configuration' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'package.json is the manifest file for Node.js projects. It contains metadata, dependencies, scripts, and configuration.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['package.json', 'npm', 'dependencies']),
tags: JSON.stringify(['npm', 'configuration', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['nodejs'],
question_text: 'What is the difference between process.nextTick() and setImmediate()?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'nextTick() executes before the event loop continues, setImmediate() after I/O' },
{ id: 'b', text: 'They are exactly the same' },
{ id: 'c', text: 'setImmediate() is synchronous' },
{ id: 'd', text: 'nextTick() is deprecated' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'process.nextTick() callbacks execute immediately after the current operation, before the event loop continues. setImmediate() executes in the check phase.',
difficulty: 'hard',
points: 15,
time_limit: 120,
keywords: JSON.stringify(['nexttick', 'setimmediate', 'event loop']),
tags: JSON.stringify(['event-loop', 'async', 'advanced']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['nodejs'],
question_text: 'What is clustering in Node.js?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Running multiple Node.js processes to utilize all CPU cores' },
{ id: 'b', text: 'Grouping related code together' },
{ id: 'c', text: 'Database optimization technique' },
{ id: 'd', text: 'A design pattern' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Clustering allows you to create child processes (workers) that share server ports, enabling Node.js to utilize all available CPU cores.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['cluster', 'scaling', 'performance']),
tags: JSON.stringify(['clustering', 'scaling', 'performance']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
}
];
// TypeScript Questions (10 questions)
const tsQuestions = [
{
id: uuidv4(),
category_id: categoryMap['typescript'],
question_text: 'What is the difference between interface and type in TypeScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Interfaces can be extended/merged, types are more flexible with unions' },
{ id: 'b', text: 'They are exactly the same' },
{ id: 'c', text: 'Types are deprecated' },
{ id: 'd', text: 'Interfaces only work with objects' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Interfaces can be extended and declared multiple times (declaration merging). Types are more flexible with unions, intersections, and primitives.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['interface', 'type', 'alias']),
tags: JSON.stringify(['types', 'interfaces', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['typescript'],
question_text: 'What is a generic in TypeScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A way to create reusable components that work with multiple types' },
{ id: 'b', text: 'A basic data type' },
{ id: 'c', text: 'A class decorator' },
{ id: 'd', text: 'A testing utility' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Generics allow you to create components that work with any type while maintaining type safety. They\'re like variables for types.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['generic', 'type parameter', 'reusable']),
tags: JSON.stringify(['generics', 'types', 'advanced']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['typescript'],
question_text: 'What is the "never" type in TypeScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A type representing values that never occur' },
{ id: 'b', text: 'A deprecated type' },
{ id: 'c', text: 'Same as void' },
{ id: 'd', text: 'A null type' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'The never type represents values that never occur - functions that always throw errors or infinite loops. It\'s the bottom type.',
difficulty: 'hard',
points: 15,
time_limit: 120,
keywords: JSON.stringify(['never', 'bottom type', 'type system']),
tags: JSON.stringify(['types', 'advanced', 'type-system']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['typescript'],
question_text: 'What is type narrowing in TypeScript?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Refining types through conditional checks to more specific types' },
{ id: 'b', text: 'Making type names shorter' },
{ id: 'c', text: 'Removing types from code' },
{ id: 'd', text: 'Converting types to primitives' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Type narrowing is when TypeScript refines a broader type to a more specific one based on conditional checks (typeof, instanceof, etc.).',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['narrowing', 'type guards', 'refinement']),
tags: JSON.stringify(['type-guards', 'narrowing', 'advanced']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['typescript'],
question_text: 'What is the purpose of the "readonly" modifier?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Makes properties immutable after initialization' },
{ id: 'b', text: 'Hides properties from console.log' },
{ id: 'c', text: 'Marks properties as private' },
{ id: 'd', text: 'Improves performance' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'The readonly modifier prevents properties from being reassigned after initialization, providing compile-time immutability.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['readonly', 'immutable', 'modifier']),
tags: JSON.stringify(['modifiers', 'immutability', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
}
];
// SQL Questions (10 questions)
const sqlQuestions = [
{
id: uuidv4(),
category_id: categoryMap['sql-databases'],
question_text: 'What is the difference between INNER JOIN and LEFT JOIN?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'INNER returns only matching rows, LEFT returns all left table rows' },
{ id: 'b', text: 'They are exactly the same' },
{ id: 'c', text: 'LEFT JOIN is faster' },
{ id: 'd', text: 'INNER JOIN includes NULL values' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'INNER JOIN returns only rows with matches in both tables. LEFT JOIN returns all rows from the left table, with NULLs for non-matching right table rows.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['join', 'inner', 'left', 'sql']),
tags: JSON.stringify(['joins', 'queries', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['sql-databases'],
question_text: 'What is database normalization?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Organizing data to reduce redundancy and improve integrity' },
{ id: 'b', text: 'Making all values lowercase' },
{ id: 'c', text: 'Optimizing query performance' },
{ id: 'd', text: 'Backing up the database' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Normalization is the process of organizing database structure to reduce redundancy and dependency by dividing large tables into smaller ones.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['normalization', 'database design', 'redundancy']),
tags: JSON.stringify(['design', 'normalization', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['sql-databases'],
question_text: 'What is an index in a database?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A data structure that improves query speed at the cost of write speed' },
{ id: 'b', text: 'A primary key' },
{ id: 'c', text: 'A backup of the table' },
{ id: 'd', text: 'A foreign key relationship' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'An index is a data structure (typically B-tree) that speeds up data retrieval operations but requires additional space and slows down writes.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['index', 'performance', 'query optimization']),
tags: JSON.stringify(['indexes', 'performance', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['sql-databases'],
question_text: 'What is a transaction in SQL?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'A sequence of operations performed as a single unit of work (ACID)' },
{ id: 'b', text: 'A single SQL query' },
{ id: 'c', text: 'A database backup' },
{ id: 'd', text: 'A table relationship' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'A transaction is a logical unit of work that follows ACID properties (Atomicity, Consistency, Isolation, Durability) to maintain data integrity.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['transaction', 'acid', 'commit', 'rollback']),
tags: JSON.stringify(['transactions', 'acid', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['sql-databases'],
question_text: 'What does the GROUP BY clause do in SQL?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Groups rows with same values for aggregate functions' },
{ id: 'b', text: 'Sorts the result set' },
{ id: 'c', text: 'Filters rows before grouping' },
{ id: 'd', text: 'Joins tables together' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'GROUP BY groups rows that have the same values in specified columns, often used with aggregate functions like COUNT, SUM, AVG.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['group by', 'aggregate', 'sql']),
tags: JSON.stringify(['grouping', 'aggregates', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
}
];
// System Design Questions (10 questions)
const systemDesignQuestions = [
{
id: uuidv4(),
category_id: categoryMap['system-design'],
question_text: 'What is horizontal scaling vs vertical scaling?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Horizontal adds more machines, vertical increases single machine resources' },
{ id: 'b', text: 'Vertical adds more machines, horizontal increases resources' },
{ id: 'c', text: 'They are the same' },
{ id: 'd', text: 'Horizontal is always better' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Horizontal scaling (scale out) adds more machines to the pool. Vertical scaling (scale up) adds more resources (CPU, RAM) to a single machine.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['scaling', 'horizontal', 'vertical', 'architecture']),
tags: JSON.stringify(['scaling', 'architecture', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['system-design'],
question_text: 'What is a load balancer?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Distributes incoming traffic across multiple servers' },
{ id: 'b', text: 'Stores user sessions' },
{ id: 'c', text: 'Caches database queries' },
{ id: 'd', text: 'Monitors system performance' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'A load balancer distributes network traffic across multiple servers to ensure no single server is overwhelmed, improving reliability and performance.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['load balancer', 'distribution', 'scaling']),
tags: JSON.stringify(['load-balancing', 'architecture', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['system-design'],
question_text: 'What is CAP theorem?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'You can only achieve 2 of 3: Consistency, Availability, Partition tolerance' },
{ id: 'b', text: 'All three can be achieved simultaneously' },
{ id: 'c', text: 'A caching strategy' },
{ id: 'd', text: 'A security principle' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'CAP theorem states that a distributed system can only guarantee two of three properties: Consistency, Availability, and Partition tolerance.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['cap', 'theorem', 'distributed systems']),
tags: JSON.stringify(['distributed-systems', 'theory', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['system-design'],
question_text: 'What is caching and why is it used?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Storing frequently accessed data in fast storage to reduce latency' },
{ id: 'b', text: 'Backing up data' },
{ id: 'c', text: 'Encrypting sensitive data' },
{ id: 'd', text: 'Compressing files' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Caching stores frequently accessed data in fast storage (memory) to reduce database load and improve response times.',
difficulty: 'easy',
points: 5,
time_limit: 60,
keywords: JSON.stringify(['cache', 'performance', 'latency']),
tags: JSON.stringify(['caching', 'performance', 'fundamentals']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
},
{
id: uuidv4(),
category_id: categoryMap['system-design'],
question_text: 'What is a microservices architecture?',
question_type: 'multiple',
options: JSON.stringify([
{ id: 'a', text: 'Application composed of small, independent services communicating via APIs' },
{ id: 'b', text: 'A very small application' },
{ id: 'c', text: 'A caching strategy' },
{ id: 'd', text: 'A database design pattern' }
]),
correct_answer: JSON.stringify(['a']),
explanation: 'Microservices architecture structures an application as a collection of loosely coupled, independently deployable services.',
difficulty: 'medium',
points: 10,
time_limit: 90,
keywords: JSON.stringify(['microservices', 'architecture', 'distributed']),
tags: JSON.stringify(['microservices', 'architecture', 'patterns']),
is_active: true,
times_attempted: 0,
times_correct: 0,
created_by: adminId,
created_at: new Date(),
updated_at: new Date()
}
];
// Combine all questions
questions.push(
...jsQuestions,
...angularQuestions,
...reactQuestions,
...nodejsQuestions,
...tsQuestions,
...sqlQuestions,
...systemDesignQuestions
);
await queryInterface.bulkInsert('questions', questions, {});
console.log(`✅ Seeded ${questions.length} demo questions across all categories`);
},
async down(queryInterface, Sequelize) {
await queryInterface.bulkDelete('questions', null, {});
console.log('✅ Removed demo questions');
}
};