Class Form

فرم

فرمی که شامل خصوصیات و موارد کلی است. ویژگی ها عبارتند از عنوان، تنظیمات، و محل ذخیره پاسخ ها. موارد شامل موارد سؤالی مانند چک باکس یا موارد رادیویی هستند، در حالی که موارد طرح‌بندی به مواردی مانند شکستگی صفحه اشاره دارند. فرم ها را می توان از 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());

مواد و روش ها

روش نوع برگشت توضیح مختصر
addCheckboxGridItem() CheckboxGridItem یک آیتم سوال جدید را اضافه می‌کند که به صورت شبکه‌ای از ستون‌ها و ردیف‌ها ارائه می‌شود که به پاسخ‌دهنده این امکان را می‌دهد که چندین گزینه را در هر ردیف از یک دنباله چک باکس انتخاب کند.
addCheckboxItem() CheckboxItem یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک یا چند کادر انتخاب و همچنین یک فیلد اختیاری "دیگر" را انتخاب کند.
addDateItem() DateItem یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد تاریخ را مشخص کند.
addDateTimeItem() DateTimeItem یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد تاریخ و زمان را مشخص کند.
addDurationItem() DurationItem یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد مدت زمان را مشخص کند.
addEditor(emailAddress) Form کاربر داده شده را به لیست ویرایشگرهای Form اضافه می کند.
addEditor(user) Form کاربر داده شده را به لیست ویرایشگرهای Form اضافه می کند.
addEditors(emailAddresses) Form آرایه داده شده از کاربران را به لیست ویرایشگرهای Form اضافه می کند.
addGridItem() GridItem یک آیتم سوال جدید را اضافه می کند که به صورت شبکه ای از ستون ها و ردیف ها ارائه می شود که به پاسخ دهنده اجازه می دهد در هر ردیف یک گزینه را از میان دنباله ای از دکمه های رادیویی انتخاب کند.
addImageItem() ImageItem یک مورد طرح بندی جدید را اضافه می کند که یک تصویر را نمایش می دهد.
addListItem() ListItem یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک گزینه را از لیست کشویی انتخاب کند.
addMultipleChoiceItem() MultipleChoiceItem یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک گزینه را از لیست دکمه های رادیویی یا یک فیلد "دیگر" اختیاری انتخاب کند.
addPageBreakItem() PageBreakItem یک آیتم طرح بندی جدید اضافه می کند که شروع یک صفحه را نشان می دهد.
addParagraphTextItem() ParagraphTextItem یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک بلوک متن را وارد کند.
addScaleItem() ScaleItem یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک گزینه را از یک دنباله شماره گذاری دکمه های رادیویی انتخاب کند.
addSectionHeaderItem() SectionHeaderItem یک آیتم طرح بندی جدید اضافه می کند که به صورت بصری شروع یک بخش را نشان می دهد.
addTextItem() TextItem یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک خط متن را وارد کند.
addTimeItem() TimeItem یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد زمانی از روز را مشخص کند.
addVideoItem() VideoItem یک مورد طرح بندی جدید را اضافه می کند که یک ویدیو را نمایش می دهد.
canEditResponse() Boolean تعیین می کند که آیا فرم پس از ارسال، پیوندی برای ویرایش پاسخ نمایش می دهد یا خیر.
collectsEmail() Boolean تعیین می کند که آیا فرم آدرس های ایمیل پاسخ دهندگان را جمع آوری می کند یا خیر.
createResponse() FormResponse پاسخ جدیدی به فرم ایجاد می کند.
deleteAllResponses() Form تمام پاسخ های ارسال شده را از فروشگاه پاسخ فرم حذف می کند.
deleteItem(index) void مورد را در یک شاخص معین از بین همه موارد موجود در فرم حذف می کند.
deleteItem(item) void مورد داده شده را حذف می کند.
deleteResponse(responseId) Form یک پاسخ را از فروشگاه پاسخ فرم حذف می کند.
getConfirmationMessage() String پیام تأیید فرم را دریافت می کند.
getCustomClosedFormMessage() String پیام سفارشی را دریافت می‌کند که اگر فرم پاسخ‌ها را نمی‌پذیرد، یا اگر پیام سفارشی تنظیم نشده باشد، یک رشته خالی نمایش داده می‌شود.
getDescription() String توضیحات فرم را دریافت می کند.
getDestinationId() String شناسه مقصد پاسخ فرم را دریافت می کند.
getDestinationType() DestinationType نوع مقصد پاسخ فرم را دریافت می کند.
getEditUrl() String نشانی اینترنتی را دریافت می کند که می توان از آن برای دسترسی به حالت ویرایش فرم استفاده کرد.
getEditors() User[] لیست ویرایشگران این Form را دریافت می کند.
getId() String شناسه فرم را می گیرد.
getItemById(id) Item مورد را با شناسه داده شده دریافت می کند.
getItems() Item[] آرایه ای از تمام موارد موجود در فرم را دریافت می کند.
getItems(itemType) Item[] آرایه ای از همه موارد از یک نوع معین را دریافت می کند.
getPublishedUrl() String نشانی اینترنتی را دریافت می کند که می توان از آن برای پاسخ دادن به فرم استفاده کرد.
getResponse(responseId) FormResponse بر اساس شناسه پاسخ خود یک پاسخ فرم واحد دریافت می کند.
getResponses() FormResponse[] آرایه ای از تمام پاسخ های فرم را دریافت می کند.
getResponses(timestamp) FormResponse[] آرایه ای از تمام پاسخ های فرم را پس از تاریخ و زمان معین دریافت می کند.
getShuffleQuestions() Boolean تعیین می کند که آیا ترتیب سؤالات در هر صفحه از فرم تصادفی است یا خیر.
getSummaryUrl() String نشانی اینترنتی را دریافت می کند که می توان از آن برای مشاهده خلاصه ای از پاسخ های فرم استفاده کرد.
getTitle() String عنوان فرم را دریافت می کند.
hasLimitOneResponsePerUser() Boolean تعیین می کند که آیا فرم تنها یک پاسخ را برای هر پاسخ دهنده مجاز می کند یا خیر.
hasProgressBar() Boolean تعیین می کند که آیا فرم نوار پیشرفت را نمایش می دهد یا خیر.
hasRespondAgainLink() Boolean تعیین می کند که آیا فرم پیوندی برای ارسال پاسخ دیگری پس از تکمیل فرم توسط پاسخ دهنده نمایش می دهد یا خیر.
isAcceptingResponses() Boolean تعیین می کند که آیا فرم در حال حاضر پاسخ ها را می پذیرد یا خیر.
isPublishingSummary() Boolean تعیین می کند که آیا فرم پیوندی برای مشاهده خلاصه ای از پاسخ ها پس از تکمیل فرم توسط پاسخ دهنده نمایش می دهد یا خیر.
isQuiz() Boolean تعیین می کند که آیا فرم یک مسابقه است.
moveItem(from, to) Item یک مورد را در یک شاخص معین از بین همه موارد موجود در فرم به نمایه داده شده دیگری منتقل می کند.
moveItem(item, toIndex) Item یک آیتم داده شده را به یک شاخص معین از بین همه موارد موجود در فرم منتقل می کند.
removeDestination() Form فرم را از مقصد پاسخ فعلی آن جدا می کند.
removeEditor(emailAddress) Form کاربر داده شده را از لیست ویرایشگرهای Form حذف می کند.
removeEditor(user) Form کاربر داده شده را از لیست ویرایشگرهای Form حذف می کند.
requiresLogin() Boolean تعیین می‌کند که آیا فرم از پاسخ‌دهندگان می‌خواهد قبل از پاسخ دادن به حسابی در همان دامنه یا یک زیر دامنه وارد شوند یا خیر.
setAcceptingResponses(enabled) Form تنظیم می کند که آیا فرم در حال حاضر پاسخ ها را می پذیرد یا خیر.
setAllowResponseEdits(enabled) Form تنظیم می کند که آیا فرم پس از ارسال، پیوندی برای ویرایش پاسخ نمایش می دهد یا خیر.
setCollectEmail(collect) Form تنظیم می کند که آیا فرم آدرس های ایمیل پاسخ دهندگان را جمع آوری کند یا خیر.
setConfirmationMessage(message) Form پیام تأیید فرم را تنظیم می کند.
setCustomClosedFormMessage(message) Form پیام را تنظیم می کند تا در صورت عدم پذیرش پاسخ، پیام نمایش داده شود.
setDescription(description) Form توضیحات فرم را تنظیم می کند.
setDestination(type, id) Form مقصدی را که پاسخ های فرم در آن ذخیره می شوند را تعیین می کند.
setIsQuiz(enabled) Form تعیین می کند که آیا فرم یک مسابقه است.
setLimitOneResponsePerUser(enabled) Form تعیین می کند که آیا فرم فقط یک پاسخ را برای هر پاسخ دهنده مجاز می کند یا خیر.
setProgressBar(enabled) Form تعیین می کند که آیا فرم نوار پیشرفت داشته باشد یا خیر.
setPublishingSummary(enabled) Form تنظیم می کند که آیا فرم پیوندی برای مشاهده خلاصه پاسخ ها پس از ارسال فرم توسط پاسخ دهنده نمایش دهد یا خیر.
setRequireLogin(requireLogin) Form تعیین می‌کند که آیا فرم از پاسخ‌دهندگان می‌خواهد قبل از پاسخ دادن به یک حساب در همان دامنه یا یک زیر دامنه وارد شوند یا خیر.
setShowLinkToRespondAgain(enabled) Form تنظیم می کند که آیا فرم پیوندی برای ارسال پاسخ دیگری پس از تکمیل فرم توسط پاسخ دهنده نمایش دهد یا خیر.
setShuffleQuestions(shuffle) Form تعیین می کند که ترتیب سؤالات در هر صفحه از فرم تصادفی باشد یا خیر.
setTitle(title) Form عنوان فرم را تنظیم می کند.
shortenFormUrl(url) String URL طولانی یک فرم را به یک URL کوتاه تبدیل می کند.
submitGrades(responses) Form نمرات FormResponses داده شده را ارسال می کند.

