接口文档
登录
/api/phone/login [POST]
用于手机端用户登录
请求参数
参数 | 描述 | 约束 |
---|---|---|
username | 用户名 | 手机或邮箱 |
password | 密码 | 最少六位 |
请求示例
{ "username" : 16041747873, "password" : 123456 }
响应参数
参数 | 描述 |
---|---|
data.token | 前后台沟通的密钥,放在header里面,使用“phone-token”命名 |
响应示例
{
"data": {
"token": "ChiiaUfU6rtFvbqr94QPXKlW26spxTKFQCNjBOcN9pKQVWmwFlVjJ9L6edajuVyzB2NzCesx3UDGGagT1QtxKNirJMi2cquVbnap"
}
}
用户信息
/api/phone/user [GET]
用户获取用户信息
请求参数
在header头里面添加登录获得的Token,键名为 phone-token
请求示例
Request Headers:
{ "phone-token" : 123123123123123123 }
响应参数
参数 | 描述 |
---|---|
data.id | 用户id |
data.name | 用户姓名 |
data.email | 用户邮箱 |
data.phone | 用户手机 |
data.is_admin | 是否为管理员 |
data.is_active | 是否为激活状态 |
data.created_at | 注册时间 |
data.updated_at | 更新时间 |
data.group.id | 用户所属群组(班级)ID |
data.group.name | 用户群组(班级)名称 |
data.group.creator | 该条记录的创建人ID |
data.group.created_at | 创建时间 |
data.group.updated_at | 更新时间 |
响应示例
{
"data": {
"id": 1,
"name": "张三",
"email": "mstoltenberg@example.org",
"phone": "17507972735",
"is_admin": 1,
"is_active": 0,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-28 17:09:14",
"group": [
{
"id": 18,
"name": "Ena Bradtke",
"creator": 13,
"deleted_at": null,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-27 20:39:17",
"pivot": {
"user_id": 1,
"group_id": 18
}
}
]
}
}
获取学员所在群组的考试列表
/api/phone/exam [POST]
用于手机端用户登录
请求参数
必须在headers里面加上phone-token
参数 | 描述 |
---|---|
group_id | 群组ID |
请求示例
/api/phone/exam?group_id=18
响应参数
参数 | 描述 |
---|---|
data.*.id | 考试ID |
data.*.name | 考试名称 |
data.*.started_at | 考试开始时间 |
data.*.stopped_at | 考试结束时间 |
data.*.group_id | 考试指定群组 |
data.*.paper_id | 考试试卷 |
data.*.status | 考试状态 |
data.*.creator | 考试创建人 |
data.*.created_at | 考试开始时间 |
data.*.updated_at | 考试更新时间 |
data.*.paper.id | 考试试卷ID |
data.*.paper.name | 考试试卷名称 |
响应示例
{
"data": [
{
"id": 9,
"name": "Dr. Jewel Rice",
"started_at": "2017-11-05 20:09:46",
"stopped_at": "2017-10-30 07:34:02",
"group_id": 18,
"paper_id": 3,
"status": 1,
"creator": 14,
"deleted_at": null,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-27 20:39:17",
"paper": {
"id": 3,
"name": "Dr. Darrell Schinner I"
}
},
{
"id": 11,
"name": "Prof. Ryley Dickens DVM",
"started_at": "2017-11-12 21:35:59",
"stopped_at": "2017-11-10 06:49:57",
"group_id": 18,
"paper_id": 20,
"status": 1,
"creator": 20,
"deleted_at": null,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-27 20:39:17",
"paper": {
"id": 20,
"name": "第一次考试"
}
}
]
}
获取考试试卷
/api/phone/paper/{id}
请求参数
id 为试卷id
请求示例
exam.app/api/phone/paper/20
响应参数
参数 | 描述 |
---|---|
data.id | 试卷ID |
data.name | 试卷名称 |
data.comment | 试卷描述 |
data.creator | 创建人 |
data.is_active | 1为正常,其余是关闭 |
data.questions | 试卷题目 |
data.questions.*.id | 题目ID |
data.questions.*.title | 题目内容 |
data.questions.*.image | 题目内容中的图片 |
data.questions.*.type | 题目类型,1单选,2多选 |
data.questions.*.star | 题目难度,12345 |
data.questions.*.comment | 题目答案解析 |
data.questions.*.options | 题目选项 |
data.questions.*.options.*.id | 选项ID |
data.questions.*.options.*.content | 选项内容 |
data.questions.*.options.*.image | 选项内容中的图片 |
data.questions.*.options.*.is_answer | 选项是否为答案,1为正确,0位错误 |
响应示例
{
"data": {
"id": 20,
"name": "第一次考试",
"comment": "哈哈哈",
"creator": 18,
"is_active": 1,
"deleted_at": null,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-28 21:20:47",
"questions": [
{
"id": 20,
"title": "Nemo dolorum mollitia quidem libero. Nihil recusandae aut voluptas quod. Qui odio aspernatur aut amet sequi.",
"type": 1,
"comment": null,
"star": 3,
"creator": 18,
"image": "http://ofa50j8as.bkt.clouddn.com/201712181744032629",
"options": [
{
"id": 1,
"content": "Occaecati alias aliquid harum eos omnis voluptatum. Ab maiores et expedita cupiditate quod dolorum numquam.",
"is_answer": 0,
"image": "http://ofa50j8as.bkt.clouddn.com/201712181744032629"
},
{
"id": 2,
"content": "Hic velit aut deleniti.",
"is_answer": 0,
"image": "http://ofa50j8as.bkt.clouddn.com/201712181744032629"
},
{
"id": 3,
"content": "Et sint mollitia et exercitationem possimus ullam. Repudiandae reiciendis facere enim blanditiis esse nesciunt.",
"is_answer": 0,
"image": "http://ofa50j8as.bkt.clouddn.com/201712181744032629"
},
{
"id": 4,
"content": "Eos laudantium occaecati aperiam.",
"is_answer": 1,
"image": "http://ofa50j8as.bkt.clouddn.com/201712181744032629"
}
],
"is_active": 1,
"deleted_at": null,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-27 20:39:17",
"pivot": {
"paper_id": 20,
"question_id": 20,
"score": 5
}
},
{
"id": 19,
"title": "Eos quia expedita fugiat. Explicabo rerum repudiandae et ipsa et.",
"type": 1,
"comment": null,
"star": 3,
"creator": 9,
"image": null,
"options": [
{
"id": 1,
"content": "Autem et id qui facere voluptate non qui.",
"is_answer": 0,
"image": null
},
{
"id": 2,
"content": "Nulla molestias molestiae quis asperiores repudiandae rem.",
"is_answer": 1,
"image": null
},
{
"id": 3,
"content": "Eaque dignissimos sit nostrum quos.",
"is_answer": 0,
"image": null
},
{
"id": 4,
"content": "A corrupti similique sit ipsam officia necessitatibus. Omnis id impedit quae sed enim illo.",
"is_answer": 0,
"image": null
}
],
"is_active": 1,
"deleted_at": null,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-27 20:39:17",
"pivot": {
"paper_id": 20,
"question_id": 19,
"score": 5
}
},
{
"id": 18,
"title": "Quia necessitatibus porro occaecati sint quia porro. Eveniet et cum inventore est. Minus est praesentium dicta corporis.",
"type": 1,
"comment": null,
"star": 2,
"creator": 19,
"image": "http://ofa50j8as.bkt.clouddn.com/201712181744032629"
"options": [
{
"id": 1,
"content": "Tempore modi qui at quas.",
"is_answer": 1,
"image": ""
},
{
"id": 2,
"content": "Et aliquam aut incidunt sit in et itaque illo.",
"is_answer": 1,
"image": ""
},
{
"id": 3,
"content": "Voluptatem unde vel nemo est distinctio vero. Occaecati corrupti pariatur hic provident rerum sed.",
"is_answer": 0,
"image": ""
},
{
"id": 4,
"content": "Non ad quam corrupti. Similique qui culpa rerum esse pariatur provident repellendus.",
"is_answer": 1,
"image": ""
}
],
"is_active": 1,
"deleted_at": null,
"created_at": "2017-11-27 20:39:17",
"updated_at": "2017-11-27 20:39:17",
"pivot": {
"paper_id": 20,
"question_id": 18,
"score": 5
}
}
}
]
}
}
提交答题
/api/phone/record
请求参数
参数 | 描述 | 约束 |
---|---|---|
user_id | 用户id | |
exam_id | 测评ID | |
answers | 答案数组 | |
answers.*.question_id | 题目ID | |
answers.*.option_id | 题目选项ID |
answers里面对象为 { 问题ID : 答案ID数组 },因为可能是多选。
请求示例
{
"user_id" : 1,
"exam_id" : 1,
"answers" : {
1 : [1,2,3,4],
2 : [2],
3 : [3,4],
4 : [4]
}
}
响应格式
响应码 201 添加成功。
正确与错误,在请求试卷时已经提供了,只需要进行逻辑判断然后展示就行了。