feat: implement QuestionBank CRUD with pagination and template query
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
-- Migration: Create Question Banks Tables
|
||||
-- Run this SQL to create the question_banks and question_bank_items tables
|
||||
|
||||
-- Create QuestionBanks table
|
||||
CREATE TABLE IF NOT EXISTS question_banks (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
tenant_id VARCHAR(255),
|
||||
template_id UUID,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
status VARCHAR(50) DEFAULT 'DRAFT',
|
||||
created_by VARCHAR(255),
|
||||
reviewed_by VARCHAR(255),
|
||||
reviewed_at TIMESTAMP,
|
||||
review_comment TEXT,
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_at TIMESTAMP DEFAULT NOW(),
|
||||
CONSTRAINT fk_template FOREIGN KEY (template_id) REFERENCES assessment_templates(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
-- Create QuestionBankItems table
|
||||
CREATE TABLE IF NOT EXISTS question_bank_items (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
bank_id UUID NOT NULL,
|
||||
question_text TEXT NOT NULL,
|
||||
question_type VARCHAR(50) DEFAULT 'SHORT_ANSWER',
|
||||
options JSONB,
|
||||
correct_answer TEXT,
|
||||
key_points JSONB NOT NULL,
|
||||
difficulty VARCHAR(50) DEFAULT 'STANDARD',
|
||||
dimension VARCHAR(50) DEFAULT 'PROMPT',
|
||||
basis TEXT,
|
||||
created_by VARCHAR(255),
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_at TIMESTAMP DEFAULT NOW(),
|
||||
CONSTRAINT fk_bank FOREIGN KEY (bank_id) REFERENCES question_banks(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Create indexes for performance
|
||||
CREATE INDEX IF NOT EXISTS idx_question_banks_tenant_id ON question_banks(tenant_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_question_banks_status ON question_banks(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_question_banks_created_by ON question_banks(created_by);
|
||||
CREATE INDEX IF NOT EXISTS idx_question_bank_items_bank_id ON question_bank_items(bank_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_question_bank_items_difficulty ON question_bank_items(difficulty);
|
||||
CREATE INDEX IF NOT EXISTS idx_question_bank_items_dimension ON question_bank_items(dimension);
|
||||
Reference in New Issue
Block a user