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

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

@@ -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)