Để nhà sáng tạo biểu mẫu có nhiều quyền kiểm soát hơn đối với những người có thể trả lời, chúng tôi sẽ ra mắt các chế độ kiểm soát chi tiết cho người trả lời. Theo mặc định, những biểu mẫu được tạo bằng API sau ngày 31 tháng 1 năm 2026 sẽ có trạng thái chưa xuất bản. Để tìm hiểu thêm, hãy xem bài viết
Các thay đổi về API đối với Google Biểu mẫu.
Tổng quan
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.
Google Biểu mẫu API là một giao diện RESTful cho phép bạn tạo và sửa đổi biểu mẫu cũng như bài kiểm tra, truy xuất câu trả lời của biểu mẫu và điểm của bài kiểm tra, thiết lập khoá đáp án của bài kiểm tra kèm theo phản hồi tự động và nhận thông báo đẩy. Các trường hợp sử dụng phổ biến nhất của API này bao gồm những nhiệm vụ sau:
- Tạo biểu mẫu hoặc bài kiểm tra
- Xuất bản và quản lý người trả lời
- Cập nhật biểu mẫu hoặc bài kiểm tra
- Truy xuất câu trả lời từ biểu mẫu hoặc bài kiểm tra
- Đọc nội dung và siêu dữ liệu của biểu mẫu
- Thiết lập và nhận thông báo đẩy
- Sau đây là danh sách các thuật ngữ thường dùng trong Forms API:
- Biểu mẫu
Một tài liệu Google Biểu mẫu, được tạo và lưu trữ trong Drive. Mỗi biểu mẫu được biểu thị bằng một tài nguyên Form
và có một giá trị formId
duy nhất, chứa chữ cái, số, dấu gạch ngang hoặc dấu gạch dưới. Bạn có thể tìm thấy mã nhận dạng biểu mẫu trong URL của Google Biểu mẫu:
https://docs.google.com/forms/d/FORM_ID/edit
- Bài kiểm tra
Một loại tài liệu cụ thể của Google Biểu mẫu cho phép chấm điểm các câu trả lời trên biểu mẫu dựa trên đáp án. Bạn chỉ có thể tạo bài kiểm tra bằng cách sử dụng phương thức batchUpdate()
để cập nhật chế độ cài đặt isQuiz
trên một biểu mẫu hiện có thành true
.
- Chấm điểm
- Giá trị điểm, đáp án và ý kiến phản hồi cho một câu hỏi, được áp dụng khi
isQuiz
là true
. Được biểu thị bằng tài nguyên Grading
.
- Phản hồi
- Câu trả lời được đưa ra cho người dùng cuối khi trả lời một câu hỏi trong bài kiểm tra, được biểu thị bằng tài nguyên
Feedback
.
- Item
Một phần tử trong biểu mẫu, được biểu thị bằng tài nguyên Item. Item
là một phần tử lặp lại có thể chứa một phần, nhóm câu hỏi, câu hỏi, văn bản, hình ảnh hoặc video.
- Câu hỏi
Một câu hỏi duy nhất trên biểu mẫu, được biểu thị bằng tài nguyên Question
.
- Nhóm câu hỏi
Một nhóm câu hỏi có cùng một tập hợp câu trả lời có thể (ví dụ: một lưới gồm các mức phân loại từ 1 đến 5). Được biểu thị bằng tài nguyên QuestionGroupItem
.
- Section
Phần là một cách để chia biểu mẫu thành nhiều trang và thêm logic có điều kiện (chẳng hạn như chỉ hiện một số câu hỏi nhất định dựa trên cách người dùng trả lời). Các phần tương ứng với tài nguyên PageBreakItem
.
- Trả lời
Câu trả lời của người dùng cuối cho một câu hỏi, được biểu thị bằng tài nguyên Answer
. Bao gồm cả thông tin về điểm (nếu có), siêu dữ liệu và nội dung của câu trả lời.
- Đáp
Việc người dùng cuối gửi biểu mẫu, được biểu thị bằng tài nguyên FormResponse
.
- Xem
Một điều kiện kích hoạt theo dõi các thay đổi đối với các thay đổi về giản đồ biểu mẫu (chẳng hạn như chỉnh sửa câu hỏi) hoặc việc gửi phản hồi biểu mẫu và gửi thông báo đẩy khi có thay đổi xảy ra. Được biểu thị bằng tài nguyên Watch
.
Khi quản lý biểu mẫu và bài kiểm tra, việc tìm hiểu cách chỉ định các trường khác nhau có thể phức tạp, vì nhiều đối tượng biểu mẫu có thể được lồng vào nhau theo nhiều cách. Để xem cách biểu diễn trực quan của một biểu mẫu tương ứng với các trường, bạn nên sử dụng giao diện người dùng để tạo một vài ví dụ về các biểu mẫu mà ứng dụng của bạn có thể tạo. Sau đó, hãy truy xuất JSON tương ứng bằng phương thức forms.get()
để bạn có thể so sánh. Ví dụ: ví dụ về bài kiểm tra này tương ứng với JSON sau:
{
"formId": "FORM_ID",
"info": {
"title": "Famous Black Women",
"description": "Please complete this quiz based off of this week's readings for class.",
"documentTitle": "API Example Quiz"
},
"settings": {
"quizSettings": {
"isQuiz": true
}
},
"revisionId": "00000021",
"responderUri": "https://docs.google.com/forms/d/e/1FAIpQLSd0iBLPh4suZoGW938EU1WIxzObQv_jXto0nT2U8HH2KsI5dg/viewform",
"items": [
{
"itemId": "5d9f9786",
"imageItem": {
"image": {
"contentUri": "DIRECT_URL",
"properties": {
"alignment": "LEFT"
}
}
}
},
{
"itemId": "72b30353",
"title": "Which African American woman authored \"I Know Why the Caged Bird Sings\"?",
"questionItem": {
"question": {
"questionId": "25405d4e",
"required": true,
"grading": {
"pointValue": 2,
"correctAnswers": {
"answers": [
{
"value": "Maya Angelou"
}
]
}
},
"choiceQuestion": {
"type": "RADIO",
"options": [
{
"value": "Maya Angelou"
},
{
"value": "bell hooks"
},
{
"value": "Alice Walker"
},
{
"value": "Roxane Gay"
}
]
}
}
}
},
{
"itemId": "0a4859c8",
"title": "Who was the first Dominican-American woman elected to state office?",
"questionItem": {
"question": {
"questionId": "37fff47a",
"grading": {
"pointValue": 2,
"correctAnswers": {
"answers": [
{
"value": "Grace Diaz"
}
]
}
},
"choiceQuestion": {
"type": "RADIO",
"options": [
{
"value": "Rosa Clemente"
},
{
"value": "Grace Diaz"
},
{
"value": "Juana Matias"
},
{
"value": "Sabrina Matos"
}
]
}
}
}
}
],
"publishSettings" : {
"isPublished": true,
"isAcceptingResponses": true
}
}
Các bước tiếp theo
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-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],["The Google Forms API facilitates creating, modifying, and retrieving data from forms and quizzes. Key actions include creating and updating forms/quizzes, retrieving responses, reading form content/metadata, and setting up push notifications. Quizzes can include grading, answer keys, and feedback. Forms consist of *Items*, like *Questions*, *Question Groups*, and *Sections*. User input is stored as *Answers* in *Responses*. *Watches* track form changes and trigger push notifications.\n"],null,["# Overview\n\nThe Google Forms API is a RESTful interface that lets you create and modify forms\nand quizzes, retrieve form responses and quiz grades, set up quiz answer keys\nwith automatic feedback, and receive push notifications. The most common uses\nof this API include the following tasks:\n\n- Create a form or quiz\n- Publish and manage responders\n- Update a form or quiz\n- Retrieve responses from a form or quiz\n- Read form content and metadata\n- Set up and receive push notifications\n\nThe following is a list of common terms used in the Forms API:\n*Form*\n\n: A Google Forms document, created and stored in Drive. Each\n form is represented by a\n [`Form`](/workspace/forms/api/reference/rest/v1/forms) resource\n and has a unique `formId` value, containing letters, numbers, hyphens, or\n underscores. You can find the form ID in a Google Forms URL:\n\n: `https://docs.google.com/forms/d/FORM_ID/edit`\n\n*Quiz*\n\n: A specific type of Google Forms document that allows for grading of the\n form responses against an answer key. A quiz can only be created by using\n the [`batchUpdate()`](/workspace/forms/api/reference/rest/v1/forms/batchUpdate)\n method to update the `isQuiz` setting on an existing form to `true`.\n\n *Grading*\n : A point value, answer key, and feedback for a question, applied when\n `isQuiz` is `true`. Represented by the\n [`Grading`](/workspace/forms/api/reference/rest/v1/forms#grading) resource.\n\n *Feedback*\n : A response given to the end user when responding to a question on a quiz,\n represented by the [`Feedback`](/workspace/forms/api/reference/rest/v1/Feedback)\n resource.\n\n*Item*\n\n: A single element in a form, represented by the\n [Item](/workspace/forms/api/reference/rest/v1/forms#item) resource. `Item` is a\n repeating element which can contain a section, question group, question,\n text, image, or video.\n\n*Question*\n\n: A single question on the form, represented by the\n [`Question`](/workspace/forms/api/reference/rest/v1/forms#question) resource.\n\n*Question group*\n\n: A group of questions that all share the same set of possible answers (for\n example, a grid of ratings from 1 to 5). Represented by the\n [`QuestionGroupItem`](/workspace/forms/api/reference/rest/v1/forms#questiongroupitem)\n resource.\n\n*Section*\n\n: A section is a way to break up a form into multiple pages and add\n conditional logic (such as only showing certain questions based on how the\n user answers). Sections correspond to the\n [`PageBreakItem`](/workspace/forms/api/reference/rest/v1/forms#PageBreakItem)\n resource.\n\n*Answer*\n\n: The end user's answer to a question, represented by the\n [`Answer`](/workspace/forms/api/reference/rest/v1/forms.responses#Answer)\n resource. Includes both grade information (if present), metadata, and the\n content of the answer.\n\n*Response*\n\n: The end user's submission of a form, represented by the\n [`FormResponse`](/workspace/forms/api/reference/rest/v1/forms.responses)\n resource.\n\n*Watch*\n\n: A trigger that tracks changes to either form schema changes (such as edits\n to questions) or form response submissions and sends a push notification when\n a change occurs. Represented by the\n [`Watch`](/workspace/forms/api/reference/rest/v1/forms.watches) resource.\n\nForm structure\n--------------\n\nWhen managing forms and quizzes, understanding how to specify different fields\ncan be complicated, given that many of the form objects can be nested inside\neach other in multiple ways. To see how the visual representation of a form\nmaps to the fields, we recommend using the UI to create a few examples of\nforms your application might generate. Then retrieve the corresponding JSON\nusing the\n[`forms.get()`](/workspace/forms/api/reference/rest/v1/forms/get) method\nso you can compare. For example,\n[this example quiz](https://docs.google.com/forms/d/e/1FAIpQLSd0iBLPh4suZoGW938EU1WIxzObQv_jXto0nT2U8HH2KsI5dg/viewform)\ncorresponds to the following JSON: \n\n {\n \"formId\": \"FORM_ID\",\n \"info\": {\n \"title\": \"Famous Black Women\",\n \"description\": \"Please complete this quiz based off of this week's readings for class.\",\n \"documentTitle\": \"API Example Quiz\"\n },\n \"settings\": {\n \"quizSettings\": {\n \"isQuiz\": true\n }\n },\n \"revisionId\": \"00000021\",\n \"responderUri\": \"https://docs.google.com/forms/d/e/1FAIpQLSd0iBLPh4suZoGW938EU1WIxzObQv_jXto0nT2U8HH2KsI5dg/viewform\",\n \"items\": [\n {\n \"itemId\": \"5d9f9786\",\n \"imageItem\": {\n \"image\": {\n \"contentUri\": \"DIRECT_URL\",\n \"properties\": {\n \"alignment\": \"LEFT\"\n }\n }\n }\n },\n {\n \"itemId\": \"72b30353\",\n \"title\": \"Which African American woman authored \\\"I Know Why the Caged Bird Sings\\\"?\",\n \"questionItem\": {\n \"question\": {\n \"questionId\": \"25405d4e\",\n \"required\": true,\n \"grading\": {\n \"pointValue\": 2,\n \"correctAnswers\": {\n \"answers\": [\n {\n \"value\": \"Maya Angelou\"\n }\n ]\n }\n },\n \"choiceQuestion\": {\n \"type\": \"RADIO\",\n \"options\": [\n {\n \"value\": \"Maya Angelou\"\n },\n {\n \"value\": \"bell hooks\"\n },\n {\n \"value\": \"Alice Walker\"\n },\n {\n \"value\": \"Roxane Gay\"\n }\n ]\n }\n }\n }\n },\n {\n \"itemId\": \"0a4859c8\",\n \"title\": \"Who was the first Dominican-American woman elected to state office?\",\n \"questionItem\": {\n \"question\": {\n \"questionId\": \"37fff47a\",\n \"grading\": {\n \"pointValue\": 2,\n \"correctAnswers\": {\n \"answers\": [\n {\n \"value\": \"Grace Diaz\"\n }\n ]\n }\n },\n \"choiceQuestion\": {\n \"type\": \"RADIO\",\n \"options\": [\n {\n \"value\": \"Rosa Clemente\"\n },\n {\n \"value\": \"Grace Diaz\"\n },\n {\n \"value\": \"Juana Matias\"\n },\n {\n \"value\": \"Sabrina Matos\"\n }\n ]\n }\n }\n }\n }\n ],\n \"publishSettings\" : {\n \"isPublished\": true,\n \"isAcceptingResponses\": true\n }\n }\n\nNext steps\n----------\n\n- To learn about developing with Google Workspace APIs, including handling authentication and authorization, refer to [Get started as a Workspace developer](/workspace/guides/getstarted-overview).\n- To learn how to configure and run a basic Forms API app, read the [Quickstarts overview](/workspace/forms/api/guides/quickstarts-overview)."]]