[关闭]
@fuyb1986 2017-05-26T09:56:11.000000Z 字数 5319 阅读 629

课件

冰橙课件


获取课本

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

  1. 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

  1. {
  2. "count":3,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":3,
  7. "author":1,
  8. "name":"课本第一",
  9. "intro":"介绍",
  10. "tag":"default",
  11. "created":"2017-05-23T18:24:39.915929"
  12. }...]
  13. }

获取一个课本

Method and URL Structure

Method Resource URL Authorization
GET /api/book/${pk}/ YES

cURL Example

  1. 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

  1. {
  2. "pk":1,
  3. "author":1,
  4. "name":"课本第一",
  5. "intro":"介绍",
  6. "tag":"default",
  7. "created":"2017-05-23T18:37:38.359172",
  8. "chapters":[{
  9. "pk":1,
  10. "book":1,
  11. "title":"第一章",
  12. "subtitle":"第一章副标题",
  13. "intro":"介绍",
  14. "created":"2017-05-23T18:37:38.360481",
  15. "secations":[{
  16. "pk":1,
  17. "chapter":2,
  18. "title":"第一小节",
  19. "subtitle":"第一小节副标题",
  20. "intro":"介绍",
  21. "created":"2017-05-23T19:16:39.312622",
  22. "pages":[
  23. "http://testserver/api/book/page/1/",
  24. "http://testserver/api/book/page/2/",
  25. "http://testserver/api/book/page/3/"
  26. ],
  27. "exercises":[
  28. "http://testserver/api/book/exercise/1/",
  29. "http://testserver/api/book/exercise/3/",
  30. "http://testserver/api/book/exercise/5/"
  31. ]
  32. },{
  33. "pk":2,
  34. "chapter":2,
  35. "title":"第二小节副标题",
  36. "subtitle":"第一小节副标题",
  37. "intro":"介绍",
  38. "created":"2017-05-23T19:16:39.315210",
  39. "pages":[
  40. "http://testserver/api/book/page/9/",
  41. "http://testserver/api/book/page/10/",
  42. "http://testserver/api/book/page/11/"
  43. ],
  44. "exercises":[
  45. "http://testserver/api/book/exercise/1/",
  46. "http://testserver/api/book/exercise/3/",
  47. "http://testserver/api/book/exercise/5/"
  48. ]
  49. }...]
  50. }...]
  51. }

获取一个小节

Method and URL Structure

Method Resource URL Authorization
GET /api/book/secation/{pk}/ YES

cURL Example

  1. curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/book/secation/301/

Reponse

  1. {
  2. "pk":1,
  3. "chapter":1,
  4. "title":"第一小节",
  5. "subtitle":"第一小节副标题",
  6. "intro":"介绍",
  7. "created":"2017-05-24T12:23:46.633797",
  8. "pages":[
  9. "http://testserver/api/book/page/1/",
  10. "http://testserver/api/book/page/2/",
  11. "http://testserver/api/book/page/3/"
  12. ],
  13. "exercises":[
  14. "http://testserver/api/book/exercise/1/",
  15. "http://testserver/api/book/exercise/3/",
  16. "http://testserver/api/book/exercise/5/"
  17. ]
  18. }

获取一个页面

Method and URL Structure

Method Resource URL Authorization
GET /api/book/page/{pk}/ YES

cURL Example

  1. 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

  1. {
  2. "url":"http://testserver/api/book/page/1000/",
  3. "pk":1000,
  4. "secation":"http://testserver/api/book/secation/99/",
  5. "title":"页面一",
  6. "media_url":"http://example.com/1.png",
  7. "media_type":"image",
  8. "content":"test_content",
  9. "created":"2017-05-24T12:05:13.713600"
  10. }

获取页面列表

用 secation 的 pk 获取页面列表

Method and URL Structure

Method Resource URL Authorization
GET /api/book/secation/${pk}/pages/ YES

cURL Example

  1. 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

  1. {
  2. "count":3,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "url":"http://testserver/api/book/page/1/",
  7. "pk":1,
  8. "secation":"http://testserver/api/book/secation/1/",
  9. "title":"页面一",
  10. "media_url":"http://example.com/1.png",
  11. "media_type":"image",
  12. "content":"test_content",
  13. "created":"2017-05-24T12:05:13.396317"
  14. },{
  15. "url":"http://testserver/api/book/page/2/",
  16. "pk":2,
  17. "secation":"http://testserver/api/book/secation/1/",
  18. "title":"页面一",
  19. "media_url":"http://example.com/1.png",
  20. "media_type":"image",
  21. "content":"test_content",
  22. "created":"2017-05-24T12:05:13.397770"
  23. },...]
  24. }

获取一个习题

Method and URL Structure

Method Resource URL Authorization
GET /api/book/exercise/{pk}/ YES

cURL Example

  1. 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

  1. {
  2. "pk":1,
  3. "secation":1,
  4. "title":"这是一个题目的提干",
  5. "exercise_type":1,
  6. "exercise_type_display":"单选题",
  7. "options":[{
  8. "exercise":1,
  9. "title":"A",
  10. "content":"选项A",
  11. "media_type":"image",
  12. "media_url":"http://example.com/1.png"
  13. },... ],
  14. "media_url":"",
  15. "media_type":null
  16. }

获取习题列表

用 secation 的 pk 获取习题列表

Method and URL Structure

Method Resource URL Authorization
GET /api/book/secation/${pk}/exercises/ YES

cURL Example

  1. 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

  1. {
  2. "count":10,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":1,
  7. "secation":1,
  8. "title":"这是一个题目的提干",
  9. "exercise_type":1,
  10. "exercise_type_display":"单选题",
  11. "options":[{
  12. "exercise":1,
  13. "title":"A",
  14. "content":"选项A",
  15. "media_type":"image",
  16. "media_url":"http://example.com/1.png"
  17. },...],
  18. },..]
  19. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注