班级
冰橙课件
获取班级列表
老师创建的班级用此接口获取
学生加入的班级用此接口获取
Method and URL Structure
| Method |
Resource URL |
Authorization |
| GET |
/api/classroom/ |
YES |
cURL Example
curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/classroom/
Response Data
| Name |
Description |
| pk |
id |
| name |
名称 |
| created |
创建时间 |
| teacher |
教师用户信息 |
Response
{ "count":1, "next":null, "previous":null, "results":[{ "pk":1, "name":"三年级(9)班", "created":"2017-05-17T17:58:58.894193", "teacher":{ "pk":1, "owner":1, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"赵小明", "sex":"M", "sex_display":"男", "birthday":"1990-01-01" } }]}
创建班级
Method and URL Structure
| Method |
Resource URL |
Authorization |
| POST |
/api/classroom/create/ |
YES |
Request Pramaters
| Name |
Description |
Required |
Default |
| name |
名称 |
YES |
|
Request Data
{ "name": "一年级(1)班"}
cURL Example
curl -X POST -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' --data '{"name": "一年(1)班"}' http://localhost/api/classroom/create/
Response Data
| Name |
Description |
| pk |
id |
| name |
名称 |
| created |
创建时间 |
| teacher |
教师用户信息 |
Response
{ "pk":1, "name":"一年级(1)班", "created":"2017-05-17T18:17:51.396326", "teacher":{ "pk":1, "owner":1, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"赵小明", "sex":"M", "sex_display":"男", "birthday":"1990-01-01" }}
更新班级
老师更新自己创建的班级
Method and URL Structure
| Method |
Resource URL |
Authorization |
| PUT |
/api/classroom/update/${pk}/ |
YES |
Request Pramaters
| Name |
Description |
Required |
Default |
| name |
名称 |
YES |
|
Request Data
{ "name": "三年级(1)班"}
cURL Example
curl -X PUT -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' --data '{"name": "三年级(1)班"}' http://localhost/api/classroom/update/200/
Response Data
| Name |
Description |
| pk |
id |
| name |
名称 |
| created |
创建时间 |
| teacher |
教师用户信息 |
Response
{ "pk":200, "name":"三年级(1)班", "created":"2017-05-17T18:17:51.396326", "teacher":{ "pk":1, "owner":1, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"赵小明", "sex":"M", "sex_display":"男", "birthday":"1990-01-01" }}
删除班级
老师删除自己创建的班级
Method and URL Structure
| Method |
Resource URL |
Authorization |
| DELETE |
/api/classroom/delete/200/ |
YES |
cURL Example
curl -X DELETE -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' http://localhost/api/classroom/delete/200/
搜索班级
学生获取老师创建的班级
Method and URL Structure
| Method |
Resource URL |
Authorization |
| GET |
/api/classroom/search/ |
YES |
Request Pramaters
| Name |
Description |
Required |
Default |
| teacher |
老师用户名 |
YES |
|
Request Data
{ "teacher": "12345678910"}
cURL Example
# 方式一curl -X GET -H "Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c" -H "Content-Type: application/json" http://localhost/api/classroom/search/?teacher=12345678910# 方式二curl -X GET -H 'Authorization: token 95b7b4d8fff5d76c9d3d2954fe5c7d456c110a8c' -H 'Content-Type: application/json' --data '{"teacher": "12345678910"}' http://localhost/api/classroom/search/
Response Data
| Name |
Description |
| pk |
id |
| name |
名称 |
| created |
创建时间 |
| teacher |
教师用户信息 |
Reponse
{ "count":2, "next":null, "previous":null, "results":[{ "pk":2, "name":"三年级(9)班", "created":"2017-05-18T14:27:57.002889", "teacher":{ "pk":1, "owner":1, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"赵小明", "sex":"M", "sex_display":"男", "birthday":"1990-01-01" } },{ "pk":1, "name":"三年级(9)班", "created":"2017-05-18T14:27:57.000523", "teacher":{ "pk":1, "owner":1, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan", "name":"赵小明", "sex":"M", "sex_display":"男", "birthday":"1990-01-01" } }]}