修正正常模式无法返回系统题库的bug
This commit is contained in:
parent
146704e11d
commit
6359a43f90
@ -48,7 +48,7 @@ class ExamController extends BaseController {
|
|||||||
let questions = await Puzzle.randomQuestions(params, record.qcount)
|
let questions = await Puzzle.randomQuestions(params, record.qcount)
|
||||||
results = transformRecord(questions)
|
results = transformRecord(questions)
|
||||||
for (let _r of questions) {
|
for (let _r of questions) {
|
||||||
history.questions.set(_r.id, _r.a1)
|
history.questions.set(_r.id, _r.compactRecord(true))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
results = record.transQuestion()
|
results = record.transQuestion()
|
||||||
|
@ -113,10 +113,17 @@ export class PuzzleClass extends BaseModule {
|
|||||||
public static async randomQuestions(this: ReturnModelType<typeof PuzzleClass>, options: any, count: number) {
|
public static async randomQuestions(this: ReturnModelType<typeof PuzzleClass>, options: any, count: number) {
|
||||||
let filters = {status: 1, is_hide: 0, deleted: 0, dp: 1}
|
let filters = {status: 1, is_hide: 0, deleted: 0, dp: 1}
|
||||||
Object.assign(filters, options)
|
Object.assign(filters, options)
|
||||||
return Puzzle.aggregate([
|
let records = await Puzzle.aggregate([
|
||||||
{ $match: filters },
|
{ $match: filters },
|
||||||
{ $sample: { size: count } }
|
{ $sample: { size: count } }
|
||||||
]).exec()
|
]).exec()
|
||||||
|
let results = []
|
||||||
|
for (let record of records) {
|
||||||
|
let o = new Puzzle({})
|
||||||
|
Object.assign(o, record)
|
||||||
|
results.push(o)
|
||||||
|
}
|
||||||
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
public compactRecord(withAnswer: boolean) {
|
public compactRecord(withAnswer: boolean) {
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
updateRound,
|
updateRound,
|
||||||
updateScore
|
updateScore
|
||||||
} from './WsSvr'
|
} from './WsSvr'
|
||||||
import { Puzzle } from '../models/content/Puzzle'
|
import { Puzzle, PuzzleClass } from '../models/content/Puzzle'
|
||||||
import { Schedule } from '../clock/Schedule'
|
import { Schedule } from '../clock/Schedule'
|
||||||
import { BaseConst } from '../constants/BaseConst'
|
import { BaseConst } from '../constants/BaseConst'
|
||||||
import { PuzzleSession } from '../models/match/PuzzleSession'
|
import { PuzzleSession } from '../models/match/PuzzleSession'
|
||||||
@ -22,7 +22,7 @@ import { GameUser } from '../models/GameUser'
|
|||||||
|
|
||||||
export function transformRecord(records: any[]) {
|
export function transformRecord(records: any[]) {
|
||||||
return records.map(o => {
|
return records.map(o => {
|
||||||
return o.compactRecord(false)
|
return (o as PuzzleClass).compactRecord(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user