مستندات دقیق

addCheckboxGridItem()

یک آیتم سوال جدید را اضافه می‌کند که به صورت شبکه‌ای از ستون‌ها و ردیف‌ها ارائه می‌شود که به پاسخ‌دهنده این امکان را می‌دهد که چندین گزینه را در هر ردیف از یک دنباله چک باکس انتخاب کند.

// 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']);

برگشت

CheckboxGridItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addCheckboxItem()

یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک یا چند کادر انتخاب و همچنین یک فیلد اختیاری "دیگر" را انتخاب کند.

// 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']);

برگشت

CheckboxItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addDateItem()

یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد تاریخ را مشخص کند.

// 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.');

برگشت

DateItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addDateTimeItem()

یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد تاریخ و زمان را مشخص کند.

// 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);

برگشت

DateTimeItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addDurationItem()

یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد مدت زمان را مشخص کند.

// 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);

برگشت

DurationItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addEditor(emailAddress)

کاربر داده شده را به لیست ویرایشگرهای Form اضافه می کند. اگر کاربر قبلاً در لیست بینندگان بوده است، این روش کاربر را از لیست بینندگان خارج می کند.

مولفه های

نام تایپ کنید شرح
emailAddress String آدرس ایمیل کاربر برای افزودن

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addEditor(user)

