Class Form

فرم

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

// Open a form by ID and create a new spreadsheet.
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
const ss = SpreadsheetApp.create('Spreadsheet Name');

// Update form properties via chaining.
form.setTitle('Form Name')
    .setDescription('Description of form')
    .setConfirmationMessage('Thanks for responding!')
    .setAllowResponseEdits(true)
    .setAcceptingResponses(false);

// Update the form's response destination.
form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());

روش‌ها

روش نوع بازگشتی شرح مختصر
add Checkbox Grid Item() Checkbox Grid Item یک آیتم سوال جدید اضافه می‌کند که به صورت شبکه‌ای از ستون‌ها و ردیف‌ها ارائه می‌شود و به پاسخ‌دهنده اجازه می‌دهد تا در هر ردیف، چندین گزینه را از بین مجموعه‌ای از کادرهای انتخاب انتخاب کند.
add Checkbox Item() Checkbox Item یک آیتم سوال جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد یک یا چند کادر انتخاب و همچنین یک فیلد اختیاری "سایر" را انتخاب کند.
add Date Item() Date Item یک آیتم سوال جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد تاریخ را مشخص کند.
add Date Time Item() Date Time Item یک آیتم سوال جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد تاریخ و زمان را مشخص کند.
add Duration Item() Duration Item یک آیتم سؤالی جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد مدت زمان را مشخص کند.
add Editor(emailAddress) Form کاربر داده شده را به لیست ویرایشگرهای Form اضافه می‌کند.
add Editor(user) Form کاربر داده شده را به لیست ویرایشگرهای Form اضافه می‌کند.
add Editors(emailAddresses) Form آرایه‌ی داده شده از کاربران را به لیست ویرایشگرهای Form اضافه می‌کند.
add Grid Item() Grid Item یک آیتم سوال جدید اضافه می‌کند که به صورت شبکه‌ای از ستون‌ها و ردیف‌ها ارائه می‌شود و به پاسخ‌دهنده اجازه می‌دهد تا در هر ردیف، یک گزینه را از بین دنباله‌ای از دکمه‌های رادیویی انتخاب کند.
add Image Item() Image Item یک آیتم طرح‌بندی جدید اضافه می‌کند که یک تصویر را نمایش می‌دهد.
add List Item() List Item یک آیتم سوال جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد از یک لیست کشویی، یک گزینه را انتخاب کند.
add Multiple Choice Item() Multiple Choice Item یک آیتم سوال جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد از فهرست دکمه‌های رادیویی یا یک فیلد اختیاری «سایر» یک گزینه را انتخاب کند.
add Page Break Item() Page Break Item یک آیتم طرح‌بندی جدید اضافه می‌کند که شروع یک صفحه را مشخص می‌کند.
add Paragraph Text Item() Paragraph Text Item یک آیتم سوال جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد یک بلوک متن وارد کند.
add Published Reader(emailAddress) Form کاربر داده شده را به لیست پاسخ دهندگان Form اضافه می‌کند.
add Published Reader(user) Form کاربر داده شده را به لیست پاسخ دهندگان Form اضافه می‌کند.
add Published Readers(emailAddresses) Form آرایه‌ی داده شده از کاربران را به لیست پاسخ‌دهندگان Form اضافه می‌کند.
add Rating Item() Rating Item یک آیتم سوال جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد امتیاز بدهد.
add Scale Item() Scale Item یک آیتم سؤالی جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد از بین مجموعه‌ای از دکمه‌های رادیویی که شماره‌گذاری شده‌اند، یک گزینه را انتخاب کند.
add Section Header Item() Section Header Item یک آیتم طرح‌بندی جدید اضافه می‌کند که به صورت بصری شروع یک بخش را نشان می‌دهد.
add Text Item() Text Item یک آیتم سؤالی جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد یک خط متن وارد کند.
add Time Item() Time Item یک آیتم سؤالی جدید اضافه می‌کند که به پاسخ‌دهنده اجازه می‌دهد زمانی از روز را مشخص کند.
add Video Item() Video Item یک آیتم طرح‌بندی جدید اضافه می‌کند که یک ویدیو را نمایش می‌دهد.
can Edit Response() Boolean تعیین می‌کند که آیا فرم پس از ارسال پاسخ، پیوندی برای ویرایش آن نمایش دهد یا خیر.
collects Email() Boolean تعیین می‌کند که آیا فرم، آدرس‌های ایمیل پاسخ‌دهندگان را جمع‌آوری می‌کند یا خیر.
create Response() Form Response یک پاسخ جدید به فرم ایجاد می‌کند.
delete All Responses() Form تمام پاسخ‌های ارسالی را از مخزن پاسخ فرم حذف می‌کند.
delete Item(index) void آیتمی را که در یک اندیس مشخص از بین تمام آیتم‌های موجود در فرم قرار دارد، حذف می‌کند.
delete Item(item) void مورد داده شده را حذف می‌کند.
delete Response(responseId) Form یک پاسخ واحد را از مخزن پاسخ فرم حذف می‌کند.
get Confirmation Message() String پیام تأیید فرم را دریافت می‌کند.
get Custom Closed Form Message() String پیام سفارشی‌ای را که در صورت عدم پذیرش پاسخ‌ها توسط فرم نمایش داده می‌شود، یا در صورت عدم تنظیم پیام سفارشی، یک رشته خالی را برمی‌گرداند.
get Description() String توضیحات فرم را دریافت می‌کند.
get Destination Id() String شناسه (ID) مقصد پاسخ فرم را دریافت می‌کند.
get Destination Type() Destination Type نوع مقصد پاسخ فرم را دریافت می‌کند.
get Edit Url() String آدرس اینترنتی (URL) مورد استفاده برای دسترسی به حالت ویرایش فرم را برمی‌گرداند.
get Editors() User[] لیست ویرایشگرهای این Form را دریافت می‌کند.
get Id() String شناسه فرم را دریافت می‌کند.
get Item By Id(id) Item |null آیتم را با شناسه (ID) داده شده دریافت می‌کند.
get Items() Item[] آرایه‌ای از تمام آیتم‌های موجود در فرم را دریافت می‌کند.
get Items(itemType) Item[] آرایه‌ای از تمام آیتم‌های یک نوع داده شده را دریافت می‌کند.
get Published Readers() User[] لیست پاسخ‌دهندگان به این Form را دریافت می‌کند.
get Published Url() String آدرس اینترنتی (URL) مورد استفاده برای پاسخ به فرم را دریافت می‌کند.
get Response(responseId) Form Response بر اساس شناسه پاسخ، یک پاسخ واحد از فرم دریافت می‌کند.
get Responses() Form Response[] آرایه‌ای از تمام پاسخ‌های فرم را دریافت می‌کند.
get Responses(timestamp) Form Response[] آرایه‌ای از تمام پاسخ‌های فرم را پس از تاریخ و زمان مشخص شده دریافت می‌کند.
get Shuffle Questions() Boolean تعیین می‌کند که آیا ترتیب سوالات در هر صفحه از فرم تصادفی است یا خیر.
get Summary Url() String URL ای را که می توان برای مشاهده خلاصه ای از پاسخ های فرم استفاده کرد، دریافت می کند.
get Title() String عنوان فرم را دریافت می‌کند.
has Limit One Response Per User() Boolean تعیین می‌کند که آیا فرم فقط به ازای هر پاسخ‌دهنده یک پاسخ را مجاز می‌داند یا خیر.
has Progress Bar() Boolean تعیین می‌کند که آیا فرم نوار پیشرفت را نمایش می‌دهد یا خیر.
has Respond Again Link() Boolean تعیین می‌کند که آیا فرم، پس از تکمیل فرم توسط پاسخ‌دهنده، پیوندی برای ارسال پاسخ دیگر نمایش دهد یا خیر.
is Accepting Responses() Boolean تعیین می‌کند که آیا فرم در حال حاضر پاسخ‌ها را می‌پذیرد یا خیر.
is Published() Boolean مشخص می‌کند که آیا فرم منتشر شده است یا خیر.
is Publishing Summary() Boolean تعیین می‌کند که آیا فرم، پس از تکمیل فرم توسط پاسخ‌دهنده، پیوندی برای مشاهده خلاصه پاسخ‌ها نمایش دهد یا خیر.
is Quiz() Boolean مشخص می‌کند که آیا فرم، یک آزمون است یا خیر.
move Item(from, to) Item یک آیتم را در یک اندیس مشخص از بین تمام آیتم‌های موجود در فرم، به اندیس مشخص دیگری منتقل می‌کند.
move Item(item, toIndex) Item یک آیتم داده شده را از بین تمام آیتم‌های موجود در فرم، به یک اندیس داده شده منتقل می‌کند.
remove Destination() Form فرم را از مقصد پاسخ فعلی‌اش جدا می‌کند.
remove Editor(emailAddress) Form کاربر داده شده را از لیست ویرایشگرهای Form حذف می‌کند.
remove Editor(user) Form کاربر داده شده را از لیست ویرایشگرهای Form حذف می‌کند.
remove Published Reader(emailAddress) Form کاربر داده شده را از لیست پاسخ دهندگان Form حذف می‌کند.
remove Published Reader(user) Form کاربر داده شده را از لیست پاسخ دهندگان Form حذف می‌کند.
set Accepting Responses(enabled) Form تعیین می‌کند که آیا فرم در حال حاضر پاسخ‌ها را می‌پذیرد یا خیر.
set Allow Response Edits(enabled) Form تعیین می‌کند که آیا فرم پس از ارسال پاسخ، پیوندی برای ویرایش آن نمایش دهد یا خیر.
set Collect Email(collect) Form تعیین می‌کند که آیا فرم، آدرس‌های ایمیل پاسخ‌دهندگان را جمع‌آوری کند یا خیر.
set Confirmation Message(message) Form پیام تأیید فرم را تنظیم می‌کند.
set Custom Closed Form Message(message) Form تنظیم می‌کند که در صورت عدم پذیرش پاسخ‌ها توسط فرم، چه پیامی نمایش داده شود.
set Description(description) Form توضیحات فرم را تنظیم می‌کند.
set Destination(type, id) Form مقصدی را که پاسخ‌های فرم در آن ذخیره می‌شوند، تعیین می‌کند.
set Is Quiz(enabled) Form مشخص می‌کند که آیا فرم یک آزمون است یا خیر.
set Limit One Response Per User(enabled) Form تعیین می‌کند که آیا فرم فقط به ازای هر پاسخ‌دهنده یک پاسخ می‌دهد یا خیر.
set Progress Bar(enabled) Form تعیین می‌کند که آیا فرم دارای نوار پیشرفت باشد یا خیر.
set Published(enabled) Form مشخص می‌کند که آیا فرم منتشر شده است یا خیر.
set Publishing Summary(enabled) Form تعیین می‌کند که آیا فرم، پس از ارسال فرم توسط پاسخ‌دهنده، پیوندی برای مشاهده خلاصه پاسخ‌ها نمایش دهد یا خیر.
set Show Link To Respond Again(enabled) Form تعیین می‌کند که آیا فرم، پس از تکمیل فرم توسط پاسخ‌دهنده، پیوندی برای ارسال پاسخ دیگر نمایش دهد یا خیر.
set Shuffle Questions(shuffle) Form تعیین می‌کند که آیا ترتیب سوالات در هر صفحه از فرم تصادفی باشد یا خیر.
set Title(title) Form عنوان فرم را تنظیم می‌کند.
shorten Form Url(url) String یک URL طولانی برای یک فرم را به یک URL کوتاه تبدیل می‌کند.
submit Grades(responses) Form نمرات مربوط به FormResponses داده شده را ارسال می‌کند.
supports Advanced Responder Permissions() Boolean تعیین می‌کند که آیا فرم از انتشار پشتیبانی می‌کند یا خیر.

