课件
冰橙课件
获取课本
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/api/book/ |
YES |
Requeset Paramters
Name |
Description |
Required |
Default |
exclude |
不需要的 fields |
NO |
|
?exclude=chapters 只获取基础信息不获取 chapter 列表
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/?exclude=chapters
Response Data
Name |
Description |
pk |
id |
name |
课本名字 |
created |
创建时间 |
intro |
介绍 |
tag |
标签,分类 |
Response
{
"count":3,
"next":null,
"previous":null,
"results":[{
"pk":3,
"author":1,
"name":"课本第一",
"intro":"介绍",
"tag":"default",
"created":"2017-05-23T18:24:39.915929"
}...]
}
获取一个课本
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/api/book/${pk}/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/199/
Response Data
Name |
Description |
pk |
id |
name |
课本名字 |
created |
创建时间 |
intro |
介绍 |
tag |
标签,分类 |
charpters |
章列表 |
secations |
小节列表 |
Response
{
"pk":1,
"author":1,
"name":"课本第一",
"intro":"介绍",
"tag":"default",
"created":"2017-05-23T18:37:38.359172",
"chapters":[{
"pk":1,
"book":1,
"title":"第一章",
"subtitle":"第一章副标题",
"intro":"介绍",
"created":"2017-05-23T18:37:38.360481",
"secations":[{
"pk":1,
"chapter":2,
"title":"第一小节",
"subtitle":"第一小节副标题",
"intro":"介绍",
"created":"2017-05-23T19:16:39.312622",
"pages":[
"http://testserver/api/book/page/1/",
"http://testserver/api/book/page/2/",
"http://testserver/api/book/page/3/"
],
"exercises":[
"http://testserver/api/book/exercise/1/",
"http://testserver/api/book/exercise/3/",
"http://testserver/api/book/exercise/5/"
]
},{
"pk":2,
"chapter":2,
"title":"第二小节副标题",
"subtitle":"第一小节副标题",
"intro":"介绍",
"created":"2017-05-23T19:16:39.315210",
"pages":[
"http://testserver/api/book/page/9/",
"http://testserver/api/book/page/10/",
"http://testserver/api/book/page/11/"
],
"exercises":[
"http://testserver/api/book/exercise/1/",
"http://testserver/api/book/exercise/3/",
"http://testserver/api/book/exercise/5/"
]
}...]
}...]
}
获取一个小节
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/api/book/secation/{pk}/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/secation/301/
Reponse
{
"pk":1,
"chapter":1,
"title":"第一小节",
"subtitle":"第一小节副标题",
"intro":"介绍",
"created":"2017-05-24T12:23:46.633797",
"pages":[
"http://testserver/api/book/page/1/",
"http://testserver/api/book/page/2/",
"http://testserver/api/book/page/3/"
],
"exercises":[
"http://testserver/api/book/exercise/1/",
"http://testserver/api/book/exercise/3/",
"http://testserver/api/book/exercise/5/"
]
}
获取一个页面
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/api/book/page/{pk}/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/page/1000/
Response Data
Name |
Description |
url |
获取页面信息的 url |
pk |
id |
secation |
小节的 url |
title |
标题 |
created |
创建时间 |
content |
文字内容 |
media_url |
图片或视频的 url |
media_type |
iamge, video 类型 |
Response
{
"url":"http://testserver/api/book/page/1000/",
"pk":1000,
"secation":"http://testserver/api/book/secation/99/",
"title":"页面一",
"media_url":"http://example.com/1.png",
"media_type":"image",
"content":"test_content",
"created":"2017-05-24T12:05:13.713600"
}
获取页面列表
用 secation 的 pk 获取页面列表
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/api/book/secation/${pk}/pages/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/secation/1/pages/
Response Data
Name |
Description |
url |
获取页面信息的 url |
pk |
id |
secation |
小节的 url |
title |
标题 |
created |
创建时间 |
content |
文字内容 |
media_url |
图片或视频的 url |
media_type |
iamge, video 类型 |
Response
{
"count":3,
"next":null,
"previous":null,
"results":[{
"url":"http://testserver/api/book/page/1/",
"pk":1,
"secation":"http://testserver/api/book/secation/1/",
"title":"页面一",
"media_url":"http://example.com/1.png",
"media_type":"image",
"content":"test_content",
"created":"2017-05-24T12:05:13.396317"
},{
"url":"http://testserver/api/book/page/2/",
"pk":2,
"secation":"http://testserver/api/book/secation/1/",
"title":"页面一",
"media_url":"http://example.com/1.png",
"media_type":"image",
"content":"test_content",
"created":"2017-05-24T12:05:13.397770"
},...]
}
获取一个习题
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/api/book/exercise/{pk}/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/exericse/1001/
Response Data
Name |
Description |
url |
获取页面信息的 url |
pk |
id |
secation |
小节的 id |
title |
题干 |
media_url |
图片或视频的 url |
media_type |
iamge, video 类型 |
options |
选项 |
Response
{
"pk":1,
"secation":1,
"title":"这是一个题目的提干",
"exercise_type":1,
"exercise_type_display":"单选题",
"options":[{
"exercise":1,
"title":"A",
"content":"选项A",
"media_type":"image",
"media_url":"http://example.com/1.png"
},... ],
"media_url":"",
"media_type":null
}
获取习题列表
用 secation 的 pk 获取习题列表
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/api/book/secation/${pk}/exercises/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/secation/1/exercises/
Response Data
Name |
Description |
url |
获取页面信息的 url |
pk |
id |
secation |
小节的 id |
title |
题干 |
media_url |
图片或视频的 url |
media_type |
iamge, video 类型 |
options |
选项 |
Response
{
"count":10,
"next":null,
"previous":null,
"results":[{
"pk":1,
"secation":1,
"title":"这是一个题目的提干",
"exercise_type":1,
"exercise_type_display":"单选题",
"options":[{
"exercise":1,
"title":"A",
"content":"选项A",
"media_type":"image",
"media_url":"http://example.com/1.png"
},...],
},..]
}