کاربر داده شده را به لیست ویرایشگرهای Form اضافه می کند. اگر کاربر قبلاً در لیست بینندگان بوده است، این روش کاربر را از لیست بینندگان خارج می کند.

مولفه های

نام تایپ کنید شرح
user User نمایشی از کاربر برای اضافه کردن.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addEditors(emailAddresses)

آرایه داده شده از کاربران را به لیست ویرایشگرهای Form اضافه می کند. اگر هر یک از کاربران قبلاً در لیست بینندگان بودند، این روش آنها را از لیست بینندگان خارج می کند.

مولفه های

نام تایپ کنید شرح
emailAddresses String[] مجموعه ای از آدرس های ایمیل کاربران برای اضافه کردن.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addGridItem()

یک آیتم سوال جدید را اضافه می کند که به صورت شبکه ای از ستون ها و ردیف ها ارائه می شود که به پاسخ دهنده اجازه می دهد در هر ردیف یک گزینه را از میان دنباله ای از دکمه های رادیویی انتخاب کند.

// 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']);

برگشت

GridItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addImageItem()

یک مورد طرح بندی جدید را اضافه می کند که یک تصویر را نمایش می دهد.

// 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);

برگشت

ImageItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addListItem()

یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک گزینه را از لیست کشویی انتخاب کند.

// 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')
]);

برگشت

ListItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addMultipleChoiceItem()

یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک گزینه را از لیست دکمه های رادیویی یا یک فیلد "دیگر" اختیاری انتخاب کند.

// 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]);

برگشت

MultipleChoiceItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addPageBreakItem()

یک آیتم طرح بندی جدید اضافه می کند که شروع یک صفحه را نشان می دهد.

// 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);

برگشت

PageBreakItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addParagraphTextItem()

یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک بلوک متن را وارد کند.

// 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?');

برگشت

ParagraphTextItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addScaleItem()

یک مورد سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک گزینه را از یک دنباله شماره گذاری دکمه های رادیویی انتخاب کند.

// 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');

برگشت

ScaleItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addSectionHeaderItem()

یک آیتم طرح بندی جدید اضافه می کند که به صورت بصری شروع یک بخش را نشان می دهد.

 // 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');

برگشت

SectionHeaderItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addTextItem()

یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد یک خط متن را وارد کند.

// 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?');

برگشت

TextItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addTimeItem()

یک آیتم سوال جدید اضافه می کند که به پاسخ دهنده اجازه می دهد زمانی از روز را مشخص کند.

// 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?');

برگشت

TimeItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addVideoItem()

یک مورد طرح بندی جدید را اضافه می کند که یک ویدیو را نمایش می دهد.

// 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);

برگشت

VideoItem - مورد تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

canEditResponse()

تعیین می کند که آیا فرم پس از ارسال، پیوندی برای ویرایش پاسخ نمایش می دهد یا خیر.

صرف نظر از این تنظیم، روش FormResponse.getEditResponseUrl() به نویسنده اسکریپت که دسترسی ویرایش به فرم را دارد اجازه می دهد تا 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.
// 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);

برگشت

Boolean - true اگر فرم پیوند "ویرایش پاسخ خود" را نشان دهد. اگر false نباشد نادرست است.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

collectsEmail()

تعیین می کند که آیا فرم آدرس های ایمیل پاسخ دهندگان را جمع آوری می کند یا خیر.

// 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);

برگشت

Boolean - اگر فرم آدرس‌های ایمیل را جمع‌آوری کند true . اگر false نباشد نادرست است.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

createResponse()

پاسخ جدیدی به فرم ایجاد می کند. برای پاسخ به یک سوال، یک ItemResponse از مورد ایجاد کنید، سپس با فراخوانی FormResponse.withItemResponse(response) آن را به پاسخ فرم پیوست کنید. برای ذخیره پاسخ اسمبل شده، FormResponse.submit() را فراخوانی کنید.

برگشت

FormResponse - پاسخ فرم تازه ایجاد شده.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteAllResponses()

تمام پاسخ های ارسال شده را از فروشگاه پاسخ فرم حذف می کند. این روش کپی‌هایی از پاسخ‌های ذخیره شده در یک مقصد پاسخ خارجی (مانند یک صفحه گسترده) را حذف نمی‌کند، اما نمای خلاصه فرم را پاک می‌کند.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteItem(index)

مورد را در یک شاخص معین از بین همه موارد موجود در فرم حذف می کند. در صورتی که هیچ موردی در ایندکس داده شده وجود نداشته باشد، یک استثنای اسکریپت را پرتاب می کند.

// 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);
}

مولفه های

نام تایپ کنید شرح
index Integer نمایه آیتم در بین تمامی موارد موجود در فرم.

پرتاب می کند

Error - اگر هیچ موردی در شاخص داده شده وجود نداشته باشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteItem(item)

مورد داده شده را حذف می کند. در صورتی که مورد قبلاً حذف شده باشد، یک استثناء اسکریپت ایجاد می کند.

// 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);
}

مولفه های

نام تایپ کنید شرح
item Item موردی که باید حذف شود.

پرتاب می کند

Error - اگر مورد در فرم وجود نداشته باشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteResponse(responseId)

یک پاسخ را از فروشگاه پاسخ فرم حذف می کند. این روش کپی‌هایی از پاسخ‌های ذخیره‌شده در یک مقصد پاسخ خارجی (مانند صفحه‌گسترده) را حذف نمی‌کند، اما پاسخ را از نمای خلاصه فرم حذف می‌کند. شناسه پاسخ را می توان با FormResponse.getId() بازیابی کرد.

مولفه های

نام تایپ کنید شرح
responseId String شناسه پاسخ فرم برای حذف.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getConfirmationMessage()