مستندات دقیق

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

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 اضافه می‌کند. اگر کاربر از قبل در لیست بینندگان یا پاسخ‌دهندگان باشد، این متد کاربر را از لیست خارج می‌کند.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds editor to the form.
// TODO(developer): replace the emailAddress.
form.addEditor('editor@uni.edu');

پارامترها

نام نوع توضیحات
email Address String آدرس ایمیل کاربر برای اضافه کردن.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

addEditor(user)

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

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the editors from the old form.
const users = oldForm.getEditors();

// Creates a new form.
const newForm = FormApp.create('New form');

// Adds the editors to a new form.
users.forEach(user => newForm.addEditor(user));

پارامترها

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

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

addEditors(emailAddresses)

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

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds editors to the form.
// TODO(developer): replace the emailAddress.
form.addPublishedReaders(['editor1@uni.edu', 'editor2@uni.edu']);

پارامترها

نام نوع توضیحات
email Addresses 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

addPublishedReader(emailAddress)

کاربر داده شده را به لیست پاسخ دهندگان Form اضافه می‌کند. اگر کاربر از قبل در لیست ویرایشگران یا بینندگان باشد، این متد هیچ تاثیری ندارد.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds responder to the form.
// TODO(developer): replace the emailAddress.
form.addPublishedReader('responder@uni.edu');

