feat: 更新考试相关页面,添加刷新功能,修改考试状态显示
- 注:当前代码还存在bug:查看结果暂出现错误。 - 在 SubjectSelectionPage 页面中添加刷新按钮,允许用户手动刷新考试任务列表。 - 修改 UserTaskPage 页面,重构考试任务为答题记录,更新数据结构和状态显示。 - 在 AdminDashboardPage、UserManagePage、UserRecordsPage 等管理页面中添加考试状态显示,使用不同颜色区分状态(不及格、合格、优秀)。 - 在 ResultPage 中显示考试状态,确保用户能够清晰了解考试结果。 - 添加约束,确保单次考试试卷中题目不可重复出现,并记录相关规范。 - 添加评分状态约束,根据得分占比自动计算考试状态,并在结果页面显示。
This commit is contained in:
@@ -83,7 +83,10 @@ const columnExists = async (tableName: string, columnName: string): Promise<bool
|
||||
|
||||
const ensureColumn = async (tableName: string, columnDefSql: string, columnName: string) => {
|
||||
if (!(await columnExists(tableName, columnName))) {
|
||||
console.log(`添加列 ${tableName}.${columnName}`);
|
||||
await exec(`ALTER TABLE ${tableName} ADD COLUMN ${columnDefSql}`);
|
||||
} else {
|
||||
console.log(`列 ${tableName}.${columnName} 已存在`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,6 +122,8 @@ export const initDatabase = async () => {
|
||||
} else {
|
||||
console.log('数据库表已存在,跳过初始化');
|
||||
await ensureColumn('questions', "analysis TEXT NOT NULL DEFAULT ''", 'analysis');
|
||||
await ensureColumn('quiz_records', "score_percentage REAL", 'score_percentage');
|
||||
await ensureColumn('quiz_records', "status TEXT", 'status');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('数据库初始化失败:', error);
|
||||
|
||||
@@ -87,6 +87,8 @@ CREATE TABLE quiz_records (
|
||||
total_score INTEGER NOT NULL,
|
||||
correct_count INTEGER NOT NULL,
|
||||
total_count INTEGER NOT NULL,
|
||||
score_percentage REAL,
|
||||
status TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id),
|
||||
FOREIGN KEY (subject_id) REFERENCES exam_subjects(id),
|
||||
|
||||
Reference in New Issue
Block a user