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

الطُرق

الطريقةنوع القيمة التي تم إرجاعهاوصف قصير
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تضيف هذه السمة عنصر سؤال جديدًا يتيح للمستجيب إدخال فقرة نصية.
addPublishedReader(emailAddress)Formتضيف هذه الطريقة المستخدم المحدّد إلى قائمة المستجيبين لـ Form.
addPublishedReader(user)Formتضيف هذه الطريقة المستخدم المحدّد إلى قائمة المستجيبين لـ Form.
addPublishedReaders(emailAddresses)Formتضيف هذه الطريقة مصفوفة المستخدمين المحدّدة إلى قائمة المستجيبين لـ Form.
addRatingItem()RatingItemتضيف هذه الطريقة عنصر سؤال جديدًا يتيح للمجيب تقديم تقييم.
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تعرض هذه الدالة عنوان URL الذي يمكن استخدامه للوصول إلى وضع تعديل النموذج.
getEditors()User[]تعرض هذه الطريقة قائمة بالمحرّرين لـ Form.
getId()Stringتعرض هذه الدالة رقم تعريف النموذج.
getItemById(id)Item|nullتعرض هذه الطريقة السلعة التي تحمل رقم تعريف معيّنًا.
getItems()Item[]تعرض هذه الطريقة مصفوفة تتضمّن جميع العناصر في النموذج.
getItems(itemType)Item[]تعرض هذه الطريقة صفيفًا يتضمّن جميع العناصر من نوع معيّن.
getPublishedReaders()User[]تعرض هذه الطريقة قائمة المجيبين عن Form.
getPublishedUrl()Stringتعرض هذه الدالة عنوان URL الذي يمكن استخدامه للردّ على النموذج.
getResponse(responseId)FormResponseيحصل على ردّ واحد على النموذج استنادًا إلى رقم تعريف الردّ.
getResponses()FormResponse[]تعرض هذه الطريقة مصفوفة تتضمّن جميع الردود على النموذج.
getResponses(timestamp)FormResponse[]تعرض هذه الدالة مصفوفة تتضمّن جميع ردود النموذج بعد تاريخ ووقت محدّدَين.
getShuffleQuestions()Booleanتحدّد هذه السمة ما إذا كان ترتيب الأسئلة على كل صفحة من النموذج عشوائيًا.
getSummaryUrl()Stringتعرض هذه الدالة عنوان URL الذي يمكن استخدامه لعرض ملخّص لردود النموذج.
getTitle()Stringتعرض هذه الدالة عنوان النموذج.
hasLimitOneResponsePerUser()Booleanتحدِّد ما إذا كان النموذج يسمح بردّ واحد فقط لكل مستجيب.
hasProgressBar()Booleanتحدّد هذه السمة ما إذا كان النموذج يعرض شريط تقدّم.
hasRespondAgainLink()Booleanتحدّد ما إذا كان النموذج يعرض رابطًا لإرسال رد آخر بعد أن يكمل المجيب النموذج.
isAcceptingResponses()Booleanتحدّد ما إذا كان النموذج يقبل الردود حاليًا.
isPublished()Booleanتحدّد هذه السمة ما إذا كان النموذج منشورًا.
isPublishingSummary()Booleanتحدّد ما إذا كان النموذج يعرض رابطًا للاطّلاع على ملخّص الردود بعد أن يكمل المجيب النموذج.
isQuiz()Booleanتحدّد ما إذا كان النموذج اختبارًا.
moveItem(from, to)Itemتنقل هذه الدالة عنصرًا في فهرس معيّن بين جميع العناصر في النموذج إلى فهرس آخر معيّن.
moveItem(item, toIndex)Itemتنقل هذه السمة عنصرًا معيّنًا إلى فهرس معيّن بين جميع العناصر في النموذج.
removeDestination()Formلإلغاء ربط النموذج بوجهة الرد الحالية
removeEditor(emailAddress)Formتزيل هذه السمة المستخدم المحدّد من قائمة المحرّرين في Form.
removeEditor(user)Formتزيل هذه السمة المستخدم المحدّد من قائمة المحرّرين في Form.
removePublishedReader(emailAddress)Formيزيل هذا الإجراء المستخدم المحدّد من قائمة المستجيبين لـ Form.
removePublishedReader(user)Formيزيل هذا الإجراء المستخدم المحدّد من قائمة المستجيبين لـ Form.
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تضبط هذه السمة ما إذا كان النموذج يتضمّن شريط تقدّم.
setPublished(enabled)Formتضبط هذه السمة ما إذا كان النموذج منشورًا.
setPublishingSummary(enabled)Formتحدّد ما إذا كان النموذج يعرض رابطًا للاطّلاع على ملخّص الردود بعد أن يرسل المجيب النموذج.
setShowLinkToRespondAgain(enabled)Formتحدّد ما إذا كان النموذج يعرض رابطًا لإرسال رد آخر بعد أن يكمل المستجيب النموذج.
setShuffleQuestions(shuffle)Formتحدّد هذه السمة ما إذا كان ترتيب الأسئلة في كل صفحة من النموذج عشوائيًا.
setTitle(title)Formتضبط هذه السمة عنوان النموذج.
shortenFormUrl(url)Stringتحويل عنوان URL طويل خاص بنموذج إلى عنوان URL قصير
submitGrades(responses)Formيرسل الدرجات لردود النماذج المحدّدة.
supportsAdvancedResponderPermissions()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');