پارامترها

نام نوع توضیحات
email Address String آدرس ایمیل کاربر برای اضافه کردن.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

addPublishedReader(user)

کاربر داده شده را به لیست پاسخ دهندگان Form اضافه می‌کند. اگر کاربر از قبل در لیست ویرایشگران یا بینندگان باشد، این متد هیچ تاثیری ندارد.

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the responders from the old form.
const users = oldForm.getPublishedReaders();

// Creates a new form.
const newForm = FormApp.create('New form');

// Adds the responders to a new form.
users.forEach(user => newForm.addPublishedReader(user));

پارامترها

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

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

addPublishedReaders(emailAddresses)

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

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds responders to the form.
// TODO(developer): replace the emailAddress.
form.addPublishedReaders(['responder1@uni.edu', 'responder2@uni.edu']);

پارامترها

نام نوع توضیحات
email Addresses String[] آرایه‌ای از آدرس‌های ایمیل کاربران برای اضافه کردن.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

addRatingItem()

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

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl(
    'https://docs.google.com/forms/d/abc123456/edit',
);

// Adds the rating item.
const item = form.addRatingItem();

بازگشت

RatingItem — آیتم تازه ایجاد شده.

مجوز

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

  • 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() بازیابی کرد.

پارامترها

نام نوع توضیحات
response Id 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()

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

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

