训练游戏记录管理

训练游戏记录列表: /trainGameRecords GET

请求参数

参数名 示列值 类型 必须 说明 默认值
page 1 number 否 当前页数 1
pageSize 10 number 否 每页条数 10
sort -createdAt string 否 排序。多个排序字段用,号隔开。sort=-a,b
expand 'member.organizationMember' string 否 获取指定子资源数据: 'member,trainGame,trainGameLevelRecords'
attributes ["id", "name"] array 否 本资源的字段。不定义该字段时返回所有字段;空数组不返回字段
memberId 1 number 否 患者id
trainGameId 1 number 否 训练内容id
status 1 number 否 状态:(0:未开始,1:进行中,2:已完成)

返回参数

参数名 示列值 说明
page 1 当前页数
pageSize 10 每页条数
limit 10 同 pageSize
offset 2 起始条数
total 3231 符合条件的总数量
items [{},{}] 返回数据项(具体字段看游戏记录信息)
参数名 示列值 说明
id 1 id
organizationId 1 机构id
trainGameId 1 训练内容id
memberId 5 患者id
status 1 状态:(0:未开始,1:进行中,2:已完成)
startedAt 1650160322 开始时间
endedAt 1650160322 结束时间
score 98 得分
accuracy 95.5 正确率(%)
actualDuration 300 实际训练时长(秒)
curLevel 3 当前关卡
createdAt 1650160322 创建时间
updatedAt 1650160322 更新时间
member {} 扩展字段:患者信息(支持链式 member.organizationMember)
trainGame {} 扩展字段:训练内容信息
trainGameLevelRecords [{},{}] 扩展字段:关卡记录列表

返回示列

HTTP/1.1 200 OK
{
    "items": [
    {
      "id": 1,
      "trainGameId": 1,
      "memberId": 5,
      "status": 2,
      "startedAt": 1650160322,
      "endedAt": 1650160322,
      "score": 98,
      "accuracy": 95.5,
      "member": { "id": 5, "name": "张三" },
      "createdAt": 1650160322,
      "updatedAt": 1650160322,
    },
  ],
  "page": 1,
  "pageSize": 10,
  "limit": 10,
  "offset": 2,
  "total": 15
}

所有游戏记录: /listAll/trainGameRecords GET

请求参数

参数名 示列值 类型 必须 说明
expand 'member' string 否 获取指定子资源数据: 'member,trainGame,trainGameLevelRecords'
attributes ["id", "name"] array 否 本资源的字段。不定义该字段时返回所有字段
memberId 1 number 否 患者id
trainGameId 1 number 否 训练内容id
status 1 number 否 状态

返回示列

HTTP/1.1 200 OK
[
  { "id": 1, "trainGameId": 1, "memberId": 5, "status": 2 }
]

游戏高分榜: /leaderboard/trainGameRecords GET

按训练内容分组,统计各游戏得分前三名。同一患者只取其在对应游戏中的最高分参与排名。

请求参数

参数名 示列值 类型 必须 说明 默认值
organizationId 1 number 是 组织id
memberId 1 number 否 当前患者id
trainGameCategoryId 1 number 否 训练内容分类id, 只显示某分类下的游戏
limit 3 number 否 每个游戏取前几名 3

返回结果

参数名 示列值 说明
items [] 榜单列表, 按训练内容分组

items 内每个分组结构:

字段 示列值 说明
trainGame {} 训练内容信息(含 trainGameCategory 分类信息)
records [] 该游戏得分排名记录, 按 rank 升序

records 内每条记录结构:

参数名 示列值 说明
rank 1 排名
memberId 5 患者id
memberName 张** 患者姓名(已脱敏)
score 98 得分
trainedAt 1650160322 训练时间
tag 项目第一 榜单标签: 满分记录/项目第一/个人最佳/优秀选手
isCurrentMember true/false 是否为当前登录用户

返回示列

HTTP/1.1 200 OK
{
  "items": [
    {
      "trainGame": {
        "id": 1,
        "name": "记忆卡牌",
        "trainCode": "memory-card",
        "trainGameCategory": { "id": 1, "name": "学习与记忆" }
      },
      "records": [
        { "rank": 1, "memberId": 5, "memberName": "王**", "score": 98, "trainedAt": 1650160322, "tag": "项目第一", "isCurrentMember": false },
        { "rank": 2, "memberId": 6, "memberName": "李**", "score": 92, "trainedAt": 1650158400, "tag": "个人最佳", "isCurrentMember": true }
      ]
    }
  ]
}

游戏记录详情: /trainGameRecords/:id GET

请求参数

参数名 示列值 类型 必须 说明
id 1 number 是 id
expand 'member' string 否 获取指定子资源数据: 'member,trainGame,trainGameLevelRecords'
attributes ["id", "name"] array 否 本资源的字段。不定义该字段时返回所有字段

返回结果: 游戏记录信息

返回示列

HTTP/1.1 200 OK
{
  "id": 1,
  "trainGameId": 1,
  "memberId": 5,
  "status": 2,
  "score": 98,
  "startedAt": 1650160322,
  "endedAt": 1650160322,
}

统计系统平均得分和正确率: stat/trainGameRecords POST

请求参数

参数名 示列值 类型 必须 说明
trainGameId 1 number 否 训练内容 id(可选, 不传则统计全部训练内容)
memberId 10 number 否 患者 id(可选, 不传则统计全部患者)

返回示列

HTTP/1.1 200 OK
{
  "avgScore": 85.5,
  "avgAccuracy": 92.3,
  "count": 120
}
  • avgScore: 平均得分
  • avgAccuracy: 平均正确率(百分比, 对应记录的 accuracy 字段)
  • count: 参与统计的记录数