المعلمات

الاسمالنوعالوصف
emailAddressStringعنوان البريد الإلكتروني للمستخدم الذي تريد إضافته

الإرجاع

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

المعلمات

الاسمالنوعالوصف
userUserتمثيل للمستخدم الذي تريد إضافته

الإرجاع

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

المعلمات

الاسمالنوعالوصف
emailAddressesString[]مصفوفة من عناوين البريد الإلكتروني للمستخدمين الذين تريد إضافتهم

الإرجاع

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

المعلمات

الاسمالنوعالوصف
emailAddressStringعنوان البريد الإلكتروني للمستخدم الذي تريد إضافته

الإرجاع

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

المعلمات

الاسمالنوعالوصف
userUserتمثيل للمستخدم الذي تريد إضافته

الإرجاع

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

المعلمات

الاسمالنوعالوصف
emailAddressesString[]مصفوفة من عناوين البريد الإلكتروني للمستخدمين الذين تريد إضافتهم

الإرجاع

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

الإرجاع

Booleantrue إذا كان النموذج يعرض الرابط "تعديل ردك"، 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);
}

المعلمات

الاسمالنوعالوصف
indexIntegerفهرس العنصر بين جميع العناصر في النموذج

عمليات الطرح

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

المعلمات

الاسمالنوعالوصف
itemItemالعنصر المطلوب حذفه

عمليات الطرح

Error: إذا لم يكن العنصر متوفّرًا في النموذج

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

deleteResponse(responseId)

يحذف هذا الإجراء ردًا واحدًا من مستودع الردود في النموذج. لا تحذف هذه الطريقة نُسخ الردود المخزّنة في وجهة ردود خارجية (مثل جدول بيانات)، ولكنها تزيل الرد من عرض الملخّص للنموذج. يمكن استرداد رقم تعريف الردّ باستخدام FormResponse.getId().

المعلمات

الاسمالنوعالوصف
responseIdStringرقم تعريف الردّ على النموذج المطلوب حذفه

الإرجاع

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

تعرض هذه الطريقة عنوان 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)

تعرض هذه الطريقة السلعة التي تحمل رقم تعريف معيّنًا. تعرِض هذه السمة القيمة 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);

المعلمات

الاسمالنوعالوصف
idIntegerمعرّف السلعة.

الإرجاع

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

المعلمات

الاسمالنوعالوصف
itemTypeItemTypeنوع العناصر المطلوب استردادها.

الإرجاع

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

المعلمات

الاسمالنوعالوصف
responseIdStringرقم تعريف الردّ على النموذج

الإرجاع

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)

تعرض هذه الدالة مصفوفة تتضمّن جميع ردود النموذج بعد تاريخ ووقت محدّدَين.

المعلمات

الاسمالنوعالوصف
timestampDateأبكر تاريخ ووقت يجب عرض ردود النموذج فيهما

الإرجاع

FormResponse[]: قائمة الردود على النموذج

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

getShuffleQuestions()

تحدّد هذه السمة ما إذا كان ترتيب الأسئلة على كل صفحة من النموذج عشوائيًا.

الإرجاع

Booleantrue إذا كان ترتيب الأسئلة على كل صفحة من النموذج عشوائيًا، 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: عنوان 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());

الإرجاع

Booleantrue إذا كان النموذج يعرض الرابط "إرسال رد آخر"، 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);