پیام تأیید فرم را دریافت می کند.

// 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);

برگشت

String - پیام تأیید فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getCustomClosedFormMessage()

پیام سفارشی را دریافت می‌کند که اگر فرم پاسخ‌ها را نمی‌پذیرد، یا اگر پیام سفارشی تنظیم نشده باشد، یک رشته خالی نمایش داده می‌شود.

// 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);

برگشت

String - پیام سفارشی برای نمایش اگر فرم پاسخ‌ها را نمی‌پذیرد، یا یک رشته خالی اگر پیام سفارشی تنظیم نشده باشد.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getDescription()

توضیحات فرم را دریافت می کند.

// 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);

برگشت

String - توضیحات فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getDestinationId()

شناسه مقصد پاسخ فرم را دریافت می کند.

// 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);

برگشت

String - شناسه مقصد پاسخ فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getDestinationType()

نوع مقصد پاسخ فرم را دریافت می کند.

// 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);

برگشت

DestinationType - نوع مقصد پاسخ فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getEditUrl()

نشانی اینترنتی را دریافت می کند که می توان از آن برای دسترسی به حالت ویرایش فرم استفاده کرد.

// 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);

برگشت

String - URL برای ویرایش فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getEditors()

لیست ویرایشگران این Form را دریافت می کند.

برگشت

User[] - آرایه ای از کاربران با مجوز ویرایش.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getId()

شناسه فرم را می گیرد.

// 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);

برگشت

String - شناسه فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getItemById(id)

مورد را با شناسه داده شده دریافت می کند. اگر شناسه با یک مورد در فرم مطابقت نداشته باشد، null برمی‌گرداند.

// 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);

مولفه های

نام تایپ کنید شرح
id Integer شناسه کالا

برگشت

Item - موردی با شناسه داده شده، یا اگر مورد در فرم وجود نداشته باشد null .

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getItems()

آرایه ای از تمام موارد موجود در فرم را دریافت می کند.

// 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);

برگشت

Item[] - آرایه ای از همه موارد در فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getItems(itemType)

آرایه ای از همه موارد از یک نوع معین را دریافت می کند.

// 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);

مولفه های

نام تایپ کنید شرح
itemType ItemType نوع اقلام برای بازیابی

برگشت

Item[] - آرایه ای از همه موارد از آن نوع.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getPublishedUrl()

نشانی اینترنتی را دریافت می کند که می توان از آن برای پاسخ دادن به فرم استفاده کرد.

// 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);

برگشت

String - URL برای پاسخ به فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getResponse(responseId)

بر اساس شناسه پاسخ خود یک پاسخ فرم واحد دریافت می کند. شناسه های پاسخ را می توان از FormResponse.getId() بازیابی کرد.

مولفه های

نام تایپ کنید شرح
responseId String شناسه پاسخ فرم.

برگشت

FormResponse - پاسخ فرم.

پرتاب می کند

Error - اگر پاسخ وجود نداشته باشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getResponses()

آرایه ای از تمام پاسخ های فرم را دریافت می کند.

برگشت

FormResponse[] - آرایه ای از تمام پاسخ های فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getResponses(timestamp)

آرایه ای از تمام پاسخ های فرم را پس از تاریخ و زمان معین دریافت می کند.

مولفه های

نام تایپ کنید شرح
timestamp Date اولین تاریخ و زمانی که پاسخ های فرم باید برگردانده شود.

برگشت

FormResponse[] - لیستی از پاسخ های فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getShuffleQuestions()

تعیین می کند که آیا ترتیب سؤالات در هر صفحه از فرم تصادفی است یا خیر.

برگشت

Boolean - true اگر ترتیب سوالات در هر صفحه از فرم تصادفی باشد. false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getSummaryUrl()

نشانی اینترنتی را دریافت می کند که می توان از آن برای مشاهده خلاصه ای از پاسخ های فرم استفاده کرد. مگر اینکه setPublishingSummary(enabled) روی true تنظیم شود، فقط کاربرانی که مجوز ویرایش فرم را دارند می توانند به 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);

برگشت

String - URL برای مشاهده خلاصه ای از پاسخ ها.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getTitle()

عنوان فرم را دریافت می کند.

// 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);

برگشت

String - عنوان فرم.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

hasLimitOneResponsePerUser()

