From ec17dbd5637afe55eca3596883e188b85c4d90a2 Mon Sep 17 00:00:00 2001 From: zhl Date: Mon, 24 May 2021 11:22:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=91=E6=88=98=E6=A8=A1=E5=BC=8F=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=AF=8F=E9=A2=98=E9=97=B4=E9=9A=94=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/api.md | 1 + src/api/controllers/exam.controller.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/api.md b/doc/api.md index 53e97a8..23cca3a 100644 --- a/doc/api.md +++ b/doc/api.md @@ -220,6 +220,7 @@ | -------- | -------------------------------------- | | shop | 店铺id, 比如 607ff59d4a4e16687a3b7079 | | eid | 测验id, 比如 609e13eeccc78154ac683583 | +| delay | 每题需要增加的延迟时间, 单位秒 | 3. Response: JSON diff --git a/src/api/controllers/exam.controller.ts b/src/api/controllers/exam.controller.ts index 0416eea..111ca6e 100644 --- a/src/api/controllers/exam.controller.ts +++ b/src/api/controllers/exam.controller.ts @@ -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()