الإرجاع

Booleantrue إذا كان النموذج يعرض الرابط "عرض الردود السابقة"، 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);

المعلمات

الاسمالنوعالوصف
fromIntegerالفهرس الحالي للعنصر بين جميع العناصر في النموذج
toIntegerالفهرس الجديد للعنصر بين جميع العناصر في النموذج

الإرجاع

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

المعلمات

الاسمالنوعالوصف
itemItemالعنصر المطلوب نقله
toIndexIntegerالفهرس الجديد للعنصر بين جميع العناصر في النموذج

الإرجاع

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، يؤدي ذلك أيضًا إلى إزالة المستخدم من قائمة المشاهدين والمستجيبين.

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

المعلمات

الاسمالنوعالوصف
emailAddressStringعنوان البريد الإلكتروني للمستخدم الذي تريد إزالته

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

removeEditor(user)

تزيل هذه السمة المستخدم المحدّد من قائمة المحرّرين في Form. لا تمنع هذه الطريقة المستخدمين من الوصول إلى Form إذا كانوا ينتمون إلى فئة من المستخدمين لديهم إذن عام بالوصول، مثلاً إذا تمت مشاركة Form مع النطاق الكامل للمستخدم، أو إذا كان Form في مساحة تخزين سحابي مشتركة يمكن للمستخدم الوصول إليها.

بالنسبة إلى ملفات Drive، تؤدي هذه العملية أيضًا إلى إزالة المستخدم من قائمة المشاهدين.

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

المعلمات

الاسمالنوعالوصف
userUserتمثيل للمستخدم المطلوب إزالته

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

removePublishedReader(emailAddress)

يزيل هذا الإجراء المستخدم المحدّد من قائمة المستجيبين لـ Form. لا تمنع هذه الطريقة المستخدمين من الوصول إلى Form إذا كانوا ينتمون إلى فئة من المستخدمين لديهم إذن وصول عام، مثلاً، إذا تمت مشاركة Form مع النطاق الكامل للمستخدم، أو إذا كان Form في مساحة تخزين سحابي مشتركة يمكن للمستخدم الوصول إليها.

بالنسبة إلى ملفات Drive، يؤدي ذلك أيضًا إلى إزالة المستخدم من قائمة المشاهدين والمحرّرين.

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

المعلمات

الاسمالنوعالوصف
emailAddressStringعنوان البريد الإلكتروني للمستخدم الذي تريد إزالته

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

removePublishedReader(user)

يزيل هذا الإجراء المستخدم المحدّد من قائمة المستجيبين لـ Form. لا تمنع هذه الطريقة المستخدمين من الوصول إلى Form إذا كانوا ينتمون إلى فئة من المستخدمين لديهم إذن وصول عام، مثلاً، إذا تمت مشاركة Form مع النطاق الكامل للمستخدم، أو إذا كان Form في مساحة تخزين سحابي مشتركة يمكن للمستخدم الوصول إليها.

بالنسبة إلى ملفات Drive، يؤدي ذلك أيضًا إلى إزالة المستخدم من قائمة المشاهدين والمحرّرين.

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

المعلمات

الاسمالنوعالوصف
userUserتمثيل للمستخدم المطلوب إزالته

الإرجاع

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

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان النموذج سيقبل الردود، 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());

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان النموذج سيعرض رابط "تعديل ردّك"، 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);

المعلمات

الاسمالنوعالوصف
collectBooleantrue إذا كان النموذج سيجمع عناوين البريد الإلكتروني، 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);

المعلمات

الاسمالنوعالوصف
messageStringرسالة التأكيد الجديدة للنموذج

الإرجاع

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

المعلمات

الاسمالنوعالوصف
messageStringالرسالة التي سيتم عرضها إذا كان النموذج لا يقبل الردود.

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setDescription(description)

تضبط هذه السمة وصف النموذج.

المعلمات

الاسمالنوعالوصف
descriptionStringالوصف الجديد للنموذج.

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setDestination(type, id)

تضبط هذه السمة الوجهة التي يتم فيها حفظ ردود النموذج. تحفظ جميع النماذج، بما في ذلك تلك التي لم يتم ضبط وجهة لها بشكل صريح، نسخة من الردود في مستودع الردود الخاص بالنموذج.

المعلمات

الاسمالنوعالوصف
typeDestinationTypeنوع وجهة الردّ على النموذج
idStringرقم تعريف وجهة الردود على النموذج