تعیین می کند که آیا فرم تنها یک پاسخ را برای هر پاسخ دهنده مجاز می کند یا خیر. اگر مقدار true باشد، اسکریپت به هیچ وجه نمی تواند پاسخ های فرم را ارسال کند.

برگشت

Boolean - true اگر فرم فقط یک پاسخ را به هر پاسخ دهنده اجازه دهد. false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

hasProgressBar()

تعیین می کند که آیا فرم نوار پیشرفت را نمایش می دهد یا خیر.

// 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());

برگشت

Boolean - true اگر فرم نوار پیشرفت را نمایش دهد. اگر false نباشد نادرست است.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

تعیین می کند که آیا فرم پیوندی برای ارسال پاسخ دیگری پس از تکمیل فرم توسط پاسخ دهنده نمایش می دهد یا خیر.

// 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());

برگشت

Boolean - true اگر فرم پیوند "ارسال پاسخ دیگری" را نشان دهد. اگر false نباشد نادرست است.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isAcceptingResponses()

تعیین می کند که آیا فرم در حال حاضر پاسخ ها را می پذیرد یا خیر.

// 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);

برگشت

Boolean - true اگر فرم پاسخ‌ها را می‌پذیرد. اگر false نباشد نادرست است

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isPublishingSummary()

تعیین می کند که آیا فرم پیوندی برای مشاهده خلاصه ای از پاسخ ها پس از تکمیل فرم توسط پاسخ دهنده نمایش می دهد یا خیر.

// 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);

برگشت

Boolean - true اگر فرم پیوند "مشاهده پاسخ های قبلی" را نشان دهد. اگر false نباشد نادرست است.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isQuiz()

تعیین می کند که آیا فرم یک مسابقه است.

// 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());

برگشت

Boolean - true اگر فرم پاسخ‌ها را می‌پذیرد. اگر false نباشد نادرست است

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

moveItem(from, to)

یک مورد را در یک شاخص معین از بین همه موارد موجود در فرم به نمایه داده شده دیگری منتقل می کند. در صورتی که نمایه to خارج از محدوده باشد، یک استثنای اسکریپت ایجاد می کند.

// 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);

مولفه های

نام تایپ کنید شرح
from Integer نمایه فعلی مورد در بین تمام موارد موجود در فرم.
to Integer نمایه جدید مورد در بین تمام موارد موجود در فرم.

برگشت

Item - موردی که منتقل شد.

پرتاب می کند

Error - اگر هر یک از ایندکس ها خارج از محدوده باشد.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

moveItem(item, toIndex)

یک آیتم داده شده را به یک شاخص معین از بین همه موارد موجود در فرم منتقل می کند. در صورتی که شاخص داده شده خارج از محدوده باشد، یک استثناء اسکریپت می اندازد.

// 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);

مولفه های

نام تایپ کنید شرح
item Item موردی برای جابجایی
toIndex Integer نمایه جدید مورد در بین تمام موارد موجود در فرم.

برگشت

Item - موردی که منتقل شد.

پرتاب می کند

Error - اگر شاخص خارج از محدوده باشد.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

removeDestination()

فرم را از مقصد پاسخ فعلی آن جدا می کند. مقصد قبلی بدون پیوند همچنان یک کپی از همه پاسخ‌های قبلی را حفظ می‌کند. همه فرم‌ها، از جمله آن‌هایی که به‌صراحت مقصدی ندارند، یک کپی از پاسخ‌ها را در فروشگاه پاسخ فرم ذخیره می‌کنند . اگر فرم در حال حاضر مقصد پاسخگویی نداشته باشد، این روش تاثیری ندارد.

// 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();

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

removeEditor(emailAddress)

کاربر داده شده را از لیست ویرایشگرهای Form حذف می کند. اگر کاربران به دسته‌ای از کاربرانی که دسترسی Form دارند - برای مثال اگر Form با کل دامنه کاربر به اشتراک گذاشته شده باشد، یا اگر Form در درایو مشترکی باشد که کاربر به آن دسترسی دارد، این روش از دسترسی به فرم جلوگیری نمی‌کند. می تواند دسترسی داشته باشد.

برای فایل‌های Drive، این کار همچنین کاربر را از لیست بینندگان حذف می‌کند.

مولفه های

نام تایپ کنید شرح
emailAddress String آدرس ایمیل کاربر برای حذف.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

removeEditor(user)

