接口文檔
登錄
/api/phone/login [POST]
用于手機(jī)端用戶登錄
請(qǐng)求參數(shù)
參數(shù) | 描述 | 約束 |
---|---|---|
username | 用戶名 | 手機(jī)或郵箱 |
password | 密碼 | 最少六位 |
請(qǐng)求示例
{ "username" : 16041747873, "password" : 123456 }
響應(yīng)參數(shù)
參數(shù) | 描述 |
---|---|
data.token | 前后臺(tái)溝通的密鑰泉手,放在header里面,使用“phone-token”命名 |
響應(yīng)示例
{
"data": {
"token": "ChiiaUfU6rtFvbqr94QPXKlW26spxTKFQCNjBOcN9pKQVWmwFlVjJ9L6edajuVyzB2NzCesx3UDGGagT1QtxKNirJMi2cquVbnap"
}
}
用戶信息
/api/phone/user [GET]
用戶獲取用戶信息
請(qǐng)求參數(shù)
在header頭里面添加登錄獲得的Token偶器,鍵名為 phone-token
請(qǐng)求示例
Request Headers:
{ "phone-token" : 123123123123123123 }
響應(yīng)參數(shù)
參數(shù) | 描述 |
---|---|
data.id | 用戶id |
data.name | 用戶姓名 |
data.email | 用戶郵箱 |
data.phone | 用戶手機(jī) |
data.is_admin | 是否為管理員 |
data.is_active | 是否為激活狀態(tài) |
data.created_at | 注冊(cè)時(shí)間 |
data.updated_at | 更新時(shí)間 |
data.group.id | 用戶所屬群組(班級(jí))ID |
data.group.name | 用戶群組(班級(jí))名稱 |
data.group.creator | 該條記錄的創(chuàng)建人ID |
data.group.created_at | 創(chuàng)建時(shí)間 |
data.group.updated_at | 更新時(shí)間 |
響應(yīng)示例
{
"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
}
}
]
}
}
獲取學(xué)員所在群組的考試列表
/api/phone/exam [POST]
用于手機(jī)端用戶登錄
請(qǐng)求參數(shù)
必須在headers里面加上phone-token
參數(shù) | 描述 |
---|---|
group_id | 群組ID |
請(qǐng)求示例
/api/phone/exam?group_id=18
響應(yīng)參數(shù)
參數(shù) | 描述 |
---|---|
data.*.id | 考試ID |
data.*.name | 考試名稱 |
data.*.started_at | 考試開始時(shí)間 |
data.*.stopped_at | 考試結(jié)束時(shí)間 |
data.*.group_id | 考試指定群組 |
data.*.paper_id | 考試試卷 |
data.*.status | 考試狀態(tài) |
data.*.creator | 考試創(chuàng)建人 |
data.*.created_at | 考試開始時(shí)間 |
data.*.updated_at | 考試更新時(shí)間 |
data.*.paper.id | 考試試卷ID |
data.*.paper.name | 考試試卷名稱 |
響應(yīng)示例
{
"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}
請(qǐng)求參數(shù)
id 為試卷id
請(qǐng)求示例
exam.app/api/phone/paper/20
響應(yīng)參數(shù)
參數(shù) | 描述 |
---|---|
data.id | 試卷ID |
data.name | 試卷名稱 |
data.comment | 試卷描述 |
data.creator | 創(chuàng)建人 |
data.is_active | 1為正常斩萌,其余是關(guān)閉 |
data.questions | 試卷題目 |
data.questions.*.id | 題目ID |
data.questions.*.title | 題目?jī)?nèi)容 |
data.questions.*.image | 題目?jī)?nèi)容中的圖片 |
data.questions.*.type | 題目類型,1單選屏轰,2多選 |
data.questions.*.star | 題目難度颊郎,12345 |
data.questions.*.comment | 題目答案解析 |
data.questions.*.options | 題目選項(xiàng) |
data.questions.*.options.*.id | 選項(xiàng)ID |
data.questions.*.options.*.content | 選項(xiàng)內(nèi)容 |
data.questions.*.options.*.image | 選項(xiàng)內(nèi)容中的圖片 |
data.questions.*.options.*.is_answer | 選項(xiàng)是否為答案,1為正確霎苗,0位錯(cuò)誤 |
響應(yīng)示例
{
"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
請(qǐng)求參數(shù)
參數(shù) | 描述 | 約束 |
---|---|---|
user_id | 用戶id | |
exam_id | 測(cè)評(píng)ID | |
answers | 答案數(shù)組 | |
answers.*.question_id | 題目ID | |
answers.*.option_id | 題目選項(xiàng)ID |
answers里面對(duì)象為 { 問題ID : 答案ID數(shù)組 }姆吭,因?yàn)榭赡苁嵌噙x。
請(qǐng)求示例
{
"user_id" : 1,
"exam_id" : 1,
"answers" : {
1 : [1,2,3,4],
2 : [2],
3 : [3,4],
4 : [4]
}
}
響應(yīng)格式
響應(yīng)碼 201 添加成功唁盏。
正確與錯(cuò)誤内狸,在請(qǐng)求試卷時(shí)已經(jīng)提供了,只需要進(jìn)行邏輯判斷然后展示就行了厘擂。