修复数据库连接错误,用户组功能待测试

This commit is contained in:
2025-12-21 01:56:54 +08:00
parent 41f7474f2b
commit b5262fc13a
15 changed files with 162 additions and 198 deletions

View File

@@ -1,5 +1,6 @@
import { Request, Response } from 'express';
import { QuestionModel, QuizModel, SystemConfigModel } from '../models';
import { Question } from '../models/question';
export class QuizController {
static async generateQuiz(req: Request, res: Response) {
@@ -122,8 +123,8 @@ export class QuizController {
let totalScore = questions.reduce((sum, q) => sum + q.score, 0);
while (totalScore < subject.totalScore) {
// 获取所有类型的随机题目
const allTypes = Object.keys(subject.typeRatios).filter(type => subject.typeRatios[type] > 0);
if (allTypes.length === 0) break;
const allTypes = Object.keys(subject.typeRatios).filter(type => subject.typeRatios[type as keyof typeof subject.typeRatios] > 0);
if (allTypes.length === 0) break;
const randomType = allTypes[Math.floor(Math.random() * allTypes.length)];
const availableQuestions = await QuestionModel.getRandomQuestions(