کاربر داده شده را از لیست ویرایشگرهای Form حذف می کند. اگر کاربران به دسته‌ای از کاربرانی که دسترسی Form دارند - برای مثال اگر Form با کل دامنه کاربر به اشتراک گذاشته شده باشد، یا اگر Form در درایو مشترکی باشد که کاربر به آن دسترسی دارد، این روش از دسترسی به فرم جلوگیری نمی‌کند. می تواند دسترسی داشته باشد.

برای فایل‌های Drive، این کار همچنین کاربر را از لیست بینندگان حذف می‌کند.

مولفه های

نام تایپ کنید شرح
user User نمایشی از کاربر برای حذف.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

requiresLogin()

تعیین می‌کند که آیا فرم از پاسخ‌دهندگان می‌خواهد قبل از پاسخ دادن به حسابی در همان دامنه یا یک زیر دامنه وارد شوند یا خیر.

// 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);

برگشت

Boolean - true اگر فرم نیاز به ورود کاربران داشته باشد. اگر false نباشد نادرست است.


setAcceptingResponses(enabled)

تنظیم می کند که آیا فرم در حال حاضر پاسخ ها را می پذیرد یا خیر. پیش فرض برای فرم های جدید 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());

مولفه های

نام تایپ کنید شرح
enabled Boolean true اگر فرم باید پاسخ ها را بپذیرد. false اگر نباید باشد

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setAllowResponseEdits(enabled)

تنظیم می کند که آیا فرم پس از ارسال، پیوندی برای ویرایش پاسخ نمایش می دهد یا خیر. پیش فرض برای فرم های جدید false است.

صرف نظر از این تنظیم، روش FormResponse.getEditResponseUrl() به نویسنده اسکریپت که مجوز ویرایش فرم را دارد اجازه می دهد تا یک 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.
// 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());

مولفه های

نام تایپ کنید شرح
enabled Boolean true اگر فرم باید پیوند "ویرایش پاسخ خود" را نمایش دهد. false اگر نه

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setCollectEmail(collect)

تنظیم می کند که آیا فرم آدرس های ایمیل پاسخ دهندگان را جمع آوری کند یا خیر. پیش فرض برای فرم های جدید 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);

مولفه های

نام تایپ کنید شرح
collect Boolean true اگر فرم باید آدرس های ایمیل را جمع آوری کند. اگر false نباشد نادرست است.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setConfirmationMessage(message)

پیام تأیید فرم را تنظیم می کند.

// 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);

مولفه های

نام تایپ کنید شرح
message String پیام تأیید جدید فرم.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setCustomClosedFormMessage(message)

پیام را تنظیم می کند تا در صورت عدم پذیرش پاسخ، پیام نمایش داده شود. اگر هیچ پیامی تنظیم نشده باشد، فرم از یک پیام پیش فرض استفاده می کند.

// 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);

مولفه های

نام تایپ کنید شرح
message String پیامی که در صورتی که فرم پاسخ‌ها را نمی‌پذیرد، نمایش داده می‌شود.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setDescription(description)

توضیحات فرم را تنظیم می کند.

مولفه های

نام تایپ کنید شرح
description String توضیحات جدید فرم

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setDestination(type, id)

مقصدی را که پاسخ های فرم در آن ذخیره می شوند را تعیین می کند. همه فرم‌ها، از جمله آن‌هایی که به‌صراحت مقصدی ندارند، یک کپی از پاسخ‌ها را در فروشگاه پاسخ فرم ذخیره می‌کنند .

مولفه های

نام تایپ کنید شرح
type DestinationType نوع مقصد پاسخ فرم.
id String شناسه مقصد پاسخ فرم.

برگشت

Form - این Form ، برای زنجیر کردن.

پرتاب می کند

Error - اگر شناسه مقصد داده شده نامعتبر باشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setIsQuiz(enabled)

تعیین می کند که آیا فرم یک مسابقه است. پیش فرض برای فرم های جدید false است.

سوالات درجه بندی شده فقط در Quizzes مجاز هستند، بنابراین تنظیم آن روی false باعث می شود همه گزینه های درجه بندی از همه سوالات حذف شوند.

تنظیمات آزمون فقط در رابط کاربری فرم‌های جدید موجود است. ساخت یک فرم Quiz فرم را برای استفاده از رابط کاربری جدید انتخاب می کند.

// 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());

مولفه های

