Hiện tại, các nhà phát triển đã có thể sử dụng rộng rãi tiện ích bổ sung của Google Lớp học! Vui lòng xem
tài liệu về tiện ích bổ sung để biết thêm thông tin.
Method: courses.courseWork.create
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tạo bài tập trong khoá học.
Bài tập của khoá học (và bài nộp tương ứng của học viên) được liên kết với dự án Developer Console của mã ứng dụng khách OAuth dùng để gửi yêu cầu. Bạn phải sử dụng mã ứng dụng khách OAuth trong dự án Developer Console được liên kết để gửi yêu cầu sửa đổi bài tập của khoá học và bài nộp của học viên thông qua API Lớp học.
Phương thức này trả về các mã lỗi sau:
PERMISSION_DENIED
nếu người dùng yêu cầu không được phép truy cập vào khoá học được yêu cầu, tạo bài tập trong khoá học được yêu cầu, chia sẻ tệp đính kèm trên Drive hoặc gặp lỗi truy cập.
INVALID_ARGUMENT
nếu yêu cầu không đúng định dạng.
NOT_FOUND
nếu khoá học được yêu cầu không tồn tại.
FAILED_PRECONDITION
cho lỗi yêu cầu sau:
Yêu cầu HTTP
POST https://classroom.googleapis.com/v1/courses/{courseId}/courseWork
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
courseId |
string
Giá trị nhận dạng của khoá học. Giá trị nhận dạng này có thể là giá trị nhận dạng do Lớp học chỉ định hoặc alias .
|
Tham số truy vấn
Thông số |
previewVersion |
enum (PreviewVersion )
Không bắt buộc. Phiên bản xem trước của điểm cuối. Bạn phải đặt giá trị này để truy cập vào các tính năng API mới được cung cấp cho nhà phát triển trong Chương trình xem trước.
|
Nội dung yêu cầu
Nội dung yêu cầu chứa một bản sao của CourseWork
.
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ chứa một thực thể CourseWork
mới tạo.
Phạm vi uỷ quyền
Yêu cầu phạm vi OAuth sau:
https://www.googleapis.com/auth/classroom.coursework.students
Để biết thêm thông tin, hãy xem Hướng dẫn uỷ quyền.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["# Method: courses.courseWork.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nCreates course work.\n\nThe resulting course work (and corresponding student submissions) are associated with the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to make the request. Classroom API requests to modify course work and student submissions must be made with an OAuth client ID from the associated Developer Console project.\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work in the requested course, share a Drive attachment, or for [access errors](/workspace/classroom/reference/Access.Errors).\n- `INVALID_ARGUMENT` if the request is malformed.\n- `NOT_FOUND` if the requested course does not exist.\n- `FAILED_PRECONDITION` for the following [request error](/workspace/classroom/reference/Request.Errors):\n - AttachmentNotVisible\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/courses/{courseId}/courseWork`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `courseId` | `string` Identifier of the course. This identifier can be either the Classroom-assigned identifier or an [alias](/workspace/classroom/reference/rest/v1/courses.aliases#CourseAlias). |\n\n### Query parameters\n\n| Parameters ||\n|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `previewVersion` | `enum (`[PreviewVersion](/workspace/classroom/reference/rest/v1/PreviewVersion)`)` Optional. The preview version of the endpoint. This must be set in order to access new API capabilities made available to developers in the Preview Program. |\n\n### Request body\n\nThe request body contains an instance of [CourseWork](/workspace/classroom/reference/rest/v1/courses.courseWork#CourseWork).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [CourseWork](/workspace/classroom/reference/rest/v1/courses.courseWork#CourseWork).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/classroom.coursework.students`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]