目录
前言
网络投票、直播互动问卷,教学场景的试卷。类型基本相同,汇集或抽象成为一个数据结构,在流程上加以一定的变化,就可以搞出多种花样。后端存储完全一样,后期可以进行一些大数据相关的分析,需要什么结果就看具体需求。本文定义的是数据结构,图片以地址作为传递内容。如果包含插图,那应该配备图片服务,或者使用网络图片也可以。
数据定义
详细定义:
{
"module": "vote",
"siteId": 1,
"roomId": "sfiu3249018",
"id": "vid122323",
"userId": "168168",
"userName": "gaogao",
"thirdaddr": "http://qa221.e.com",
"notifyResult": 0,
"total": 100,
"action": "1",
"title": "地理第一次测验",
"time": "156545669964",
"imgsrc": "https://wwww.e.com/xxx/xxx.png",
"thumbnail": "https://wwww.e.com/xxx/xxxthumbnail.png",
"questions": [
{
"id": "qid134334r",
"questionContent": "世界上最高的山峰是?",
"total": 99,
"type": "text",
"added": 1,
"score": 10,
"imgsrc": "https://wwww.e.com/xxx/xxx.png",
"thumbnail": "https://wwww.e.com/xxx/xxxthumbnail.png",
"answers": [
{
"userId": "273821423",
"userName": "gaogao",
"imgsrc": "https://wwww.ee.com/xxx/xxx.png",
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"text": "文字回复内容"
}
],
"options": [
{
"id": "optid4134418",
"text": "选项文字内容",
"correct": true,
"userCount": 80,
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"imgsrc": "https://wwww.ee.com/xxx/xxx.png"
}
],
"selectItems": [
{
"index": 0,
"id": "optid4134418"
}
]
}
]
}
数据说明
1、第一层{}
“module”: “vote”, //功能名称,终端、后端区分功能数据的依据。Vote主、客观题
“siteId”: 1, //站点id
“roomId”: “sfiu3249018”, //课堂id
“id”: “vid122323”, //vote id
“servicetype”: “1”, //webcast 0 , training 1
“dst”: “all”, //broadsvr广播的范围,终端确定 all/rt/web
“userId”: 168168, //当前发送者id(发布对应发布者id,答题对应答题者id)
“userName”: “gaogao”, //当前发送者昵称(同id)
“total”: 100, //参与人数(回答人数)
“action”: “1”, //操作(发题1、答题2、停止答题3、发布结果4、导出5)
“notifyResult”: “1” //不入库,仅作结果通知标识
“thirdaddr”:推给第三方,可以是静态服务或实时转发的第三方
“title”: “地理第一次测验”, //总题干
“time”: “155956465656”, //发布时间,基于1970的毫秒数
“imgsrc”: “https://wwww.ee.com/xxx/xxx.png”, //原图url
“thumbnail”: “https://wwww.ee.com/xxx/xxxthumbnail.png”, //缩略图url
“questions”:[] //vote的题目列表,
2、question 一个题目{}
“id”: “qid134334r”, //题目id
“questionContent”: “世界上最高的山峰是?”, //题目内容
“total”: 99, //参与人数
“type”: “1”, //题目类型: 1、主观题,2、单选题,3、多选题
“score”: 10, //分数
“added”: 0, //附加题 1 ,必答题0。都不是附加题则vote为”强制”答题
“imgsrc”: “https://wwww.ee.com/xxx/xxx.png”,//题干原图
“thumbnail”: “https://wwww.ee.com/xxx/xxxthumbnail.png”,//题干缩略图
“answers”: [] //回答列表,导出、主观题答题时使用
“options”: [] //选择题选项列表
“selectItems”: []//选择题选项的选择结果列表,选择题答题时使用
3、answer一个答题回复{}
“userId”: 273821423, //答题者id
“userName”: “gaogao”,//答题者名称
“imgsrc”: “https://wwww.ee.com/xxx/xxx.png”, //原图
“thumbnail”: “https://wwww.ee.com/xxx/xxxthumbnail.png”, //缩略图
“text”: “文字回复内容”
4、option 一个选项{}
“id”: “optid4134418”, //选项id
“text”: “选项文字内容”,
“correct”: true, //true 正确选项
“userCount”: 80, //选择人数 ,发布结果使用
“thumbnail”: “https://wwww.ee.com/xxx/xxxthumbnail.png”, //缩略图
“imgsrc”: “https://wwww.ee.com/xxx/xxx.png” //原图
5、selectItems {}
“index”: 0, 选中选项下标
“id”: “optid4134418” 选择选项id
具体数据
1、发题(终端请求)示例
{
"module": "vote",
"siteId": 1,
"servicetype": "1",
"dst": "all",
"roomId": "sfiu3249018",
"id": "vid122323",
"userId": "发题者id",
"userName": "发题者名称",
"action": "1",
"thirdaddr": "http://qa221.e.com",
"title": "地理第一次测验",
"time": "15648565656565",
"questions": [
{
"id": "qid134334r",
"questionContent": "世界上最高的山峰是?",
"type": "1",
"added": 1,
"score": 10,
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"imgsrc": "https://wwww.see.com/xxx/xxx.png"
},
{
"id": "qid134334s",
"questionContent": "世界上最高的山峰是?",
"type": "2",
"added": 1,
"score": 10,
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"imgsrc": "https://wwww.see.com/xxx/xxx.png"
"options": [
{
"id": "optid4134418",
"text": "选项文字内容",
"correct": true,
"userCount": 80,
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"imgsrc": "https://wwww.see.com/xxx/xxx.png"
}
]
},
{
"id": "qid134334t",
"questionContent": "世界上最高的山峰是?",
"type": "3",
"added": 1,
"score": 10,
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"imgsrc": "https://wwww.see.com/xxx/xxx.png"
"options": [
{
"id": "optid4134419",
"text": "选项文字内容",
"correct": true,
"userCount": 80,
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"imgsrc": "https://wwww.ee.com/xxx/xxx.png"
}
]
}
]
}
“action”: “1”, 发布一个w问卷
questions 数组容量3,每种题型都对应的给出示例
“type”: “1”, // 1-主观题
客户端请求,返回相关响应码,后端存档,userid和username保持为发布者的信息,同时向第三方转发一份内容。
2、答题(图片答题,终端请求)互动或静态
{
"module": "vote",
"siteId": 1,
"servicetype": "1",
"dst": "all",
"roomId": "sfiu3249018",
"id": "vid122323",
"userId": "答题者id" ,
"userName": "答题者昵称",
"action": "2",
"notifyResult": "1",
"thirdaddr": "http://qa221.see.com",
"questions": [
{
"id": "qid134334r",
"type": "1",
"answers": [
{
"imgsrc": "https://wwww.see.com/xxx/xxx.png",
"thumbnail": "https://wwww.see.com/xxx/xxxthumbnail.png",
}
]
}
{
"id": "qid134334s",
"type": "2",
"selectItems": [
{
"index": 0,
"id": "optid4134418"
}
]
}
{
"id": "qid134334t",
"type": "3",
"selectItems": [
{
"index": 0,
"id": "optid4134419"
}
]
}
]
}
“action”: “2” 2-答题
后端更新入库,“notifyResult”: “1”, 为1的话,需向第三方发一次总结果,终端实时更新答题数据,
action值仍然为2。
3、停止答题(终端请求,一般是互动模式下有的环节)
{
"module": "vote",
"siteId": 1,
"servicetype": "1",
"dst": "all",
"roomId": "sfiu3249018",
"id": "vid122323",
"userId": 168168,
"userName": "gaogao",
"thirdaddr": "http://qa221.ee.com",
"action": "3",
"time": "15665565656"
}
后端向第三方转发一份内容,且不再处理对应vote的答题更新(存在时间差的问题),场景上可以延迟一定时间后不处理对应的答题请求。
如果没有停止答题步骤,那么发布结果也代表结束答题
4、发布结果(终端请求)互动模式
{
"module": "vote",
"siteId": 1,
"servicetype": "1",
"dst": "all",
"roomId": "sfiu3249018",
"id": "vid122323",
"userId": "168168",
"userName": "gaogao",
"action": "4",
"notifyResult": "1",
"albaddr": "http://qa221.see.com",
"title": "地理第一次测验",
"time": "156545669964"
}
后端停止处理答题请求,并将汇总结果响应给请求者,action 仍然为4。notifyResult 为1的话,结果需发送alb。notifyResult和dst由产品功能确定后终端传递。
5、答题汇总结果,互动模式或静态模式
{
"module": "vote",
"siteId": 1,
"roomId": "sfiu3249018",
"id": "vid122323",
"userId": "168168",
"userName": "gaogao",
"total": 100,
"action": "4",
"title": "地理第一次测验",
"time": "156545669964",
"questions": [
{
"id": "qid134334r",
"questionContent": "世界上最高的山峰是?",
"total": 99,
"type": "1",
"added": 1,
"score": 10,
"imgsrc": "https://wwww.ee.com/xxx/xxx.png",
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"answers": [
{
"userId": "273821423",
"userName": "gaogao",
"imgsrc": "https://wwww.ee.com/xxx/xxx.png",
"thumbnail": "https://wwww.ee.com/xxx/xxxthumbnail.png",
"text": "文字回复内容"
}
]
}
]
}
6、导出
由终端根据结果,下载对应的图片之后压缩。
或由图片服务统一压缩需要的图片:
{
“urls”:[
“https://wwww.ee.com/xxx/xxx.png”,
“https://wwww.ee.com/xxx/xxx1.png”,
“https://wwww.ee.com/xxx/xxx2.png”
]
}