نام تایپ کنید شرح
enabled Boolean true اگر ویژگی‌های مسابقه باید برای فرم فعال شوند. false اگر نه

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setLimitOneResponsePerUser(enabled)

تعیین می کند که آیا فرم فقط یک پاسخ را برای هر پاسخ دهنده مجاز می کند یا خیر. پیش فرض برای فرم های جدید false است. اگر مقدار روی true تنظیم شود، اسکریپت به هیچ وجه نمی تواند پاسخ فرم ارسال کند.

مولفه های

نام تایپ کنید شرح
enabled Boolean true اگر فرم فقط یک پاسخ را به هر پاسخ دهنده اجازه دهد. false اگر نه

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setProgressBar(enabled)

تعیین می کند که آیا فرم نوار پیشرفت داشته باشد یا خیر. پیش فرض برای فرم های جدید 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());

مولفه های

نام تایپ کنید شرح
enabled Boolean true اگر فرم نوار پیشرفت را نمایش دهد. اگر false نباشد نادرست است.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setPublishingSummary(enabled)

تنظیم می کند که آیا فرم پیوندی برای مشاهده خلاصه پاسخ ها پس از ارسال فرم توسط پاسخ دهنده نمایش دهد یا خیر. پیش فرض برای فرم های جدید false است.

مولفه های

نام تایپ کنید شرح
enabled Boolean true اگر فرم باید پیوند "مشاهده پاسخ های قبلی" را نشان دهد. false اگر نه

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setRequireLogin(requireLogin)

تعیین می‌کند که آیا فرم از پاسخ‌دهندگان می‌خواهد قبل از پاسخ دادن به یک حساب در همان دامنه یا یک زیر دامنه وارد شوند یا خیر. پیش‌فرض برای فرم‌های جدید false است، مگر اینکه مدیر دامنه پیش‌فرض را تغییر دهد.

این ویژگی فقط برای فرم‌های ایجاد شده توسط کاربران Google Workspace در دسترس است. کاربران انواع دیگر حساب‌های Google را نمی‌توان ملزم به ورود به سیستم کرد.

// 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());

مولفه های

نام تایپ کنید شرح
requireLogin Boolean true اگر فرم نیاز به ورود کاربران داشته باشد. اگر false نباشد نادرست است.

برگشت

Form - فرم فعلی (برای زنجیر کردن).

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setShowLinkToRespondAgain(enabled)

تنظیم می کند که آیا فرم پیوندی برای ارسال پاسخ دیگری پس از تکمیل فرم توسط پاسخ دهنده نمایش دهد یا خیر. پیش فرض برای فرم های جدید true است.

مولفه های

نام تایپ کنید شرح
enabled Boolean true اگر فرم باید پیوند "ارسال پاسخ دیگری" را نمایش دهد. false اگر نه

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setShuffleQuestions(shuffle)

تعیین می کند که ترتیب سؤالات در هر صفحه از فرم تصادفی باشد یا خیر.

مولفه های

نام تایپ کنید شرح
shuffle Boolean true اگر ترتیب سوالات در هر صفحه فرم باید تصادفی باشد. false اگر نه

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setTitle(title)

عنوان فرم را تنظیم می کند.

مولفه های

نام تایپ کنید شرح
title String عنوان جدید فرم

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

shortenFormUrl(url)

URL طولانی یک فرم را به یک URL کوتاه تبدیل می کند. اگر URL طولانی متعلق به فرم‌های Google نباشد، استثنا می‌کند.

مولفه های

نام تایپ کنید شرح
url String URL برای کوتاه کردن.

برگشت

String - یک URL به شکل http://goo.gl/forms/1234 .

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

submitGrades(responses)

نمرات FormResponses داده شده را ارسال می کند.

اگر کد شما شامل یک تریگر onFormSubmit باشد، فراخوانی submitGrades() شرط onFormSubmit را راه‌اندازی می‌کند و باعث ایجاد یک حلقه بی‌نهایت می‌شود. برای جلوگیری از حلقه بی نهایت، کدی را اضافه کنید که قبل از فراخوانی submitGrades() بررسی کند که آیا نمره ها از قبل وجود دارند یا خیر.

مولفه های

نام تایپ کنید شرح
responses FormResponse[] آرایه ای از تمام پاسخ های فرم.

برگشت

Form - این Form ، برای زنجیر کردن.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms