修复数据库连接错误,用户组功能待测试
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user