آدرس اینترنتی (URL) مورد استفاده برای دسترسی به حالت ویرایش فرم را برمی‌گرداند.

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

آیتم را با شناسه (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 — آیتمی با شناسه‌ی داده شده، یا اگر آیتم در فرم وجود نداشته باشد، 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);

پارامترها

نام نوع توضیحات
item Type Item Type نوع اقلامی که باید بازیابی شوند.

بازگشت

Item[] — آرایه‌ای از تمام آیتم‌های از آن نوع.

مجوز

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

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

getPublishedReaders()

لیست پاسخ‌دهندگان به این Form را دریافت می‌کند.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the responders for the form.
const users = form.getPublishedReaders();
users.forEach(user => console.log(user.getEmail()));

بازگشت

User[] — آرایه‌ای از کاربران با مجوز پاسخ‌دهنده.

مجوز

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

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

getPublishedUrl()

آدرس اینترنتی (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',
);

// 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() بازیابی کرد.

پارامترها

نام نوع توضیحات
response Id 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()

URL ای را که می‌توان برای مشاهده خلاصه‌ای از پاسخ‌های فرم استفاده کرد، دریافت می‌کند. مگر اینکه 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 - آدرس اینترنتی برای مشاهده خلاصه‌ای از پاسخ‌ها.

مجوز

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

  • 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 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

isPublished()

مشخص می‌کند که آیا فرم منتشر شده است یا خیر.

این ویژگی فقط برای فرم‌هایی که از انتشار پشتیبانی می‌کنند در دسترس است. supportsAdvancedResponderPermissions() برای بررسی اینکه آیا فرم از انتشار پشتیبانی می‌کند یا خیر، استفاده کنید.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl(
    'https://docs.google.com/forms/d/abc123456/edit',
);

// Checks whether the form is published or not and logs it to the console.
console.log(form.isPublished());

بازگشت

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

پرتاب‌ها

Error — اگر در فرم‌های پشتیبانی نشده فراخوانی شود.

مجوز

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

  • 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 موردی که باید جابجا شود.
to Index 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 در یک درایو مشترک باشد که کاربر می‌تواند به آن دسترسی داشته باشد.

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

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Removes the editor from the form.
// TODO(developer): replace the emailAddress.
form.removeEditor('editor@uni.edu');

پارامترها

نام نوع توضیحات
email Address String آدرس ایمیل کاربر برای حذف.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

removeEditor(user)

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

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

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the editors from the form.
const users = form1.getEditors();

// Opens another form.
// TODO(developer): Replace the URL with your own.
const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit');

// Removes editors from the form.
users.forEach(user => form2.removeEditor(user));

پارامترها

نام نوع توضیحات
user User نماینده‌ای از کاربر که باید حذف شود.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

removePublishedReader(emailAddress)

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

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

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Removes the responders from the form.
// TODO(developer): replace the emailAddress.
form.removePublishedReader('responder1@uni.edu');

پارامترها

نام نوع توضیحات
email Address String آدرس ایمیل کاربر برای حذف.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

removePublishedReader(user)

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

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

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the responders from the form.
const users = form1.getPublishedReaders();

// Opens another form.
// TODO(developer): Replace the URL with your own.
const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit');

// Removes responders from the form.
users.forEach(user => form2.removePublishedReader(user));

پارامترها

نام نوع توضیحات
user User نماینده‌ای از کاربر که باید حذف شود.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

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 ، برای زنجیره‌سازی.

پرتاب‌ها

Error — اگر در فرم منتشر نشده فعال باشد.

مجوز

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

  • 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 Destination Type نوع مقصد پاسخ فرم.
id String شناسه‌ی مقصد پاسخ فرم.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

پرتاب‌ها

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

مجوز

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

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

setIsQuiz(enabled)

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

سوالات نمره‌دار فقط در آزمون‌ها مجاز هستند، بنابراین تنظیم این گزینه روی 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',
);

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

setPublished(enabled)

تنظیم می‌کند که آیا فرم منتشر شود یا خیر. مقدار پیش‌فرض برای فرم‌های جدید true است.

این ویژگی فقط برای فرم‌هایی که از انتشار پشتیبانی می‌کنند در دسترس است. supportsAdvancedResponderPermissions() برای بررسی اینکه آیا فرم از انتشار پشتیبانی می‌کند یا خیر، استفاده کنید.

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

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl(
    'https://docs.google.com/forms/d/abc123456/edit',
);

// Publishes the form before sharing it.
form.setPublished(true);

// Checks whether the form is published or not and logs it to the console.
console.log(form.isPublished());

پارامترها

نام نوع توضیحات
enabled Boolean اگر فرم باید منتشر شود، true و در غیر این صورت false .

بازگشت

Form — این Form ، برای زنجیره‌سازی.

پرتاب‌ها

Error — اگر در فرم‌های پشتیبانی نشده فراخوانی شود.

مجوز

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

  • 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

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 طولانی متعلق به فرم‌های گوگل نباشد، استثنا ایجاد می‌کند.

پارامترها

نام نوع توضیحات
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 Form Response[] آرایه‌ای از تمام پاسخ‌های فرم.

بازگشت

Form — این Form ، برای زنجیره‌سازی.

مجوز

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

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

supportsAdvancedResponderPermissions()

تعیین می‌کند که آیا فرم از قابلیت انتشار پشتیبانی می‌کند یا خیر. این متد برای تعیین اینکه آیا متدهای setPublished(enabled) و isPublished() و مجوزهای پاسخ‌دهنده در دسترس هستند یا خیر، استفاده می‌شود.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl(
    'https://docs.google.com/forms/d/abc123456/edit',
);

// Checks whether the form supports publishing or not and logs it to the
// console.
console.log(form.supportsAdvancedResponderPermissions());

بازگشت

Boolean - اگر فرم از انتشار پشتیبانی کند، true و اگر پشتیبانی نکند false برمی‌گرداند.

مجوز

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

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

متدهای منسوخ شده