竞赛
program_girl
竞赛列表
Method and URL Structure
| Method |
Resource URL |
Authorization |
| GET |
/program_girl/contest/ |
NO |
cURL Example
curl -X GET http://localhost/program_girl/contest/
Response Data
| Name |
Description |
| pk |
id |
| title |
标题 |
| desc |
描述 |
| reward_amount |
奖金总额 |
| member_count |
参与人数 |
| finish |
是否结束 |
| has_answer |
是否参与过 |
Response
{ "count":4, "next":null, "previous":null, "results":[{ "pk":9, "title":"这是一个竞赛", "desc":"这是一个竞赛", "reward_amount":"200.00", "member_count": 3, "finish": false, "has_answer": true, },...]}
问题列表
用 contest 的 pk 获取问题
Method and URL Structure
| Method |
Resource URL |
Authorization |
| GET |
/program_girl/contest/${contest_pk}/question/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' http://localhost/program_girl/contest/1/question/
Response Data
| Name |
Description |
| url |
获取页面信息的 url |
| pk |
问题的 pk |
| title |
题干 |
| media_url |
图片或视频的 url |
| media_type |
iamge, video 类型 |
| options |
选项 |
Response
{ "count":10, "next":null, "previous":null, "results":[{ "pk":9, "title":"这是一个题目的提干", "question_type":1, "question_type_display":"单选题", "media_type":"image", "media_url":"http://example.com/2.png", "options":[{ "pk":33,"question":9, "title":"A", "content":"这是一个选项", "media_type":"image", "media_url":"http://www.example.com/1.png" },...], },...]}
答单选题
用 contest 的 pk 答题
Method and URL Structure
| Method |
Resource URL |
Authorization |
| POST |
/program_girl/contest/${contest_pk}/answer_question/ |
YES |
Request Parematers
| Name |
Description |
| question |
问题 id |
| option |
选项 id |
Request
{ "answers": [ { "question": 1, "option": 4 }, { "question": 2, "option": 8, }, { "question": 3, "option": 12 } ]}
cURL Example
curl -X POST -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' --data '{...}' http://localhost/program_girl/contest/123/answer_question/
Response Data
| Name |
Description |
| owner |
用户名 |
| contest |
竞赛 id |
| status |
状态码 |
| message |
返回提示信息 |
| answers |
提交的答案 |
| taken_amount |
获取的奖金 |
| diamond_count |
没有奖金的时候发钻石 |
| taken_medal |
是否获取一个新的勋章 |
| medal |
勋章信息 |
Status,Message
| Status |
Message |
| -1 |
奖金分完了 |
| -2 |
回答不正确 |
| -4 |
已经回答过问题了 |
| 0 |
|
Answer Data
| Name |
Descripton |
| question_detail |
题目详情 |
| option |
答案选项 id |
| correct |
是否正确 |
Medal Data
| Name |
Descripton |
| name |
勋章名称 |
| amount |
值大小 |
Response
{ "pk":145, "contest":123, "message": "", "status": 0, "taken_amount": 0.05, "medal":{ "pk":1 "record_type":"竞赛", "amount":1, "create_time":"2017-11-17T16:41:17.333223", "name":"1竞赛勋章", "extra":"", "owner":"test_002", }, "taken_medal":true, "answers":[{ "pk":1, "question_detail": { .... }, "option":4,vi "correct":true },{ "pk":2, "question_datil": { .... }, "option":8, "correct":true }]}
获取答题记录
用 contest 的 pk 获取答题记录
Method and URL Structure
| Method |
Resource URL |
Authorization |
| GET |
/program_girl/contest/${contest_pk}/answer_record/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' http://localhost/program_girl/contest/123/answer_record/
Response Data
| Name |
Description |
| owner |
用户名 |
| answers |
提交的答案 |
Answer Data
| Name |
Descripton |
| question_detail |
题目详情 |
| option |
答案选项 id |
| correct |
是否正确 |
Response
{ "pk":145, "contest":123, "answers":[{ "pk":1, "question_detail": { .... }, "option":4,vi "correct":true },{ "pk":2, "question_datil": { .... }, "option":8, "correct":true }]}
答填空题
Method and URL Structure
| Method |
Resource URL |
Authorization |
| POST |
/program_girl/contest/${contest_pk}/answer_question/ |
YES |
Request Parematers
| Name |
Description |
| question |
问题 id |
| content |
答案内容 |
Request
{ "answers": [ { "question": 1, "content": "这是答案" }, ]}
cURL Example
curl -X POST -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' --data '{...}' http://localhost/program_girl/contest/123/answer_question/
Response Data
| Name |
Description |
| owner |
用户名 |
| contest |
竞赛 id |
| status |
状态码 |
| message |
返回提示信息 |
| answers |
提交的答案 |
| taken_amount |
获取的奖金 |
Status,Message
| Status |
Message |
| -1 |
奖金分完了 |
| -2 |
回答不正确 |
| -4 |
已经回答过问题了 |
| 0 |
|
Answer Data
| Name |
Descripton |
| question_detail |
题目详情 |
| content |
答案内容 |
| correct |
是否正确 |
Response
{ "pk":145, "contest":123, "message":"", "status":0, "taken_amount":0.05, "answers":[{ "pk":1, "question_detail": { .... }, "content": "这是答案", "correct":true }]}
排行榜
用 contest 的 pk 获取问题
有 10 分钟的缓存时间
排行优先级: record_type > -amount > create_time
Method and URL Structure
| Method |
Resource URL |
Authorization |
| GET |
/program_girl/contest/${contest_pk}/ranking/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' http://localhost/program_girl/contest/1/ranking/?exclude=answers
Request Data
| Name |
Description |
| exclude |
= anwsers, 不显示答案 |
| page |
页码 |
| page_size |
每页数量 |
Request Paramarms
{ "exclude": "answers", "page": 1, "page_size": 20}
Response Data
| Name |
Description |
| owner |
用户信息 |
| contest |
竞赛 id |
| amount |
金额或数量 |
| record_type_display |
奖学金或钻石 |
Response
{ "count":21, "next":"http://testserver/program_girl/contest/8/ranking/?exclude=answers&page=2", "previous":null, "results":[{ "pk":5, "contest":8, "amount":"0.25", "record_type_display":"奖学金", "create_time":"2017-12-01T21:18:57.062982", "owner":{ "pk":6, "owner":"test_002", "name":"赵小明", "avatar":"http://www.example.com/xiaoming.jpg", "remark":null, "invitation_code":null, "experience":0, "diamond":0, "grade":{" next_name":"test_grade", "current_name":"test_grade", "current_all_experience":0, "next_all_experience":0 }, "olduser":false, "is_staff":false, "isactive":false, "balance":0.25, "top_rank":null, "medal_record":[{ "pk":4, "owner":"test_002", "name":"1竞赛勋章", "amount":1, "extra":"", "record_type":"竞赛", "create_time":"2017-12-01T21:31:40.675880" }....] } }...]}
奖励统计
Method and URL Structure
| Method |
Resource URL |
Authorization |
| GET |
/program_girl/contest/statistics// |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' http://localhost/program_girl/contest/statistics/
Response Data
| Name |
Description |
| diamond_amount |
钻石额 |
| reward_amount |
奖金额 |
{ "diamond_amount":1000, "reward_amount":0.3}