挑战模式增加每题间隔时间的上报

This commit is contained in:
zhl 2021-05-24 11:22:13 +08:00
parent 16dc02e127
commit ec17dbd563
2 changed files with 5 additions and 3 deletions

View File

@ -220,6 +220,7 @@
| -------- | -------------------------------------- |
| shop | 店铺id, 比如 607ff59d4a4e16687a3b7079 |
| eid | 测验id, 比如 609e13eeccc78154ac683583 |
| delay | 每题需要增加的延迟时间, 单位秒 |
3. Response: JSON

View File

@ -20,7 +20,7 @@ class ExamController extends BaseController {
@role('anon')
@router('post /api/:accountid/exam/list')
async list(req, res) {
let { shop, accountid, eid } = req.params
let { shop, accountid, eid, delay } = req.params
if (!shop || !validShopId(shop)) {
throw new ZError(10, '没有店铺id或者店铺id格式不正确, 测试使用: 607ff59d4a4e16687a3b7079')
}
@ -60,10 +60,11 @@ class ExamController extends BaseController {
stat.timeLast = now
history.members.set(accountid, stat)
history.activityId = eid
history.expire = Date.now() + (record.qcount * record.timeone || 90) * 1000
let timeone = (record.timeone || 10) + ( delay || 0 )
history.expire = Date.now() + timeone * 1000
history.type = 2
history.total = record.qcount
history.timeone = record.timeone
history.timeone = timeone
history.difficultyMode = 0
history.qtypes = record.qtypes
await history.save()