Một biểu mẫu chứa các thuộc tính và mục tổng thể. Các thuộc tính bao gồm tiêu đề, chế độ cài đặt và nơi lưu trữ các câu trả lời. Các mục bao gồm các mục câu hỏi như hộp đánh dấu hoặc mục chọn, trong khi các mục bố cục đề cập đến những thứ như dấu ngắt trang. Bạn có thể truy cập hoặc tạo biểu mẫu từ FormApp.
// Open a form by ID and create a new spreadsheet. const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); const ss = SpreadsheetApp.create('Spreadsheet Name'); // Update form properties via chaining. form.setTitle('Form Name') .setDescription('Description of form') .setConfirmationMessage('Thanks for responding!') .setAllowResponseEdits(true) .setAcceptingResponses(false); // Update the form's response destination. form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
Phương thức
| Phương thức | Kiểu dữ liệu trả về | Mô tả ngắn |
|---|---|---|
add | Checkbox | Nối một mục câu hỏi mới, được trình bày dưới dạng một lưới gồm các cột và hàng, cho phép người trả lời chọn nhiều lựa chọn cho mỗi hàng trong một chuỗi hộp đánh dấu. |
add | Checkbox | Thêm một mục câu hỏi mới cho phép người trả lời chọn một hoặc nhiều hộp đánh dấu, cũng như trường "khác" (không bắt buộc). |
add | Date | Thêm một mục câu hỏi mới cho phép người trả lời chỉ định một ngày. |
add | Date | Thêm một mục câu hỏi mới cho phép người trả lời chỉ định ngày và giờ. |
add | Duration | Thêm một mục câu hỏi mới cho phép người trả lời cho biết khoảng thời gian. |
add | Form | Thêm người dùng đã cho vào danh sách người chỉnh sửa cho Form. |
add | Form | Thêm người dùng đã cho vào danh sách người chỉnh sửa cho Form. |
add | Form | Thêm mảng người dùng đã cho vào danh sách người chỉnh sửa cho Form. |
add | Grid | Thêm một mục câu hỏi mới, được trình bày dưới dạng một lưới gồm các cột và hàng, cho phép người trả lời chọn một lựa chọn cho mỗi hàng trong một chuỗi nút chọn. |
add | Image | Nối một mục bố cục mới hiển thị hình ảnh. |
add | List | Nối một mục câu hỏi mới cho phép người trả lời chọn một lựa chọn trong danh sách thả xuống. |
add | Multiple | Thêm một mục câu hỏi mới cho phép người trả lời chọn một lựa chọn trong danh sách nút chọn hoặc một trường "khác" không bắt buộc. |
add | Page | Thêm một mục bố cục mới đánh dấu điểm bắt đầu của một trang. |
add | Paragraph | Thêm một mục câu hỏi mới cho phép người trả lời nhập một khối văn bản. |
add | Form | Thêm người dùng đã cho vào danh sách người phản hồi cho Form. |
add | Form | Thêm người dùng đã cho vào danh sách người phản hồi cho Form. |
add | Form | Thêm mảng người dùng đã cho vào danh sách người phản hồi cho Form. |
add | Rating | Nối một mục câu hỏi mới cho phép người trả lời đưa ra điểm xếp hạng. |
add | Scale | Thêm một mục câu hỏi mới cho phép người trả lời chọn một lựa chọn trong một chuỗi nút chọn được đánh số. |
add | Section | Nối một mục bố cục mới cho biết trực quan điểm bắt đầu của một phần. |
add | Text | Thêm một mục câu hỏi mới cho phép người trả lời nhập một dòng văn bản. |
add | Time | Thêm một mục câu hỏi mới cho phép người trả lời cho biết thời gian trong ngày. |
add | Video | Nối một mục bố cục mới hiển thị video. |
can | Boolean | Xác định xem biểu mẫu có hiển thị đường liên kết để chỉnh sửa câu trả lời sau khi gửi hay không. |
collects | Boolean | Xác định xem biểu mẫu có thu thập địa chỉ email của người trả lời hay không. |
create | Form | Tạo một phản hồi mới cho biểu mẫu. |
delete | Form | Xoá tất cả câu trả lời đã gửi khỏi kho lưu trữ câu trả lời của biểu mẫu. |
delete | void | Xoá mục tại một chỉ mục nhất định trong số tất cả các mục trong biểu mẫu. |
delete | void | Xoá mục đã cho. |
delete | Form | Xoá một câu trả lời khỏi kho câu trả lời của biểu mẫu. |
get | String | Lấy thông báo xác nhận của biểu mẫu. |
get | String | Lấy thông báo tuỳ chỉnh sẽ xuất hiện nếu biểu mẫu không chấp nhận câu trả lời hoặc một chuỗi trống nếu không có thông báo tuỳ chỉnh nào được đặt. |
get | String | Lấy nội dung mô tả của biểu mẫu. |
get | String | Lấy mã nhận dạng của đích đến phản hồi của biểu mẫu. |
get | Destination | Lấy loại đích trả lời của biểu mẫu. |
get | String | Lấy URL có thể dùng để truy cập vào chế độ chỉnh sửa của biểu mẫu. |
get | User[] | Lấy danh sách người chỉnh sửa cho Form này. |
get | String | Lấy mã nhận dạng của biểu mẫu. |
get | Item|null | Lấy mục có mã nhận dạng nhất định. |
get | Item[] | Lấy một mảng gồm tất cả các mục trong biểu mẫu. |
get | Item[] | Lấy một mảng gồm tất cả các mục thuộc một loại nhất định. |
get | User[] | Lấy danh sách người trả lời cho Form này. |
get | String | Lấy URL có thể dùng để trả lời biểu mẫu. |
get | Form | Lấy một câu trả lời biểu mẫu duy nhất dựa trên mã nhận dạng câu trả lời. |
get | Form | Nhận một mảng gồm tất cả câu trả lời của biểu mẫu. |
get | Form | Lấy một mảng gồm tất cả các câu trả lời của biểu mẫu sau một ngày và giờ nhất định. |
get | Boolean | Xác định xem thứ tự của các câu hỏi trên mỗi trang của biểu mẫu có được sắp xếp ngẫu nhiên hay không. |
get | String | Lấy URL có thể dùng để xem bản tóm tắt các câu trả lời của biểu mẫu. |
get | String | Lấy tiêu đề của biểu mẫu. |
has | Boolean | Xác định xem biểu mẫu có chỉ cho phép một câu trả lời cho mỗi người trả lời hay không. |
has | Boolean | Xác định xem biểu mẫu có hiển thị thanh tiến trình hay không. |
has | Boolean | Xác định xem biểu mẫu có hiển thị đường liên kết để gửi câu trả lời khác sau khi người trả lời hoàn tất biểu mẫu hay không. |
is | Boolean | Xác định xem biểu mẫu hiện có chấp nhận câu trả lời hay không. |
is | Boolean | Xác định xem biểu mẫu có được xuất bản hay không. |
is | Boolean | Xác định xem biểu mẫu có hiển thị đường liên kết để xem bản tóm tắt câu trả lời sau khi người trả lời hoàn tất biểu mẫu hay không. |
is | Boolean | Xác định xem biểu mẫu có phải là bài kiểm tra hay không. |
move | Item | Di chuyển một mục tại một chỉ mục nhất định trong số tất cả các mục trong biểu mẫu đến một chỉ mục nhất định khác. |
move | Item | Di chuyển một mục nhất định đến một chỉ mục nhất định trong số tất cả các mục trong biểu mẫu. |
remove | Form | Huỷ liên kết biểu mẫu với đích trả lời hiện tại. |
remove | Form | Xoá người dùng đã cho khỏi danh sách người chỉnh sửa của Form. |
remove | Form | Xoá người dùng đã cho khỏi danh sách người chỉnh sửa của Form. |
remove | Form | Xoá người dùng đã cho khỏi danh sách người phản hồi cho Form. |
remove | Form | Xoá người dùng đã cho khỏi danh sách người phản hồi cho Form. |
set | Form | Đặt xem biểu mẫu hiện có chấp nhận câu trả lời hay không. |
set | Form | Đặt xem biểu mẫu có hiển thị đường liên kết để chỉnh sửa câu trả lời sau khi gửi hay không. |
set | Form | Đặt xem biểu mẫu có thu thập địa chỉ email của người trả lời hay không. |
set | Form | Đặt thông báo xác nhận của biểu mẫu. |
set | Form | Đặt thông báo sẽ xuất hiện nếu biểu mẫu không chấp nhận câu trả lời. |
set | Form | Đặt nội dung mô tả của biểu mẫu. |
set | Form | Đặt đích đến nơi lưu câu trả lời của biểu mẫu. |
set | Form | Đặt xem biểu mẫu có phải là bài kiểm tra hay không. |
set | Form | Đặt xem biểu mẫu chỉ cho phép một câu trả lời cho mỗi người trả lời hay không. |
set | Form | Đặt xem biểu mẫu có thanh tiến trình hay không. |
set | Form | Đặt xem biểu mẫu có được xuất bản hay không. |
set | Form | Đặt xem biểu mẫu có hiển thị đường liên kết để xem bản tóm tắt câu trả lời sau khi người trả lời gửi biểu mẫu hay không. |
set | Form | Đặt xem biểu mẫu có hiển thị đường liên kết để gửi câu trả lời khác sau khi người trả lời hoàn tất biểu mẫu hay không. |
set | Form | Đặt xem thứ tự của các câu hỏi trên mỗi trang của biểu mẫu có được sắp xếp ngẫu nhiên hay không. |
set | Form | Đặt tiêu đề cho biểu mẫu. |
shorten | String | Chuyển đổi URL dài của một biểu mẫu thành URL ngắn. |
submit | Form | Gửi điểm cho FormResponse đã cho. |
supports | Boolean | Xác định xem biểu mẫu có hỗ trợ việc xuất bản hay không. |
Tài liệu chi tiết
addCheckboxGridItem()
Nối một mục câu hỏi mới, được trình bày dưới dạng một lưới gồm các cột và hàng, cho phép người trả lời chọn nhiều lựa chọn cho mỗi hàng trong một chuỗi hộp đánh dấu.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a checkbox grid item. const item = form.addCheckboxGridItem(); item.setTitle('Where did you celebrate New Year\'s?'); // Sets the grid's rows and columns. item.setRows(['New York', 'San Francisco', 'London']).setColumns([ '2014', '2015', '2016', '2017' ]);
Cầu thủ trả bóng
CheckboxGridItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addCheckboxItem()
Thêm một mục câu hỏi mới cho phép người trả lời chọn một hoặc nhiều hộp đánh dấu, cũng như trường "khác" (không bắt buộc).
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a checkbox item. const item = form.addCheckboxItem(); // Sets the title of the checkbox item to 'Do you prefer cats or dogs?' item.setTitle('Do you prefer cats or dogs?'); // Sets the choices. item.setChoiceValues(['Cats', 'Dogs']);
Cầu thủ trả bóng
CheckboxItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addDateItem()
Thêm một mục câu hỏi mới cho phép người trả lời chỉ định một ngày.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a date item. const item = form.addDateItem(); // Sets the title to 'When were you born?' item.setTitle('When were you born?'); // Sets the description for the date item. item.setHelpText('Some helper text.');
Cầu thủ trả bóng
DateItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addDateTimeItem()
Thêm một mục câu hỏi mới cho phép người trả lời chỉ định ngày và giờ.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a question with date and time inputs. const item = form.addDateTimeItem(); // Sets the title to 'When were you born?' item.setTitle('When were you born?'); // Sets the question as required. item.setRequired(true);
Cầu thủ trả bóng
DateTimeItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addDurationItem()
Thêm một mục câu hỏi mới cho phép người trả lời cho biết khoảng thời gian.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a question with a duration input. const item = form.addDurationItem(); // Sets the title to 'How long can you hold your breath?' item.setTitle('How long can you hold your breath?'); // Sets the question as required. item.setRequired(true);
Cầu thủ trả bóng
DurationItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addEditor(emailAddress)
Thêm người dùng đã cho vào danh sách người chỉnh sửa cho Form. Nếu người dùng đã có trong danh sách người xem hoặc người phản hồi, thì phương thức này sẽ loại người dùng đó ra khỏi danh sách.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds editor to the form. // TODO(developer): replace the emailAddress. form.addEditor('editor@uni.edu');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
email | String | Địa chỉ email của người dùng cần thêm. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addEditor(user)
Thêm người dùng đã cho vào danh sách người chỉnh sửa cho Form. Nếu người dùng đã có trong danh sách người xem hoặc người phản hồi, thì phương thức này sẽ loại người dùng đó ra khỏi danh sách.
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the editors from the old form. const users = oldForm.getEditors(); // Creates a new form. const newForm = FormApp.create('New form'); // Adds the editors to a new form. users.forEach(user => newForm.addEditor(user));
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
user | User | Thông tin về người dùng cần thêm. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addEditors(emailAddresses)
Thêm mảng người dùng đã cho vào danh sách người chỉnh sửa cho Form. Nếu bất kỳ người dùng nào đã có trong danh sách người xem, phương thức này sẽ loại bỏ họ khỏi danh sách người xem.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds editors to the form. // TODO(developer): replace the emailAddress. form.addPublishedReaders(['editor1@uni.edu', 'editor2@uni.edu']);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
email | String[] | Một mảng gồm địa chỉ email của những người dùng cần thêm. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addGridItem()
Thêm một mục câu hỏi mới, được trình bày dưới dạng một lưới gồm các cột và hàng, cho phép người trả lời chọn một lựa chọn cho mỗi hàng trong một chuỗi nút chọn.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a multiple choice grid. const item = form.addGridItem(); // Sets the title to 'Rate your interests.' item.setTitle('Rate your interests'); // Sets the grid's rows and columns. item.setRows(['Cars', 'Computers', 'Celebrities']).setColumns([ 'Boring', 'So-so', 'Interesting' ]);
Cầu thủ trả bóng
GridItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addImageItem()
Nối một mục bố cục mới hiển thị hình ảnh.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds an image item. const item = form.addImageItem(); // Gets the Google icon to use as the image. const img = UrlFetchApp.fetch( 'https://fonts.gstatic.com/s/i/productlogos/googleg/v6/web-24dp/logo_googleg_color_1x_web_24dp.png', ); // Sets the image, title, and description for the item. item.setTitle('Google icon').setHelpText('Google icon').setImage(img);
Cầu thủ trả bóng
ImageItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addListItem()
Thêm một mục câu hỏi mới cho phép người trả lời chọn một lựa chọn trong danh sách thả xuống.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a dropdown list to the form. const item = form.addListItem(); // Sets the title to 'Do you prefer cats or dogs?' item.setTitle('Do you prefer cats or dogs?'); // Sets the description to 'This is description text...' item.setHelpText('This is description text...'); // Creates and adds choices to the dropdown list. item.setChoices([item.createChoice('dog'), item.createChoice('cat')]);
Cầu thủ trả bóng
ListItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addMultipleChoiceItem()
Thêm một mục câu hỏi mới cho phép người trả lời chọn một lựa chọn trong danh sách nút chọn hoặc một trường "khác" không bắt buộc.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a multiple choice item to the form. const item = form.addMultipleChoiceItem(); // Sets the title. item.setTitle('What is your favorite ice cream flavor?'); // Creates some choice items. const vanilla = item.createChoice('vanilla'); const chocolate = item.createChoice('chocolate'); const strawberry = item.createChoice('strawberry'); // Sets the choices. item.setChoices([vanilla, chocolate, strawberry]);
Cầu thủ trả bóng
MultipleChoiceItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addPageBreakItem()
Thêm một mục bố cục mới đánh dấu điểm bắt đầu của một trang.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds page break items to create a second and third page for the form. const pageTwo = form.addPageBreakItem(); const pageThree = form.addPageBreakItem(); // Sets the titles for the pages. pageTwo.setTitle('Page two'); pageThree.setTitle('Page three'); // Upon completion of the first page, sets the form to navigate to the third // page. pageTwo.setGoToPage(pageThree); // Upon completion of the second page, sets the form to navigate back to the // first page. pageThree.setGoToPage(FormApp.PageNavigationType.RESTART);
Cầu thủ trả bóng
PageBreakItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addParagraphTextItem()
Thêm một mục câu hỏi mới cho phép người trả lời nhập một khối văn bản.
// Opens the form by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds the paragraph text item. const item = form.addParagraphTextItem(); // Sets the title to 'What is your address?' item.setTitle('What is your address?');
Cầu thủ trả bóng
ParagraphTextItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addPublishedReader(emailAddress)
Thêm người dùng đã cho vào danh sách người phản hồi cho Form. Nếu người dùng đã có trong danh sách người chỉnh sửa hoặc người xem, thì phương thức này sẽ không có hiệu lực.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds responder to the form. // TODO(developer): replace the emailAddress. form.addPublishedReader('responder@uni.edu');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
email | String | Địa chỉ email của người dùng cần thêm. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addPublishedReader(user)
Thêm người dùng đã cho vào danh sách người phản hồi cho Form. Nếu người dùng đã có trong danh sách người chỉnh sửa hoặc người xem, thì phương thức này sẽ không có hiệu lực.
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the responders from the old form. const users = oldForm.getPublishedReaders(); // Creates a new form. const newForm = FormApp.create('New form'); // Adds the responders to a new form. users.forEach(user => newForm.addPublishedReader(user));
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
user | User | Thông tin về người dùng cần thêm. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addPublishedReaders(emailAddresses)
Thêm mảng người dùng đã cho vào danh sách người phản hồi cho Form. Nếu người dùng đã có trong danh sách người chỉnh sửa hoặc người xem, thì phương thức này sẽ không có hiệu lực.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds responders to the form. // TODO(developer): replace the emailAddress. form.addPublishedReaders(['responder1@uni.edu', 'responder2@uni.edu']);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
email | String[] | Một mảng gồm địa chỉ email của những người dùng cần thêm. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addRatingItem()
Nối một mục câu hỏi mới cho phép người trả lời đưa ra điểm xếp hạng.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds the rating item. const item = form.addRatingItem();
Cầu thủ trả bóng
RatingItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addScaleItem()
Thêm một mục câu hỏi mới cho phép người trả lời chọn một lựa chọn trong một chuỗi nút chọn được đánh số.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds the scale item. const item = form.addScaleItem(); // Sets the title of the scale item to 'Choose a number.' item.setTitle('Choose a number'); // Sets the scale to 1-5. item.setBounds(1, 5); // Sets the label for the lower and upper bounds. item.setLabels('Lowest', 'Highest');
Cầu thủ trả bóng
ScaleItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addSectionHeaderItem()
Nối một mục bố cục mới cho biết trực quan điểm bắt đầu của một phần.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds the section heading item. const item = form.addSectionHeaderItem(); // Sets the title to 'Title of new section.' item.setTitle('Title of new section'); // Sets the description. item.setHelpText('Description of new section');
Cầu thủ trả bóng
SectionHeaderItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addTextItem()
Thêm một mục câu hỏi mới cho phép người trả lời nhập một dòng văn bản.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a single-line text item. const item = form.addTextItem(); // Sets the title to 'What is your name?' item.setTitle('What is your name?');
Cầu thủ trả bóng
TextItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addTimeItem()
Thêm một mục câu hỏi mới cho phép người trả lời cho biết thời gian trong ngày.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a question with a time input. const item = form.addTimeItem(); // Sets the title to 'What time do you usually wake up in the morning?' item.setTitle('What time do you usually wake up in the morning?');
Cầu thủ trả bóng
TimeItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
addVideoItem()
Nối một mục bố cục mới hiển thị video.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Adds a video item. const item = form.addVideoItem(); // Sets the title, description, and video. item.setTitle('YouTube video') .setHelpText('Send content automatically via Google Sheets and Apps Script') .setVideoUrl('https://youtu.be/xxgQr-jSu9o'); // Sets the alignment to the center. item.setAlignment(FormApp.Alignment.CENTER);
Cầu thủ trả bóng
VideoItem – Mục mới tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
canEditResponse()
Xác định xem biểu mẫu có hiển thị đường liên kết để chỉnh sửa câu trả lời sau khi gửi hay không.
Bất kể chế độ cài đặt này, phương thức FormResponse.getEditResponseUrl() cho phép tác giả tập lệnh có quyền chỉnh sửa biểu mẫu tạo một URL có thể dùng để chỉnh sửa phản hồi.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Checks if the form displays a link to edit a response after submitting it. // The default is false. To let people edit their responses, use // form.setAllowResponseEdits(true). const edit = form.canEditResponse(); // If the form doesn't let people edit responses, logs false to the console. console.log(edit);
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu có đường liên kết "Chỉnh sửa câu trả lời của bạn"; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
collectsEmail()
Xác định xem biểu mẫu có thu thập địa chỉ email của người trả lời hay không.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form to not collect respondents' email addresses. form.setCollectEmail(false); // Checks whether the form collects respondents' email addresses and logs it to // the console. const bool = form.collectsEmail(); console.log(bool);
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu thu thập địa chỉ email; false nếu biểu mẫu không thu thập địa chỉ email.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
createResponse()
Tạo một phản hồi mới cho biểu mẫu. Để trả lời một mục câu hỏi, hãy tạo ItemResponse từ mục đó, sau đó đính kèm vào câu trả lời biểu mẫu này bằng cách gọi FormResponse.withItemResponse(response). Để lưu câu trả lời đã được tổng hợp, hãy gọi FormResponse.submit().
Cầu thủ trả bóng
FormResponse – Câu trả lời biểu mẫu mới được tạo.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
deleteAllResponses()
Xoá tất cả câu trả lời đã gửi khỏi kho lưu trữ câu trả lời của biểu mẫu. Phương thức này không xoá các bản sao của câu trả lời được lưu trữ trong một đích đến phản hồi bên ngoài (chẳng hạn như bảng tính), nhưng sẽ xoá chế độ xem tóm tắt của biểu mẫu.
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
deleteItem(index)
Xoá mục tại một chỉ mục nhất định trong số tất cả các mục trong biểu mẫu. Gây ra một ngoại lệ về tập lệnh nếu không có mục nào tại chỉ mục đã cho.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets all the items from the form. const items = form.getItems(); // Finds the index of a paragraph text item and deletes it by the item's index. const index = items.findIndex( (item) => item.getType() === FormApp.ItemType.PARAGRAPH_TEXT, ); if (index !== -1) { form.deleteItem(index); }
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
index | Integer | Chỉ mục của mục trong số tất cả các mục trong biểu mẫu. |
Gửi
Error – nếu không có mục nào ở chỉ mục đã cho
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
deleteItem(item)
Xoá mục đã cho. Gửi một ngoại lệ về tập lệnh nếu mục đã bị xoá.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets all of the items from the form. const items = form.getItems(); // Finds a paragraph text item and deletes it. const item = items.find( (item) => item.getType() === FormApp.ItemType.PARAGRAPH_TEXT, ); if (item) { form.deleteItem(item); }
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
item | Item | Mục cần xoá. |
Gửi
Error – nếu mặt hàng không tồn tại trong biểu mẫu
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
deleteResponse(responseId)
Xoá một câu trả lời khỏi kho câu trả lời của biểu mẫu. Phương thức này không xoá các bản sao của câu trả lời được lưu trữ trong một đích đến câu trả lời bên ngoài (chẳng hạn như bảng tính), nhưng sẽ xoá câu trả lời khỏi chế độ xem tóm tắt của biểu mẫu. Bạn có thể truy xuất mã phản hồi bằng FormResponse.getId().
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
response | String | Mã nhận dạng của câu trả lời biểu mẫu cần xoá. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getConfirmationMessage()
Lấy thông báo xác nhận của biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the confirmation message to display after someone submits the form. form.setConfirmationMessage('You successfully submitted the form.'); // Gets the confirmation message and logs it to the console. const message = form.getConfirmationMessage(); console.log(message);
Cầu thủ trả bóng
String – Thông báo xác nhận của biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getCustomClosedFormMessage()
Lấy thông báo tuỳ chỉnh sẽ xuất hiện nếu biểu mẫu không chấp nhận câu trả lời hoặc một chuỗi trống nếu không có thông báo tuỳ chỉnh nào được đặt.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets a custom closed form message to display to the user when the form // no longer accepts responses. form.setCustomClosedFormMessage('The form is no longer accepting responses.'); // Gets the custom message set for the form and logs it to the console. const message = form.getCustomClosedFormMessage(); console.log(message);
Cầu thủ trả bóng
String – Thông báo tuỳ chỉnh sẽ xuất hiện nếu biểu mẫu không chấp nhận câu trả lời hoặc một chuỗi trống nếu bạn không đặt thông báo tuỳ chỉnh.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getDescription()
Lấy nội dung mô tả của biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form description. form.setDescription('This is the form description.'); // Gets the form description and logs it to the console. const description = form.getDescription(); console.log(description);
Cầu thủ trả bóng
String – Nội dung mô tả của biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getDestinationId()
Lấy mã nhận dạng của đích đến phản hồi của biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Creates a spreadsheet to use as the response destination. const ss = SpreadsheetApp.create('Test_Spreadsheet'); // Updates the form's response destination. form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId()); // Gets the ID of the form's response destination and logs it to the console. const destinationId = form.getDestinationId(); console.log(destinationId);
Cầu thủ trả bóng
String – Mã nhận dạng của đích đến phản hồi của biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getDestinationType()
Lấy loại đích trả lời của biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc1234556/edit', ); // Gets the type of the form's response destination and logs it to the console. const destinationType = form.getDestinationType().name(); console.log(destinationType);
Cầu thủ trả bóng
DestinationType – Loại đích trả lời của biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getEditUrl()
Lấy URL có thể dùng để truy cập vào chế độ chỉnh sửa của biểu mẫu.
// Opens the form by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets the URL that accesses the form's edit mode and logs it to the console. const url = form.getEditUrl(); console.log(url);
Cầu thủ trả bóng
String – URL để chỉnh sửa biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getEditors()
getId()
Lấy mã nhận dạng của biểu mẫu.
// Opens the form by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets the ID of the form and logs it to the console. const id = form.getId(); console.log(id);
Cầu thủ trả bóng
String – Mã nhận dạng của biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getItemById(id)
Lấy mục có mã nhận dạng nhất định. Trả về null nếu mã nhận dạng không tương ứng với một mục trong biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets the ID of the first item on the form. const itemId = form.getItems()[0].getId(); // Gets the item from the ID. const item = form.getItemById(itemId); // Gets the name of the item type and logs it to the console. const type = item.getType().name(); console.log(type);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
id | Integer | Mã nhận dạng của mặt hàng. |
Cầu thủ trả bóng
Item|null – Mục có mã nhận dạng đã cho hoặc null nếu mục đó không tồn tại trong biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getItems()
Lấy một mảng gồm tất cả các mục trong biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets the list of items in the form. const items = form.getItems(); // Gets the type for each item and logs them to the console. const types = items.map((item) => item.getType().name()); console.log(types);
Cầu thủ trả bóng
Item[] – Một mảng gồm tất cả các mục trong biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getItems(itemType)
Lấy một mảng gồm tất cả các mục thuộc một loại nhất định.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets a list of all checkbox items on the form. const items = form.getItems(FormApp.ItemType.CHECKBOX); // Gets the title of each checkbox item and logs them to the console. const checkboxItemsTitle = items.map( (item) => item.asCheckboxItem().getTitle(), ); console.log(checkboxItemsTitle);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
item | Item | Loại mặt hàng cần truy xuất. |
Cầu thủ trả bóng
Item[] – Một mảng gồm tất cả các mục thuộc loại đó.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getPublishedReaders()
Lấy danh sách người trả lời cho Form này.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the responders for the form. const users = form.getPublishedReaders(); users.forEach(user => console.log(user.getEmail()));
Cầu thủ trả bóng
User[] – Một mảng người dùng có quyền phản hồi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getPublishedUrl()
Lấy URL có thể dùng để trả lời biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets the URL to respond to the form and logs it to the console. const url = form.getPublishedUrl(); console.log(url);
Cầu thủ trả bóng
String – URL để trả lời biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getResponse(responseId)
Lấy một câu trả lời biểu mẫu duy nhất dựa trên mã nhận dạng câu trả lời. Bạn có thể truy xuất mã nhận dạng phản hồi từ FormResponse.getId().
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
response | String | Mã nhận dạng của câu trả lời biểu mẫu. |
Cầu thủ trả bóng
FormResponse – Câu trả lời biểu mẫu.
Gửi
Error – nếu không có câu trả lời
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getResponses()
Nhận một mảng gồm tất cả câu trả lời của biểu mẫu.
Cầu thủ trả bóng
FormResponse[] – Một mảng gồm tất cả câu trả lời của biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getResponses(timestamp)
Lấy một mảng gồm tất cả các câu trả lời của biểu mẫu sau một ngày và giờ nhất định.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
timestamp | Date | Ngày và giờ sớm nhất mà câu trả lời qua biểu mẫu sẽ được trả về. |
Cầu thủ trả bóng
FormResponse[] – Danh sách câu trả lời trong biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getShuffleQuestions()
Xác định xem thứ tự của các câu hỏi trên mỗi trang của biểu mẫu có được sắp xếp ngẫu nhiên hay không.
Cầu thủ trả bóng
Boolean – true nếu thứ tự của các câu hỏi trên mỗi trang của biểu mẫu được sắp xếp ngẫu nhiên;false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getSummaryUrl()
Lấy URL có thể dùng để xem bản tóm tắt các câu trả lời của biểu mẫu. Trừ phi bạn đặt setPublishingSummary(enabled) thành true, nếu không thì chỉ những người dùng có quyền chỉnh sửa biểu mẫu mới có thể truy cập vào URL.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // Opens the form by its URL. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets the URL to view a summary of the form's responses and logs it to the // console. const url = form.getSummaryUrl(); console.log(url);
Cầu thủ trả bóng
String – URL để xem bản tóm tắt câu trả lời.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getTitle()
Lấy tiêu đề của biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the title of the form to 'For_Testing.' form.setTitle('For_Testing'); // Gets the title of the form and logs it to the console. const title = form.getTitle(); console.log(title);
Cầu thủ trả bóng
String – Tiêu đề của biểu mẫu.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
hasLimitOneResponsePerUser()
Xác định xem biểu mẫu có chỉ cho phép một câu trả lời cho mỗi người trả lời hay không. Nếu giá trị là true, thì tập lệnh hoàn toàn không thể gửi câu trả lời biểu mẫu.
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu chỉ cho phép mỗi người trả lời gửi một phản hồi; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
hasProgressBar()
Xác định xem biểu mẫu có hiển thị thanh tiến trình hay không.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // Opens the form by its URL. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Displays the progress bar on the form. form.setProgressBar(true); // Checks if the form displays a progress bar and logs it to the console. console.log(form.hasProgressBar());
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu có thanh tiến trình; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
hasRespondAgainLink()
Xác định xem biểu mẫu có hiển thị đường liên kết để gửi câu trả lời khác sau khi người trả lời hoàn tất biểu mẫu hay không.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form to display a link to submit another // response after someone submits the form. form.setShowLinkToRespondAgain(true); // Checks if the form displays a 'Submit another response' link and logs it to // the console. console.log(form.hasRespondAgainLink());
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu có đường liên kết "Gửi câu trả lời khác"; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
isAcceptingResponses()
Xác định xem biểu mẫu hiện có chấp nhận câu trả lời hay không. Trạng thái này sẽ bị ghi đè khi trạng thái xuất bản của biểu mẫu thay đổi.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form to accept responses. form.setAcceptingResponses(true); // Checks if the form is accepting responses or not and logs it to the console. const accepting = form.isAcceptingResponses(); console.log(accepting);
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu chấp nhận câu trả lời; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
isPublished()
Xác định xem biểu mẫu có được xuất bản hay không.
Tính năng này chỉ dành cho những biểu mẫu hỗ trợ việc xuất bản. Dùng supportsAdvancedResponderPermissions() để kiểm tra xem biểu mẫu có hỗ trợ việc xuất bản hay không.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Checks whether the form is published or not and logs it to the console. console.log(form.isPublished());
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu được xuất bản; false nếu biểu mẫu không được xuất bản.
Gửi
Error – nếu được gọi trên các biểu mẫu không được hỗ trợ.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
isPublishingSummary()
Xác định xem biểu mẫu có hiển thị đường liên kết để xem bản tóm tắt câu trả lời sau khi người trả lời hoàn tất biểu mẫu hay không.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form to display a link to a summary of // the responses after someone submits the form. form.setPublishingSummary(true); // Checks if the form displays a "See previous responses" link and logs it to // the console. const publishingLink = form.isPublishingSummary(); console.log(publishingLink);
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu có đường liên kết "Xem câu trả lời trước"; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
isQuiz()
Xác định xem biểu mẫu có phải là bài kiểm tra hay không.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form as a quiz. form.setIsQuiz(true); // Checks if the form is a quiz or not and logs it to the console. console.log(form.isQuiz());
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu chấp nhận câu trả lời; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
moveItem(from, to)
Di chuyển một mục tại một chỉ mục nhất định trong số tất cả các mục trong biểu mẫu đến một chỉ mục nhất định khác. Đưa ra một ngoại lệ kịch bản nếu chỉ mục to nằm ngoài giới hạn.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Moves the first item to be the last item. form.moveItem(0, form.getItems().length - 1);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
from | Integer | Chỉ mục hiện tại của mục trong số tất cả các mục trong biểu mẫu. |
to | Integer | Chỉ mục mới của mục trong số tất cả các mục trong biểu mẫu. |
Cầu thủ trả bóng
Item – Mục đã được di chuyển.
Gửi
Error – nếu một trong hai chỉ mục nằm ngoài phạm vi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
moveItem(item, toIndex)
Di chuyển một mục nhất định đến một chỉ mục nhất định trong số tất cả các mục trong biểu mẫu. Gửi một ngoại lệ kịch bản nếu chỉ mục đã cho nằm ngoài giới hạn.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Gets the first item. const item = form.getItems()[0]; // Moves the item to be the last item. form.moveItem(item, form.getItems().length - 1);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
item | Item | Mục cần di chuyển. |
to | Integer | Chỉ mục mới của mục trong số tất cả các mục trong biểu mẫu. |
Cầu thủ trả bóng
Item – Mục đã được di chuyển.
Gửi
Error – nếu chỉ mục nằm ngoài phạm vi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
removeDestination()
Huỷ liên kết biểu mẫu với đích trả lời hiện tại. Đích đến cũ đã huỷ liên kết vẫn giữ lại bản sao của tất cả các phản hồi trước đó. Tất cả biểu mẫu, kể cả những biểu mẫu không có đích đến được đặt rõ ràng, đều lưu một bản sao của câu trả lời trong kho lưu trữ câu trả lời của biểu mẫu. Nếu biểu mẫu hiện không có đích trả lời, thì phương thức này sẽ không có hiệu lực.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Opens a spreadsheet to use for the response destination. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Updates the form's response destination to the spreadsheet. form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId()); // Unlinks the form from the spreadsheet. form.removeDestination();
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
removeEditor(emailAddress)
Xoá người dùng đã cho khỏi danh sách người chỉnh sửa của Form. Phương thức này không chặn người dùng truy cập vào Form nếu họ thuộc một nhóm người dùng có quyền truy cập chung – ví dụ: nếu Form được chia sẻ với toàn bộ miền của người dùng hoặc nếu Form nằm trong một bộ nhớ dùng chung mà người dùng có thể truy cập.
Đối với tệp trên Drive, thao tác này cũng sẽ xoá người dùng khỏi danh sách người xem và người phản hồi.
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Removes the editor from the form. // TODO(developer): replace the emailAddress. form.removeEditor('editor@uni.edu');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
email | String | Địa chỉ email của người dùng cần xoá. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
removeEditor(user)
Xoá người dùng đã cho khỏi danh sách người chỉnh sửa của Form. Phương thức này không chặn người dùng truy cập vào Form nếu họ thuộc một nhóm người dùng có quyền truy cập chung – ví dụ: nếu Form được chia sẻ với toàn bộ miền của người dùng hoặc nếu Form nằm trong một bộ nhớ dùng chung mà người dùng có thể truy cập.
Đối với tệp trên Drive, thao tác này cũng sẽ xoá người dùng khỏi danh sách người xem.
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the editors from the form. const users = form1.getEditors(); // Opens another form. // TODO(developer): Replace the URL with your own. const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit'); // Removes editors from the form. users.forEach(user => form2.removeEditor(user));
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
user | User | Thông tin về người dùng cần xoá. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
removePublishedReader(emailAddress)
Xoá người dùng đã cho khỏi danh sách người phản hồi cho Form. Phương thức này không chặn người dùng truy cập vào Form nếu họ thuộc một nhóm người dùng có quyền truy cập chung – ví dụ: nếu Form được chia sẻ với toàn bộ miền của người dùng hoặc nếu Form nằm trong một bộ nhớ dùng chung mà người dùng có thể truy cập.
Đối với tệp trên Drive, thao tác này cũng sẽ xoá người dùng khỏi danh sách người xem và người chỉnh sửa.
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Removes the responders from the form. // TODO(developer): replace the emailAddress. form.removePublishedReader('responder1@uni.edu');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
email | String | Địa chỉ email của người dùng cần xoá. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
removePublishedReader(user)
Xoá người dùng đã cho khỏi danh sách người phản hồi cho Form. Phương thức này không chặn người dùng truy cập vào Form nếu họ thuộc một nhóm người dùng có quyền truy cập chung – ví dụ: nếu Form được chia sẻ với toàn bộ miền của người dùng hoặc nếu Form nằm trong một bộ nhớ dùng chung mà người dùng có thể truy cập.
Đối với tệp trên Drive, thao tác này cũng sẽ xoá người dùng khỏi danh sách người xem và người chỉnh sửa.
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the responders from the form. const users = form1.getPublishedReaders(); // Opens another form. // TODO(developer): Replace the URL with your own. const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit'); // Removes responders from the form. users.forEach(user => form2.removePublishedReader(user));
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
user | User | Thông tin về người dùng cần xoá. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setAcceptingResponses(enabled)
Đặt xem biểu mẫu hiện có chấp nhận câu trả lời hay không. Chế độ mặc định cho biểu mẫu mới là true. Trạng thái này sẽ bị ghi đè khi trạng thái xuất bản của biểu mẫu thay đổi.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form to accept responses. form.setAcceptingResponses(true); // Checks whether the form is accepting responses or not and logs it to the // console. console.log(form.isAcceptingResponses());
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu biểu mẫu chấp nhận câu trả lời; false nếu biểu mẫu không chấp nhận câu trả lời. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Gửi
Error – nếu được bật trên một biểu mẫu chưa được xuất bản.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setAllowResponseEdits(enabled)
Đặt xem biểu mẫu có hiển thị đường liên kết để chỉnh sửa câu trả lời sau khi gửi hay không. Giá trị mặc định cho biểu mẫu mới là false.
Bất kể chế độ cài đặt này, phương thức FormResponse.getEditResponseUrl() cho phép tác giả tập lệnh có quyền chỉnh sửa biểu mẫu tạo một URL có thể dùng để chỉnh sửa câu trả lời.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Shows "Edit your response" link after someone submits the form. form.setAllowResponseEdits(true); // Checks whether the option to edit the form after a user submits it is set to // true or not and logs it to the console. console.log(form.canEditResponse());
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu biểu mẫu sẽ hiển thị đường liên kết "Chỉnh sửa câu trả lời của bạn"; false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setCollectEmail(collect)
Đặt xem biểu mẫu có thu thập địa chỉ email của người trả lời hay không. Chế độ mặc định cho biểu mẫu mới là false.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form to collect respondents' email addresses. form.setCollectEmail(true); // Checks whether the value is set to true or false and logs it to the console. const collect = form.collectsEmail(); console.log(collect);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
collect | Boolean | true nếu biểu mẫu phải thu thập địa chỉ email; false nếu biểu mẫu không thu thập địa chỉ email. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setConfirmationMessage(message)
Đặt thông báo xác nhận của biểu mẫu.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets a custom confirmation message to display after someone submits the form. form.setConfirmationMessage('Your form has been successfully submitted.'); // Gets the confirmation message set for the form and logs it to the console. const message = form.getConfirmationMessage(); console.log(message);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
message | String | Thông báo xác nhận mới của biểu mẫu. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setCustomClosedFormMessage(message)
Đặt thông báo sẽ xuất hiện nếu biểu mẫu không chấp nhận câu trả lời. Nếu bạn không đặt thông báo, biểu mẫu sẽ sử dụng thông báo mặc định.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Sets the form to not accept responses. form.setAcceptingResponses(false); // Sets a custom closed form message to display to the user. form.setCustomClosedFormMessage('The form is no longer accepting responses.'); // Gets the custom message set for the form and logs it to the console. const message = form.getCustomClosedFormMessage(); console.log(message);
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
message | String | Thông báo sẽ xuất hiện nếu biểu mẫu không chấp nhận câu trả lời. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setDescription(description)
Đặt nội dung mô tả của biểu mẫu.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
description | String | Nội dung mô tả mới của biểu mẫu. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setDestination(type, id)
Đặt đích đến nơi lưu câu trả lời của biểu mẫu. Tất cả biểu mẫu, kể cả những biểu mẫu không có đích đến được đặt rõ ràng, đều lưu bản sao của câu trả lời trong kho lưu trữ câu trả lời của biểu mẫu.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
type | Destination | Loại đích đến của câu trả lời trong biểu mẫu. |
id | String | Mã nhận dạng của đích đến phản hồi của biểu mẫu. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Gửi
Error – nếu mã đích đến đã cho không hợp lệ
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setIsQuiz(enabled)
Đặt xem biểu mẫu có phải là bài kiểm tra hay không. Chế độ mặc định cho biểu mẫu mới là false.
Câu hỏi được chấm điểm chỉ được phép có trong Bài kiểm tra, vì vậy, việc đặt giá trị này thành false sẽ khiến tất cả các lựa chọn chấm điểm bị xoá khỏi tất cả các câu hỏi.
Chế độ cài đặt bài kiểm tra chỉ có trong giao diện người dùng mới của Biểu mẫu; việc chuyển một biểu mẫu thành Bài kiểm tra sẽ cho phép biểu mẫu sử dụng giao diện người dùng mới.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Makes the form a quiz. form.setIsQuiz(true); // Checks whether the form is a quiz or not and logs it to the console. console.log(form.isQuiz());
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu bạn muốn bật các tính năng của bài kiểm tra cho biểu mẫu; false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setLimitOneResponsePerUser(enabled)
Đặt xem biểu mẫu chỉ cho phép một câu trả lời cho mỗi người trả lời hay không. Chế độ mặc định cho biểu mẫu mới là false. Nếu bạn đặt giá trị thành true, thì tập lệnh sẽ không thể gửi phản hồi biểu mẫu.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu biểu mẫu chỉ cho phép mỗi người trả lời gửi một câu trả lời; false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setProgressBar(enabled)
Đặt xem biểu mẫu có thanh tiến trình hay không. Chế độ mặc định cho biểu mẫu mới là false.
// Opens the Forms file by its URL. If you created your script from within // a Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Displays the progress bar on the form. form.setProgressBar(true); // Checks whether the form has a progress bar and logs it to the console. console.log(form.hasProgressBar());
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu biểu mẫu có thanh tiến trình; false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setPublished(enabled)
Đặt xem biểu mẫu có được xuất bản hay không. Chế độ mặc định cho biểu mẫu mới là true.
Tính năng này chỉ dành cho những biểu mẫu hỗ trợ việc xuất bản. Dùng supportsAdvancedResponderPermissions() để kiểm tra xem biểu mẫu có hỗ trợ việc xuất bản hay không.
Bạn cần xuất bản biểu mẫu để người trả lời có thể truy cập vào biểu mẫu đó. Phương thức này thay thế các lệnh gọi đến setAcceptingResponses(enabled).
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Publishes the form before sharing it. form.setPublished(true); // Checks whether the form is published or not and logs it to the console. console.log(form.isPublished());
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu biểu mẫu nên được xuất bản, false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Gửi
Error – nếu được gọi trên các biểu mẫu không được hỗ trợ.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setPublishingSummary(enabled)
Đặt xem biểu mẫu có hiển thị đường liên kết để xem bản tóm tắt câu trả lời sau khi người trả lời gửi biểu mẫu hay không. Chế độ mặc định cho biểu mẫu mới là false.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu biểu mẫu sẽ hiển thị đường liên kết "Xem câu trả lời trước"; false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setShowLinkToRespondAgain(enabled)
Đặt xem biểu mẫu có hiển thị đường liên kết để gửi câu trả lời khác sau khi người trả lời hoàn tất biểu mẫu hay không. Chế độ mặc định cho biểu mẫu mới là true.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
enabled | Boolean | true nếu biểu mẫu sẽ hiển thị đường liên kết "Gửi câu trả lời khác"; false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setShuffleQuestions(shuffle)
Đặt xem thứ tự của các câu hỏi trên mỗi trang của biểu mẫu có được sắp xếp ngẫu nhiên hay không.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
shuffle | Boolean | true nếu thứ tự của các câu hỏi trên mỗi trang của biểu mẫu cần được sắp xếp ngẫu nhiên; false nếu không. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setTitle(title)
Đặt tiêu đề cho biểu mẫu.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
title | String | Tiêu đề mới của biểu mẫu. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
shortenFormUrl(url)
Chuyển đổi URL dài của một biểu mẫu thành URL ngắn. Gây ra một ngoại lệ nếu URL dài không thuộc về Google Biểu mẫu.
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
url | String | URL cần rút gọn. |
Cầu thủ trả bóng
String – Một URL có dạng http://goo.gl/forms/1234.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
submitGrades(responses)
Gửi điểm cho FormResponse đã cho.
Nếu mã của bạn có một trình kích hoạt onFormSubmit, thì việc gọi submitGrades() sẽ kích hoạt điều kiện onFormSubmit và gây ra một vòng lặp vô hạn. Để ngăn chặn vòng lặp vô hạn, hãy thêm mã kiểm tra xem điểm số đã tồn tại hay chưa trước khi gọi submitGrades().
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
responses | Form | Một mảng chứa tất cả câu trả lời của biểu mẫu. |
Cầu thủ trả bóng
Form – Form này dùng để xâu chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
supportsAdvancedResponderPermissions()
Xác định xem biểu mẫu có hỗ trợ việc xuất bản hay không. Phương thức này được dùng để xác định xem các phương thức setPublished(enabled) và isPublished(), cũng như quyền của người phản hồi có dùng được hay không.
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Checks whether the form supports publishing or not and logs it to the // console. console.log(form.supportsAdvancedResponderPermissions());
Cầu thủ trả bóng
Boolean – true nếu biểu mẫu hỗ trợ việc xuất bản; false nếu không.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được uỷ quyền bằng một hoặc nhiều phạm vi sau đây:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms