fix: restore main runtime sources and cache consistency

This commit is contained in:
User
2026-07-14 14:19:36 +08:00
parent e40989eeab
commit f951bc6598
15 changed files with 1664 additions and 29 deletions

View File

@@ -170,8 +170,9 @@ class ExamLocalDB:
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''', (exam_id, name, description, total_score, len(questions), duration, 'published', created_by))
# 关联题目
for order, qid in enumerate(question_ids):
# 关联实际存在的题目,避免无效 ID 触发外键约束。
valid_question_ids = [q['id'] for q in questions]
for order, qid in enumerate(valid_question_ids):
cursor.execute('''
INSERT INTO exam_questions (exam_id, question_id, question_order)
VALUES (?, ?, ?)
@@ -183,7 +184,7 @@ class ExamLocalDB:
'total_score': total_score,
'total_count': len(questions),
'duration': duration,
'question_ids': question_ids
'question_ids': valid_question_ids
}
def get_exam(self, exam_id: str) -> Optional[Dict]: