Formularz zawierający ogólne właściwości i elementy. Właściwości obejmują tytuł, ustawienia i miejsce przechowywania odpowiedzi. Elementy to pytania, takie jak pola wyboru czy opcje, a elementy układu odnoszą się do podziałów stron. Formularze można otwierać i tworzyć w FormApp
.
// Open a form by ID and create a new spreadsheet. var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); var 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());
Metody
Metoda | Zwracany typ | Krótki opis |
---|---|---|
addCheckboxGridItem() | CheckboxGridItem | Dodaje nowe pytanie, które jest prezentowane w formie siatki kolumn i wierszy, co umożliwia respondentom wybranie wielu opcji w każdym wierszu z sekwencji pól wyboru. |
addCheckboxItem() | CheckboxItem | Dodaje nowe pytanie, które pozwala respondentowi zaznaczyć jedno lub więcej pól wyboru, a także opcjonalne pole „inne”. |
addDateItem() | DateItem | Dodaje nowy element pytania, który umożliwia respondentowi wskazanie daty. |
addDateTimeItem() | DateTimeItem | Dodaje nowy element pytania, który umożliwia respondentowi wskazanie daty i godziny. |
addDurationItem() | DurationItem | Dodaje nowy element pytania, który pozwala respondentowi określić czas trwania. |
addEditor(emailAddress) | Form | Dodaje wskazanego użytkownika do listy edytorów w Form . |
addEditor(user) | Form | Dodaje wskazanego użytkownika do listy edytorów w Form . |
addEditors(emailAddresses) | Form | Dodaje podaną tablicę użytkowników do listy edytorów elementu Form . |
addGridItem() | GridItem | Dodaje nowe pytanie, przedstawione w postaci siatki kolumn i wierszy, co umożliwia respondentom wybranie w każdym wierszu jednej odpowiedzi z sekwencji przycisków. |
addImageItem() | ImageItem | Dodaje nowy element układu, który wyświetla obraz. |
addListItem() | ListItem | Dodaje nowe pytanie, które pozwala respondentowi wybrać jedną odpowiedź z listy. |
addMultipleChoiceItem() | MultipleChoiceItem | Dodaje nowe pytanie, które umożliwia respondentowi wybranie jednej opcji z listy przycisków lub opcjonalnego pola „inne”. |
addPageBreakItem() | PageBreakItem | Dodaje nowy element układu, który oznacza początek strony. |
addParagraphTextItem() | ParagraphTextItem | Dodaje nowy element pytania, który umożliwia użytkownikowi wpisanie bloku tekstu. |
addScaleItem() | ScaleItem | Dodaje nowy element pytania, który umożliwia respondentowi wybranie jednej opcji z sekwencji numerowanych przycisków opcji. |
addSectionHeaderItem() | SectionHeaderItem | Dodaje nowy element układu, który wizualnie wskazuje początek sekcji. |
addTextItem() | TextItem | Dodaje nowy element pytania, który umożliwia użytkownikowi wpisanie jednego wiersza tekstu. |
addTimeItem() | TimeItem | Dodaje nowe pytanie, które pozwala respondentowi określić porę dnia. |
addVideoItem() | VideoItem | Dodaje nowy element układu, który wyświetla film. |
canEditResponse() | Boolean | Określa, czy w formularzu wyświetlany jest link umożliwiający edytowanie odpowiedzi po jej przesłaniu. |
collectsEmail() | Boolean | Określa, czy formularz zbiera adresy e-mail użytkowników. |
createResponse() | FormResponse | Tworzy nową odpowiedź w formularzu. |
deleteAllResponses() | Form | Usuwa wszystkie przesłane odpowiedzi z magazynu odpowiedzi formularza. |
deleteItem(index) | void | Usuwa element o danym indeksie spośród wszystkich elementów formularza. |
deleteItem(item) | void | Usuwa dany element. |
deleteResponse(responseId) | Form | Usuwa pojedynczą odpowiedź z magazynu odpowiedzi formularza. |
getConfirmationMessage() | String | Pobiera komunikat z potwierdzeniem formularza. |
getCustomClosedFormMessage() | String | Pobiera komunikat niestandardowy, który jest wyświetlany, jeśli formularz nie przyjmuje odpowiedzi, lub pusty ciąg, jeśli nie ustawiono komunikatów niestandardowych. |
getDescription() | String | Pobiera opis formularza. |
getDestinationId() | String | Pobiera identyfikator miejsca docelowego odpowiedzi formularza. |
getDestinationType() | DestinationType | Pobiera typ miejsca docelowego odpowiedzi formularza. |
getEditUrl() | String | Pobiera adres URL, za pomocą którego można uzyskać dostęp do trybu edycji formularza. |
getEditors() | User[] | Pobiera listę edytorów tego elementu (Form ). |
getId() | String | Pobiera identyfikator formularza. |
getItemById(id) | Item | Pobiera element o podanym identyfikatorze. |
getItems() | Item[] | Pobiera tablicę ze wszystkimi elementami formularza. |
getItems(itemType) | Item[] | Pobiera tablicę ze wszystkimi elementami określonego typu. |
getPublishedUrl() | String | Pobiera adres URL, którego można użyć w odpowiedzi na formularz. |
getResponse(responseId) | FormResponse | Pobiera pojedynczą odpowiedź z formularza na podstawie identyfikatora odpowiedzi. |
getResponses() | FormResponse[] | Pobiera tablicę wszystkich odpowiedzi formularza. |
getResponses(timestamp) | FormResponse[] | Pobiera tablicę wszystkich odpowiedzi formularza po określonej dacie i godzinie. |
getShuffleQuestions() | Boolean | Określa, czy kolejność pytań na każdej stronie formularza jest losowa. |
getSummaryUrl() | String | Pobiera adres URL, którego można użyć do wyświetlenia podsumowania odpowiedzi z formularza. |
getTitle() | String | Pobiera tytuł formularza. |
hasLimitOneResponsePerUser() | Boolean | Określa, czy formularz może zawierać tylko 1 odpowiedź na użytkownika. |
hasProgressBar() | Boolean | Określa, czy w formularzu będzie wyświetlany pasek postępu. |
hasRespondAgainLink() | Boolean | Określa, czy po wypełnieniu formularza przez użytkownika wyświetla się link umożliwiający przesłanie kolejnej odpowiedzi. |
isAcceptingResponses() | Boolean | Określa, czy formularz przyjmuje obecnie odpowiedzi. |
isPublishingSummary() | Boolean | Określa, czy po wypełnieniu formularza przez użytkownika ma być wyświetlany link do podsumowania odpowiedzi. |
isQuiz() | Boolean | Określa, czy formularz jest quizem. |
moveItem(from, to) | Item | Przenosi element znajdujący się w danym indeksie wśród wszystkich elementów formularza do innego indeksu. |
moveItem(item, toIndex) | Item | Przenosi dany element do wskazanego indeksu wśród wszystkich elementów formularza. |
removeDestination() | Form | Odłącza formularz od bieżącego miejsca docelowego odpowiedzi. |
removeEditor(emailAddress) | Form | Usuwa danego użytkownika z listy edytorów Form . |
removeEditor(user) | Form | Usuwa danego użytkownika z listy edytorów Form . |
requiresLogin() | Boolean | Określa, czy przed wysłaniem odpowiedzi użytkownik musi zalogować się na konto w tej samej domenie czy w subdomenie. |
setAcceptingResponses(enabled) | Form | Określa, czy formularz przyjmuje obecnie odpowiedzi. |
setAllowResponseEdits(enabled) | Form | Określa, czy w formularzu wyświetlany jest link umożliwiający edytowanie odpowiedzi po jej przesłaniu. |
setCollectEmail(collect) | Form | Określa, czy formularz ma zbierać adresy e-mail użytkowników. |
setConfirmationMessage(message) | Form | Ustawia komunikat z potwierdzeniem formularza. |
setCustomClosedFormMessage(message) | Form | Powoduje, że komunikat będzie wyświetlany, gdy formularz nie przyjmuje odpowiedzi. |
setDescription(description) | Form | Ustawia opis formularza. |
setDestination(type, id) | Form | Określa miejsce docelowe, w którym są zapisywane odpowiedzi z formularza. |
setIsQuiz(enabled) | Form | Określa, czy formularz jest quizem. |
setLimitOneResponsePerUser(enabled) | Form | Określa, czy formularz może zawierać tylko 1 odpowiedź na użytkownika. |
setProgressBar(enabled) | Form | Określa, czy formularz ma pasek postępu. |
setPublishingSummary(enabled) | Form | Określa, czy po przesłaniu formularza przez użytkownika ma być wyświetlany link do podsumowania odpowiedzi. |
setRequireLogin(requireLogin) | Form | Określa, czy przed wysłaniem odpowiedzi użytkownicy muszą zalogować się na konto w tej samej domenie czy w subdomenie. |
setShowLinkToRespondAgain(enabled) | Form | Określa, czy po wypełnieniu formularza przez użytkownika ma być wyświetlany link umożliwiający przesłanie kolejnej odpowiedzi. |
setShuffleQuestions(shuffle) | Form | Określa, czy kolejność pytań na każdej stronie formularza ma być losowa. |
setTitle(title) | Form | Ustawia tytuł formularza. |
shortenFormUrl(url) | String | Konwertuje długi adres URL formularza na krótki adres URL. |
submitGrades(responses) | Form | Przesyłam oceny dla podanych formularzy FormResponses. |
Szczegółowa dokumentacja
addCheckboxGridItem()
Dodaje nowe pytanie, które jest prezentowane w formie siatki kolumn i wierszy, co umożliwia respondentom wybranie wielu opcji w każdym wierszu z sekwencji pól wyboru.
// 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(); // Sets the title 'Where did you celebrate New Year's?' 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']);
Powroty
CheckboxGridItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addCheckboxItem()
Dodaje nowe pytanie, które pozwala respondentowi zaznaczyć jedno lub więcej pól wyboru, a także opcjonalne pole „inne”.
// 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']);
Powroty
CheckboxItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addDateItem()
Dodaje nowy element pytania, który umożliwia respondentowi wskazanie daty.
// 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.');
Powroty
DateItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addDateTimeItem()
Dodaje nowy element pytania, który umożliwia respondentowi wskazanie daty i godziny.
// 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);
Powroty
DateTimeItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addDurationItem()
Dodaje nowy element pytania, który pozwala respondentowi określić czas trwania.
// 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);
Powroty
DurationItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addEditor(emailAddress)
Dodaje wskazanego użytkownika do listy edytorów w Form
. Jeśli użytkownik był już na liście widzów, ta metoda przesuwa go poza listę widzów.
Parametry
Nazwa | Typ | Opis |
---|---|---|
emailAddress | String | Adres e-mail użytkownika, którego chcesz dodać. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addEditor(user)
Dodaje wskazanego użytkownika do listy edytorów w Form
. Jeśli użytkownik był już na liście widzów, ta metoda przesuwa go poza listę widzów.
Parametry
Nazwa | Typ | Opis |
---|---|---|
user | User | Reprezentacja użytkownika, który ma zostać dodany. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addEditors(emailAddresses)
Dodaje podaną tablicę użytkowników do listy edytorów elementu Form
. Jeśli którykolwiek z użytkowników był już na liście widzów, ta metoda przesuwa go poza listę widzów.
Parametry
Nazwa | Typ | Opis |
---|---|---|
emailAddresses | String[] | Tablica adresów e-mail użytkowników do dodania. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addGridItem()
Dodaje nowe pytanie, przedstawione w postaci siatki kolumn i wierszy, co umożliwia respondentom wybranie w każdym wierszu jednej odpowiedzi z sekwencji przycisków.
// 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']);
Powroty
GridItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addImageItem()
Dodaje nowy element układu, który wyświetla obraz.
// 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);
Powroty
ImageItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addListItem()
Dodaje nowe pytanie, które pozwala respondentowi wybrać jedną odpowiedź z listy.
// 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') ]);
Powroty
ListItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addMultipleChoiceItem()
Dodaje nowe pytanie, które umożliwia respondentowi wybranie jednej opcji z listy przycisków lub opcjonalnego pola „inne”.
// 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]);
Powroty
MultipleChoiceItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addPageBreakItem()
Dodaje nowy element układu, który oznacza początek strony.
// 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);
Powroty
PageBreakItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addParagraphTextItem()
Dodaje nowy element pytania, który umożliwia użytkownikowi wpisanie bloku tekstu.
// 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?');
Powroty
ParagraphTextItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addScaleItem()
Dodaje nowy element pytania, który umożliwia respondentowi wybranie jednej opcji z sekwencji numerowanych przycisków opcji.
// 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');
Powroty
ScaleItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addSectionHeaderItem()
Dodaje nowy element układu, który wizualnie wskazuje początek sekcji.
// 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');
Powroty
SectionHeaderItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addTextItem()
Dodaje nowy element pytania, który umożliwia użytkownikowi wpisanie jednego wiersza tekstu.
// 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?');
Powroty
TextItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addTimeItem()
Dodaje nowe pytanie, które pozwala respondentowi określić porę dnia.
// 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?');
Powroty
TimeItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addVideoItem()
Dodaje nowy element układu, który wyświetla film.
// 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);
Powroty
VideoItem
– nowo utworzony element.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
canEditResponse()
Określa, czy w formularzu wyświetlany jest link umożliwiający edytowanie odpowiedzi po jej przesłaniu.
Niezależnie od tego ustawienia metoda FormResponse.getEditResponseUrl()
umożliwia autorowi skryptu, który ma uprawnienia do edycji formularza, wygenerowanie adresu URL, którego można używać do edytowania odpowiedzi.
// 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);
Powroty
Boolean
– true
, jeśli formularz zawiera link „Edytuj swoją odpowiedź”, lub false
, jeśli nie jest.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
collectsEmail()
Określa, czy formularz zbiera adresy e-mail użytkowników.
// 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);
Powroty
Boolean
– true
, jeśli formularz zbiera adresy e-mail; jeśli nie, false
.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
createResponse()
Tworzy nową odpowiedź w formularzu. Aby odpowiedzieć na pytanie, utwórz element ItemResponse
z elementu, a następnie dołącz go do odpowiedzi na pytanie, wywołując FormResponse.withItemResponse(response)
. Aby zapisać zebraną odpowiedź, wywołaj funkcję FormResponse.submit()
.
Powroty
FormResponse
– nowo utworzona odpowiedź z formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
deleteAllResponses()
Usuwa wszystkie przesłane odpowiedzi z magazynu odpowiedzi formularza. Ta metoda nie usuwa kopii odpowiedzi zapisanych w zewnętrznym miejscu docelowym odpowiedzi (np. w arkuszu kalkulacyjnym), ale czyści widok podsumowania formularza.
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
deleteItem(index)
Usuwa element o danym indeksie spośród wszystkich elementów formularza. Zgłasza wyjątek od obsługi skryptów, jeśli w danym indeksie nie ma żadnego elementu.
// 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); }
Parametry
Nazwa | Typ | Opis |
---|---|---|
index | Integer | Indeks elementu wśród wszystkich elementów w formularzu. |
Rzuty
Error
– jeśli w danym indeksie nie ma żadnego elementu
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
deleteItem(item)
Usuwa dany element. Jeśli element został już usunięty, powoduje zgłoszenie wyjątku dotyczącego skryptów.
// 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); }
Parametry
Nazwa | Typ | Opis |
---|---|---|
item | Item | Element do usunięcia. |
Rzuty
Error
– jeśli element nie istnieje w formularzu;
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
deleteResponse(responseId)
Usuwa pojedynczą odpowiedź z magazynu odpowiedzi formularza. Ta metoda nie usuwa kopii odpowiedzi zapisanych w zewnętrznym miejscu docelowym odpowiedzi (np. w arkuszu kalkulacyjnym), ale usuwa odpowiedź z widoku podsumowania formularza. Identyfikator odpowiedzi można pobrać za pomocą polecenia FormResponse.getId()
.
Parametry
Nazwa | Typ | Opis |
---|---|---|
responseId | String | Identyfikator odpowiedzi na formularz do usunięcia. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getConfirmationMessage()
Pobiera komunikat z potwierdzeniem formularza.
// 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);
Powroty
String
– komunikat z potwierdzeniem przesłania formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getCustomClosedFormMessage()
Pobiera komunikat niestandardowy, który jest wyświetlany, jeśli formularz nie przyjmuje odpowiedzi, lub pusty ciąg, jeśli nie ustawiono komunikatów niestandardowych.
// 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);
Powroty
String
– komunikat niestandardowy wyświetlany, gdy formularz nie przyjmuje odpowiedzi, lub pusty ciąg, jeśli nie ustawiono żadnego komunikatu niestandardowego.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getDescription()
Pobiera opis formularza.
// 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);
Powroty
String
– opis formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getDestinationId()
Pobiera identyfikator miejsca docelowego odpowiedzi formularza.
// 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);
Powroty
String
– identyfikator miejsca docelowego odpowiedzi formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getDestinationType()
Pobiera typ miejsca docelowego odpowiedzi formularza.
// 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);
Powroty
DestinationType
– typ miejsca docelowego odpowiedzi formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getEditUrl()
Pobiera adres URL, za pomocą którego można uzyskać dostęp do trybu edycji formularza.
// 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);
Powroty
String
– adres URL umożliwiający edytowanie formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getEditors()
Pobiera listę edytorów tego elementu (Form
).
Powroty
User[]
– tablica użytkowników z uprawnieniami do edycji.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getId()
Pobiera identyfikator formularza.
// 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);
Powroty
String
– identyfikator formularza
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getItemById(id)
Pobiera element o podanym identyfikatorze. Zwraca wartość null
, jeśli identyfikator nie odpowiada elementowi formularza.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
id | Integer | Identyfikator produktu. |
Powroty
Item
– element o podanym identyfikatorze lub null
, jeśli elementu nie ma w formularzu.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getItems()
Pobiera tablicę ze wszystkimi elementami formularza.
// 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);
Powroty
Item[]
– tablica wszystkich elementów formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getItems(itemType)
Pobiera tablicę ze wszystkimi elementami określonego typu.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
itemType | ItemType | Typ elementów do pobrania. |
Powroty
Item[]
– tablica wszystkich elementów danego typu.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getPublishedUrl()
Pobiera adres URL, którego można użyć w odpowiedzi na formularz.
// 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);
Powroty
String
– adres URL odpowiedzi na formularz.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getResponse(responseId)
Pobiera pojedynczą odpowiedź z formularza na podstawie identyfikatora odpowiedzi. Identyfikatory odpowiedzi można pobrać z FormResponse.getId()
.
Parametry
Nazwa | Typ | Opis |
---|---|---|
responseId | String | Identyfikator odpowiedzi na formularz. |
Powroty
FormResponse
– odpowiedź z formularza.
Rzuty
Error
– jeśli odpowiedź nie istnieje.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getResponses()
Pobiera tablicę wszystkich odpowiedzi formularza.
Powroty
FormResponse[]
– tablica wszystkich odpowiedzi z formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getResponses(timestamp)
Pobiera tablicę wszystkich odpowiedzi formularza po określonej dacie i godzinie.
Parametry
Nazwa | Typ | Opis |
---|---|---|
timestamp | Date | Najwcześniejsza data i godzina, dla których mają być zwracane odpowiedzi na pytania z formularza. |
Powroty
FormResponse[]
– lista odpowiedzi z formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getShuffleQuestions()
Określa, czy kolejność pytań na każdej stronie formularza jest losowa.
Powroty
Boolean
– true
, jeśli kolejność pytań na każdej stronie formularza jest losowa; jeśli nie, false
.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getSummaryUrl()
Pobiera adres URL, którego można użyć do wyświetlenia podsumowania odpowiedzi z formularza. Jeśli zasada setPublishingSummary(enabled)
nie ma wartości true
, dostęp do adresu URL mają tylko użytkownicy z uprawnieniami do edycji formularza.
// 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);
Powroty
String
– adres URL podsumowania odpowiedzi.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getTitle()
Pobiera tytuł formularza.
// 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);
Powroty
String
– tytuł formularza.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
hasLimitOneResponsePerUser()
Określa, czy formularz może zawierać tylko 1 odpowiedź na użytkownika. Jeśli wartość to true
, skrypt w ogóle nie może przesyłać odpowiedzi z formularza.
Powroty
Boolean
– true
, jeśli formularz pozwala na tylko 1 odpowiedź na użytkownika; jeśli nie, false
.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
hasProgressBar()
Określa, czy w formularzu będzie wyświetlany pasek postępu.
// 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());
Powroty
Boolean
– true
, jeśli formularz wyświetla pasek postępu; jeśli nie, false
.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
hasRespondAgainLink()
Określa, czy po wypełnieniu formularza przez użytkownika wyświetla się link umożliwiający przesłanie kolejnej odpowiedzi.
// 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());
Powroty
Boolean
– true
, jeśli w formularzu wyświetla się link „Prześlij kolejną odpowiedź”, lub false
, jeśli go nie ma.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
isAcceptingResponses()
Określa, czy formularz przyjmuje obecnie odpowiedzi.
// 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);
Powroty
Boolean
– true
, jeśli formularz przyjmuje odpowiedzi; false
, jeśli nie.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
isPublishingSummary()
Określa, czy po wypełnieniu formularza przez użytkownika ma być wyświetlany link do podsumowania odpowiedzi.
// 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);
Powroty
Boolean
– true
, jeśli formularz zawiera link „Zobacz poprzednie odpowiedzi”, lub false
, jeśli nie jest.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
isQuiz()
Określa, czy formularz jest quizem.
// 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());
Powroty
Boolean
– true
, jeśli formularz przyjmuje odpowiedzi; false
, jeśli nie.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
moveItem(from, to)
Przenosi element znajdujący się w danym indeksie wśród wszystkich elementów formularza do innego indeksu. Jeśli indeks to
jest poza zakresem, zgłasza wyjątek dotyczący obsługi skryptów.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
from | Integer | Bieżący indeks elementu spośród wszystkich elementów w formularzu. |
to | Integer | Nowy indeks elementu spośród wszystkich elementów w formularzu. |
Powroty
Item
– przeniesiony element.
Rzuty
Error
– jeśli któryś z indeksów jest poza zakresem.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
moveItem(item, toIndex)
Przenosi dany element do wskazanego indeksu wśród wszystkich elementów formularza. Jeśli dany indeks jest poza zakresem, powoduje wyjątek od obsługi skryptów.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
item | Item | Element do przeniesienia. |
toIndex | Integer | Nowy indeks elementu spośród wszystkich elementów w formularzu. |
Powroty
Item
– przeniesiony element.
Rzuty
Error
– jeśli indeks jest poza zakresem.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
removeDestination()
Odłącza formularz od bieżącego miejsca docelowego odpowiedzi. W poprzednim odłączonym miejscu docelowym nadal będzie przechowywana kopia wszystkich poprzednich odpowiedzi. Wszystkie formularze, w tym te, które nie mają wyraźnie ustawionego miejsca docelowego, zapisują kopię odpowiedzi w magazynie odpowiedzi formularza. Jeśli formularz nie ma obecnie miejsca docelowego odpowiedzi, ta metoda nie ma zastosowania.
// 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();
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
removeEditor(emailAddress)
Usuwa danego użytkownika z listy edytorów Form
. Ta metoda nie blokuje użytkownikom dostępu do Form
, jeśli należą do klasy użytkowników z dostępem ogólnym – na przykład gdy zasób Form
jest udostępniany całej domenie użytkownika lub gdy Form
znajduje się na dysku współdzielonym, do którego użytkownik ma dostęp.
W przypadku plików na Dysku spowoduje to też usunięcie użytkownika z listy osób przeglądających.
Parametry
Nazwa | Typ | Opis |
---|---|---|
emailAddress | String | Adres e-mail użytkownika, którego chcesz usunąć. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
removeEditor(user)
Usuwa danego użytkownika z listy edytorów Form
. Ta metoda nie blokuje użytkownikom dostępu do Form
, jeśli należą do klasy użytkowników z dostępem ogólnym – na przykład gdy zasób Form
jest udostępniany całej domenie użytkownika lub gdy Form
znajduje się na dysku współdzielonym, do którego użytkownik ma dostęp.
W przypadku plików na Dysku spowoduje to też usunięcie użytkownika z listy osób przeglądających.
Parametry
Nazwa | Typ | Opis |
---|---|---|
user | User | Reprezentacja użytkownika, który ma zostać usunięty. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
requiresLogin()
Określa, czy przed wysłaniem odpowiedzi użytkownik musi zalogować się na konto w tej samej domenie czy w subdomenie.
// 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 requires respondents to log in to a Google Workspace account // before responding and logs it to the console. const login = form.requiresLogin(); console.log(login);
Powroty
Boolean
– true
, jeśli formularz wymaga zalogowania się; false
, jeśli nie jest.
setAcceptingResponses(enabled)
Określa, czy formularz przyjmuje obecnie odpowiedzi. Domyślnie nowe formularze to true
.
// 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());
Parametry
Nazwa | Typ | Opis |
---|---|---|
enabled | Boolean | true , jeśli formularz ma akceptować odpowiedzi; false , jeśli nie powinien. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setAllowResponseEdits(enabled)
Określa, czy w formularzu wyświetlany jest link umożliwiający edytowanie odpowiedzi po jej przesłaniu. Domyślnie nowe formularze to false
.
Niezależnie od tego ustawienia metoda FormResponse.getEditResponseUrl()
umożliwia autorowi skryptu, który ma uprawnienia do edycji formularza, wygenerowanie adresu URL, którego można używać do edytowania odpowiedzi.
// 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());
Parametry
Nazwa | Typ | Opis |
---|---|---|
enabled | Boolean | true , jeśli formularz powinien zawierać link „Edytuj swoją odpowiedź”. W przeciwnym razie false . |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setCollectEmail(collect)
Określa, czy formularz ma zbierać adresy e-mail użytkowników. Domyślnie nowe formularze to 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
collect | Boolean | true , jeśli formularz ma zbierać adresy e-mail, lub false , jeśli nie. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setConfirmationMessage(message)
Ustawia komunikat z potwierdzeniem formularza.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
message | String | Nowa wiadomość z potwierdzeniem formularza. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setCustomClosedFormMessage(message)
Powoduje, że komunikat będzie wyświetlany, gdy formularz nie przyjmuje odpowiedzi. Jeśli żaden komunikat nie jest ustawiony, formularz zawiera komunikat domyślny.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
message | String | Komunikat wyświetlany, gdy formularz nie przyjmuje odpowiedzi. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setDescription(description)
Ustawia opis formularza.
Parametry
Nazwa | Typ | Opis |
---|---|---|
description | String | Nowy opis formularza. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setDestination(type, id)
Określa miejsce docelowe, w którym są zapisywane odpowiedzi z formularza. Wszystkie formularze, w tym te, które nie mają wyraźnie ustawionego miejsca docelowego, zapisują kopię odpowiedzi w magazynie odpowiedzi w formularzu.
Parametry
Nazwa | Typ | Opis |
---|---|---|
type | DestinationType | Typ miejsca docelowego odpowiedzi formularza. |
id | String | Identyfikator miejsca docelowego odpowiedzi formularza. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Rzuty
Error
– jeśli podany identyfikator miejsca docelowego jest nieprawidłowy.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setIsQuiz(enabled)
Określa, czy formularz jest quizem. Domyślnie nowe formularze to false
.
Pytania z oceną są dozwolone tylko w Testach, więc ustawienie tej wartości na false
powoduje usunięcie ze wszystkich pytań wszystkich opcji oceniania.
Ustawienia testów są dostępne tylko w nowym interfejsie Formularzy. Utworzenie formularza jako quizu włącza go w nowym interfejsie.
// 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());
Parametry
Nazwa | Typ | Opis |
---|---|---|
enabled | Boolean | true , jeśli w formularzu powinny być włączone funkcje quizu; false – jeśli nie. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setLimitOneResponsePerUser(enabled)
Określa, czy formularz może zawierać tylko 1 odpowiedź na użytkownika. Domyślnie nowe formularze to false
. Jeśli wartość jest ustawiona na true
, skrypt w ogóle nie może przesyłać odpowiedzi z formularza.
Parametry
Nazwa | Typ | Opis |
---|---|---|
enabled | Boolean | true , jeśli formularz powinien zezwalać tylko na jedną odpowiedź na użytkownika; false , jeśli nie. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setProgressBar(enabled)
Określa, czy formularz ma pasek postępu. Domyślnie nowe formularze to 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());
Parametry
Nazwa | Typ | Opis |
---|---|---|
enabled | Boolean | true , jeśli formularz wyświetla pasek postępu, lub false , jeśli nie jest. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setPublishingSummary(enabled)
Określa, czy po przesłaniu formularza przez użytkownika ma być wyświetlany link do podsumowania odpowiedzi. Domyślnie nowe formularze to false
.
Parametry
Nazwa | Typ | Opis |
---|---|---|
enabled | Boolean | true , jeśli formularz powinien zawierać link „Zobacz poprzednie odpowiedzi”, lub false , jeśli nie. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setRequireLogin(requireLogin)
Określa, czy przed wysłaniem odpowiedzi użytkownicy muszą zalogować się na konto w tej samej domenie czy w subdomenie. Ustawienie domyślne nowych formularzy to false
, chyba że administrator domeny zmieni to ustawienie.
Ta funkcja jest dostępna tylko w przypadku formularzy utworzonych przez użytkowników Google Workspace. Użytkownicy innych typów kont Google nie muszą się logować.
// 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 so that users must log in to their Google Workspace account. form.setRequireLogin(true); // Checks whether the form requires login or not and logs it to the console. console.log(form.requiresLogin());
Parametry
Nazwa | Typ | Opis |
---|---|---|
requireLogin | Boolean | true , jeśli formularz wymaga od użytkowników logowania, lub false , jeśli nie jest. |
Powroty
Form
– bieżący formularz (na potrzeby łańcuchów).
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setShowLinkToRespondAgain(enabled)
Określa, czy po wypełnieniu formularza przez użytkownika ma być wyświetlany link umożliwiający przesłanie kolejnej odpowiedzi. Domyślnie nowe formularze to true
.
Parametry
Nazwa | Typ | Opis |
---|---|---|
enabled | Boolean | true , jeśli formularz powinien zawierać link „Prześlij kolejną odpowiedź”, lub false , jeśli nie. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setShuffleQuestions(shuffle)
Określa, czy kolejność pytań na każdej stronie formularza ma być losowa.
Parametry
Nazwa | Typ | Opis |
---|---|---|
shuffle | Boolean | true , jeśli kolejność pytań na każdej stronie formularza powinna być losowa; false , jeśli nie. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setTitle(title)
Ustawia tytuł formularza.
Parametry
Nazwa | Typ | Opis |
---|---|---|
title | String | Nowy tytuł formularza. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
shortenFormUrl(url)
Konwertuje długi adres URL formularza na krótki adres URL. Jeśli długi URL nie należy do Formularzy Google, tworzy wyjątek.
Parametry
Nazwa | Typ | Opis |
---|---|---|
url | String | Adres URL do skrócenia. |
Powroty
String
– adres URL w postaci http://goo.gl/forms/1234
;
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
submitGrades(responses)
Przesyłam oceny dla podanych formularzy FormResponses.
Jeśli kod zawiera aktywator onFormSubmit
, wywołanie metody submitGrades()
aktywuje warunek onFormSubmit
i pętlę nieskończoną. Aby zapobiec nieskończonej pętli, przed wywołaniem funkcji submitGrades()
dodaj kod, który sprawdza, czy oceny już istnieją.
Parametry
Nazwa | Typ | Opis |
---|---|---|
responses | FormResponse[] | Tablica wszystkich odpowiedzi formularza. |
Powroty
Form
– ten element typu Form
do tworzenia łańcuchów.
Upoważnienie
Skrypty korzystające z tej metody wymagają autoryzacji z co najmniej jednym z tych zakresów:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms