[关闭]
@fuyb1986 2018-05-03T04:38:15.000000Z 字数 2784 阅读 638

老师的课程安排、选课

儿童编程


获取课程安排列表

Method and URL Structure

Method Resource URL Authorization
GET /classroom/classschedules/ YES

Requeset Paramters

学生只能从明天以及明天之后开始的课程里选课

Name Description Required Default
week 从本周算起前/后 N 周的 NO
day 前/后 N 天开始的 NO
teacher 老师的用户名 No


day: N 天之前或之后开始的;
等于 0: 今天;
大于 0: N 天之后;
小于 0: N 天之前;


week 前/后 N 周之七天的;
等于0: 本周;
大于0: N周之后;
小于0: N周之前;


没有办主任的学生,可以用 ?teacher=18516xxxx 来获取老师的安排

cURL Example

  1. curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/classroom/classschedules/?day=1

Response Data

Name Description
pk id
starttime 开始时间
endtime 结束时间
teacher 老师 id
status 状态
students 对应的教室的学生列表
lesston_total 占用的课

Status

Name Description
0 待选
1 占用
2 已选

Response

  1. {
  2. "count": 2,
  3. "next": null,
  4. "previous": null,
  5. "results": [
  6. {
  7. "pk": 5227,
  8. "starttime": "2017-06-09T19:30:00",
  9. "endtime": "2017-06-09T20:30:00",
  10. "quantity": 0,
  11. "teacher": 1,
  12. "status": 2,
  13. "lesson_total": 1.0,
  14. "students": [{
  15. "name": "小丽",
  16. "owner": "1234567890"
  17. },.. ]
  18. },
  19. ....
  20. ]
  21. }

选课

Method and URL Structure

Method Resource URL Authorization
POST /classroom/classschedule/choice/${pk}/ YES

cURL Example

  1. curl -X POST -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/classroom/classschedule/choice/5227/

Response

  1. {
  2. "status": 0,
  3. "message": ""
  4. }

取消选课

Method and URL Structure

Method Resource URL Authorization
DELETE /classroom/classschedule/cancel/${pk}/ YES

Requeset Paramters

Name Description Required Default Comment
student 学生的用户名 NO 管理员取消教室时需要传递这个参数

cURL Example

  1. curl -X DELETE -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/classroom/classschedule/cancel/5227/

Response

  1. {
  2. "status": 0,
  3. "message": ""
  4. }

创建教室

只有管理员调用这个接口

Method and URL Structure

Method Resource URL Authorization
POST /classroom/classschedule/create_classroom/${pk}/ YES

Requeset Paramters

Name Description Required Default
student 学生的用户名 YES

cURL Example

  1. curl -X POST -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/classroom/classschedule/ceate_classroom/5227/

Response

  1. {
  2. "status": 0,
  3. "message": ""
  4. }

创建上课安排

Method and URL Structure

Method Resource URL Authorization
POST /classroom/create_schedule/ YES

Requeset Paramters

Name Description Required Default
start_time 安排开始时间戳(秒) YES
end_time 安排开始时间戳(秒) YES
quantity 教室数量 YES 1
hours 教室时间 YES 1.0

Request Data

  1. {
  2. "start_time": 1522328400,
  3. "end_time": 1522332000,
  4. "quantity" : 2,
  5. "hours": 1.5
  6. }

cURL Example

  1. curl -X POST -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' --data '{...}' http://localhost/classroom/classschedule/ceate_schedule/

Response

  1. {
  2. "status": 0,
  3. "message": ""
  4. }

删除上课安排

Method and URL Structure

Method Resource URL Authorization
DELETE /classroom/classschedule/delete/ YES

cURL Example

  1. curl -X DELTE -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/classroom/delete/12345/

Response

  1. {
  2. "status": 0,
  3. "message": ""
  4. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注