الإرجاع

Form: هذا Form، للسلاسل.

عمليات الطرح

Error: إذا كان معرّف الوجهة المحدّد غير صالح

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setIsQuiz(enabled)

تضبط هذه السمة ما إذا كان النموذج اختبارًا. القيمة التلقائية للنماذج الجديدة هي false.

لا يُسمح بالأسئلة التي تتضمّن درجات إلا في "الاختبارات"، لذا سيؤدي ضبط هذا الخيار على false إلى إزالة جميع خيارات وضع الدرجات من جميع الأسئلة.

لا تتوفّر إعدادات الاختبار إلا في واجهة مستخدم "نماذج 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',
);

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

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان يجب تفعيل ميزات الاختبار في النموذج، false إذا لم يكن يجب ذلك.

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setLimitOneResponsePerUser(enabled)

تضبط هذه السمة ما إذا كان النموذج يسمح بردّ واحد فقط لكل مجيب. القيمة التلقائية للنماذج الجديدة هي false. في حال ضبط القيمة على true، لن يتمكّن النص البرمجي من إرسال ردود النموذج على الإطلاق.

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان النموذج يجب أن يسمح برد واحد فقط لكل مجيب، 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());

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان النموذج يعرض شريط تقدّم، 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());

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان يجب نشر النموذج، false إذا لم يكن كذلك.

الإرجاع

Form: هذا Form، للسلاسل.

عمليات الطرح

Error: إذا تم استدعاؤها في نماذج غير متوافقة

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setPublishingSummary(enabled)

تحدّد ما إذا كان النموذج يعرض رابطًا للاطّلاع على ملخّص الردود بعد أن يرسل المجيب النموذج. القيمة التلقائية للنماذج الجديدة هي false.

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان النموذج سيعرض الرابط "عرض الردود السابقة"، false إذا لم يكن سيعرضه

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setShowLinkToRespondAgain(enabled)

تحدّد ما إذا كان النموذج يعرض رابطًا لإرسال رد آخر بعد أن يكمل المستجيب النموذج. القيمة التلقائية للنماذج الجديدة هي true.

المعلمات

الاسمالنوعالوصف
enabledBooleantrue إذا كان النموذج سيعرض الرابط "إرسال رد آخر"، false إذا لم يكن كذلك

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setShuffleQuestions(shuffle)

تحدّد هذه السمة ما إذا كان ترتيب الأسئلة في كل صفحة من النموذج عشوائيًا.

المعلمات

الاسمالنوعالوصف
shuffleBooleantrue إذا كان يجب ترتيب الأسئلة بشكل عشوائي على كل صفحة من صفحات النموذج، false إذا لم يكن كذلك.

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

setTitle(title)

تضبط هذه السمة عنوان النموذج.

المعلمات

الاسمالنوعالوصف
titleStringتمثّل هذه السمة العنوان الجديد للنموذج.

الإرجاع

Form: هذا Form، للسلاسل.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

shortenFormUrl(url)

تحويل عنوان URL طويل خاص بنموذج إلى عنوان URL قصير يُنشئ هذا الإجراء استثناءً إذا كان عنوان URL الطويل لا ينتمي إلى "نماذج Google".

المعلمات

الاسمالنوعالوصف
urlStringتمثّل هذه السمة عنوان URL المطلوب اختصاره.

الإرجاع

String: عنوان URL بالتنسيق http://goo.gl/forms/1234

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

submitGrades(responses)

يرسل الدرجات لردود النماذج المحدّدة.

إذا كان الرمز يتضمّن مشغّلاً onFormSubmit، سيؤدي استدعاء submitGrades() إلى تشغيل شرط onFormSubmit والتسبّب في حدوث حلقة لا نهائية. لمنع حدوث حلقة لا نهائية، أضِف رمزًا برمجيًا يتحقّق مما إذا كانت الدرجات متوفّرة قبل استدعاء submitGrades().

المعلمات

الاسمالنوعالوصف
responsesFormResponse[]مصفوفة تتضمّن جميع الردود على النموذج

الإرجاع

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

الإرجاع

Booleantrue إذا كان النموذج يتيح النشر، وfalse إذا كان لا يتيح ذلك.

التفويض

تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام واحد أو أكثر من النطاقات التالية:

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

الطُرق المتوقّفة نهائيًا