修改測驗時間、新增測驗提醒、新增截止測驗功能

This commit is contained in:
2025-10-12 00:18:24 +08:00
parent 967541a492
commit cf40e937a1
7 changed files with 176 additions and 19 deletions

View File

@@ -13,6 +13,7 @@ export interface CombinedTestResult {
creativity_breakdown: any | null // JSON 格式
balance_score: number
completed_at: string
is_timeout: boolean
created_at?: string
}
@@ -27,6 +28,7 @@ export interface CreateCombinedTestResultData {
creativity_breakdown: any | null
balance_score: number
completed_at: string
is_timeout: boolean
}
// 建立綜合測試結果表(如果不存在)
@@ -44,6 +46,7 @@ export async function createCombinedTestResultsTable(): Promise<void> {
creativity_breakdown JSON NULL,
balance_score INT NOT NULL,
completed_at TIMESTAMP NOT NULL,
is_timeout BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_user_id (user_id),
INDEX idx_completed_at (completed_at)
@@ -62,8 +65,8 @@ export async function createCombinedTestResult(resultData: CreateCombinedTestRes
INSERT INTO combined_test_results (
id, user_id, logic_score, creativity_score, overall_score,
level, description, logic_breakdown, creativity_breakdown,
balance_score, completed_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
balance_score, completed_at, is_timeout
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`
const values = [
@@ -77,7 +80,8 @@ export async function createCombinedTestResult(resultData: CreateCombinedTestRes
resultData.logic_breakdown ? JSON.stringify(resultData.logic_breakdown) : null,
resultData.creativity_breakdown ? JSON.stringify(resultData.creativity_breakdown) : null,
resultData.balance_score,
resultData.completed_at
resultData.completed_at,
resultData.is_timeout
]
try {

View File

@@ -8,6 +8,7 @@ export interface TestResult {
total_questions: number
correct_answers: number
completed_at: string
is_timeout: boolean
created_at?: string
}
@@ -18,6 +19,7 @@ export interface CreateTestResultData {
total_questions: number
correct_answers: number
completed_at: string
is_timeout: boolean
}
// 建立測試結果表(如果不存在)
@@ -31,6 +33,7 @@ export async function createTestResultsTable(): Promise<void> {
total_questions INT NOT NULL,
correct_answers INT NOT NULL,
completed_at TIMESTAMP NOT NULL,
is_timeout BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_user_id (user_id),
INDEX idx_test_type (test_type),
@@ -50,8 +53,8 @@ export async function createTestResult(resultData: CreateTestResultData): Promis
const insertQuery = `
INSERT INTO test_results (
id, user_id, test_type, score, total_questions,
correct_answers, completed_at
) VALUES (?, ?, ?, ?, ?, ?, ?)
correct_answers, completed_at, is_timeout
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`
await executeQuery(insertQuery, [
@@ -61,7 +64,8 @@ export async function createTestResult(resultData: CreateTestResultData): Promis
resultData.score,
resultData.total_questions,
resultData.correct_answers,
resultData.completed_at
resultData.completed_at,
resultData.is_timeout
])
const result = await getTestResultById(id)