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.
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.
Phần bắt đầu nhanh giải thích cách thiết lập và chạy một ứng dụng gọi API Google Workspace.
Các hướng dẫn nhanh về Google Workspace sử dụng thư viện ứng dụng API để xử lý một số thông tin chi tiết về quy trình xác thực và uỷ quyền. Bạn nên sử dụng thư viện ứng dụng cho các ứng dụng của riêng mình. Phần bắt đầu nhanh này sử dụng phương pháp xác thực đơn giản phù hợp với môi trường thử nghiệm. Đối với môi trường phát hành công khai, bạn nên tìm hiểu về quy trình xác thực và uỷ quyền trước khi chọn thông tin xác thực truy cập phù hợp với ứng dụng của mình.
/** * Lists 10 course names and ids. */functionlistCourses(){/** here pass pageSize Query parameter as argument to get maximum number of result * @see https://developers.google.com/classroom/reference/rest/v1/courses/list */constoptionalArgs={pageSize:10// Use other parameter here if needed};try{// call courses.list() method to list the courses in classroomconstresponse=Classroom.Courses.list(optionalArgs);constcourses=response.courses;if(!courses||courses.length===0){console.log('Nocoursesfound.');return;}// Print the course names and IDs of the coursesfor(constcourseofcourses){console.log('%s(%s)',course.name,course.id);}}catch(err){// TODO (developer)- Handle Courses.list() exception from Classroom API// get errors like PERMISSION_DENIED/INVALID_ARGUMENT/NOT_FOUNDconsole.log('Failedwitherror%s',err.message);}}
Nhấp vào biểu tượng Lưu .
Nhấp vào Untitled project (Dự án chưa có tên), nhập Quickstart (Bắt đầu nhanh) rồi nhấp vào Rename (Đổi tên).
Định cấu hình tập lệnh
Bật API Google Lớp học
Mở dự án Apps Script.
Nhấp vào biểu tượng Trình chỉnh sửacode.
Bên cạnh Dịch vụ, hãy nhấp vào biểu tượng Thêm dịch vụ
add .
Chọn Google Classroom API rồi nhấp vào Thêm.
Chạy mẫu
Trong trình chỉnh sửa Apps Script, hãy nhấp vào Run (Chạy).
Trong lần đầu chạy mẫu, bạn sẽ được nhắc uỷ quyền truy cập:
Nhấp vào Xem lại quyền.
Chọn một tài khoản.
Nhấp vào Cho phép.
Nhật ký thực thi của tập lệnh sẽ xuất hiện ở cuối cửa sổ.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2024-12-21 UTC."],[[["This quickstart guide demonstrates how to create a Google Apps Script that interacts with the Google Classroom API to list courses."],["Before running the script, you need a Google for Education account, access to Google Drive, and must enable the Google Classroom API within the script."],["The script retrieves and displays the names and IDs of up to 10 courses from your Google Classroom account, requiring authorization upon its first execution."],["For production environments, refer to the provided resources for authentication, authorization, and troubleshooting guidance."],["Users can explore further by consulting the advanced services documentation, troubleshooting guide, and the Classroom API reference."]]],[]]