Invitation invitation = null;
try {
/* Set the role the user is invited to have in the course. Possible values of CourseRole can be
found here: https://developers.google.com/classroom/reference/rest/v1/invitations#courserole.*/
Invitation content =
new Invitation().setCourseId(courseId).setUserId(userId).setRole("TEACHER");
invitation = service.invitations().create(content).execute();
System.out.printf(
"User (%s) has been invited to course (%s).\n",
invitation.getUserId(), invitation.getCourseId());
} catch (GoogleJsonResponseException e) {
// TODO (developer) - handle error appropriately
GoogleJsonError error = e.getDetails();
if (error.getCode() == 404) {
System.out.printf("The course or user does not exist.\n");
}
throw e;
} catch (Exception e) {
throw e;
}
return invitation;
เรียกดูคำเชิญ
เรียกข้อมูลคำเชิญที่เฉพาะเจาะจงโดยเรียกใช้เมธอด invitations.get() และระบุ id ของคำเชิญ
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2024-11-23 UTC"],[[["An Invitation resource in Classroom allows users to join a course with a specific role, containing fields like `id`, `userId`, `courseId`, and `role`."],["You can create, retrieve, accept, and delete invitations using the Classroom API's `invitations` methods, specifying necessary parameters like `courseId`, `userId`, `role`, and `id`."],["Accepting an invitation adds the user to the course with the specified role and deletes the invitation, while deleting an invitation requires using the `invitations.delete()` method."],["Updating an invitation involves deleting the existing one and creating a new one with the desired changes."]]],[]]