لمنح منشئي النماذج المزيد من التحكّم في تحديد المستخدمين الذين يمكنهم الردّ، سنقدّم أدوات تحكّم دقيقة للمجيبين. ستكون النماذج التي تم إنشاؤها باستخدام واجهة برمجة التطبيقات بعد 31 مارس 2026 في حالة "غير منشور" تلقائيًا. لمزيد من المعلومات، يُرجى الاطّلاع على
التغييرات في واجهة برمجة التطبيقات في "نماذج Google".
نموذج تطبيق ويب "برمجة تطبيقات Google"
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تقدّم هذه الصفحة نظرة عامة على مثال تطبيق الويب في Apps Script لواجهة برمجة التطبيقات
Google Forms API.
المتطلبات الأساسية
- فعِّل واجهة برمجة التطبيقات Forms API في مشروعك على Google Cloud.
- إعداد مشروع جديد في Apps Script كما هو موضّح في ملف README على GitHub
لنموذج تطبيق الويب
نظرة عامة
تسمح واجهة برمجة التطبيقات Forms API لأي عميل تمّت مصادقته بالوصول إلى واجهة برمجة التطبيقات
مباشرةً باستخدام REST.
بما أنّ Apps Script توفّر طريقة سهلة للحصول على رمز مميز صالح للوصول إلى OAuth وإجراء طلبات REST، فإنه من السهل دمج Apps Script مباشرةً مع Forms API.
توفّر أداة "برمجة التطبيقات" حاليًا
خدمة نماذج Google، التي تسمح للنصوص البرمجية بإنشاء "نماذج Google"
والوصول إليها وتعديلها. ومع ذلك، إذا كنت تفضّل استخدام واجهة برمجة التطبيقات
Forms API مباشرةً من Apps Script، يمكنك إعداد إذن الوصول باستخدام OAuth على النحو التالي:
الحصول على رمز دخول عبر OAuth مصادق عليه ومحدد النطاق
ScriptApp.getOAuthToken();
أدرِج رمز OAuth المميّز في وسيطة options المقدَّمة في أي طلبات REST
لواجهة برمجة التطبيقات.
UrlFetchApp.fetch(Url, options);
اطّلِع على مقالة إعداد مشروع Apps Script للحصول على مثال على ذلك. يوضّح دليل الإعداد التفاصيل الأساسية
للاتصال بواجهة برمجة التطبيقات، ولكن لتوفير إمكانية وصول سهلة إلى واجهة برمجة التطبيقات
للمستخدمين النهائيين، يمكنك أيضًا تجربة نموذج تطبيق الويب وتعديله.
مثال على استخدام تطبيق الويب
يتوفّر على GitHub مثال كامل لتطبيق ويب يستدعي جميع طرق Forms API مباشرةً بغرض التوضيح.
تشغيل تطبيق الويب
بعد إعداد مشروعك ونشره كتطبيق ويب، يمكنك تجربة بعض
العمليات الأساسية.
أنشئ نموذجًا جديدًا بالنقر على الزر إنشاء نموذج.
يظهر النموذج الجديد الآن في حقل معرّف النموذج: ويمكنك فتحه من خلال
النقر على الفتح في "نماذج Google".
بعد فتح النموذج الجديد في نافذة منفصلة، حاوِل إضافة بعض الأسئلة
يدويًا، ثم انقر على الحصول على النموذج حسب رقم التعريف وستظهر لك أسئلتك الجديدة
في إخراج JSON على يسار الصفحة.
لا تتردد في استكشاف الطرق الأخرى المتاحة في التطبيق وملاحظة
النتيجة على يسار كل عملية.
العمل مع ساعات "نماذج Google"
لاحِظ أيضًا أزرار نماذج
الساعات. وتستخدم هذه الطلبات ميزة "عمليات المراقبة" في Forms API وتُجري عمليات أساسية لإنشاء عمليات المراقبة وإدراجها وحذفها وتجديدها. ولاستخدامها، عليك إعداد مشروع يتضمّن مواضيع
Cloud Pub/Sub.
لمزيد من المعلومات عن عمليات المراقبة في Forms API وCloud Pub/Sub، يُرجى الاطّلاع على مقالة
إعداد الإشعارات الفورية وتلقّيها.
الخطوات التالية
جرِّب تخصيص نموذج التطبيق بما يناسب احتياجاتك. وفي ما يلي بعض الأمثلة على ذلك:
- أنشئ بنك أسئلة في جدول بيانات Google، ثم استخدِم خدمة Apps Script
SpreadsheetApp
لاسترداد الأسئلة من جدول بيانات لملء نماذج جديدة.
- بدلاً من ذلك، يمكن أن يتوفّر بنك الأسئلة في قاعدة بيانات SQL حيث
يمكنك استخدام Apps Script
خدمة JDBC لتعبئة النماذج بمواد
أسئلة من قاعدة البيانات.
- أنشئ اختبارًا واحفظ النتائج في دفتر الدرجات في "جداول بيانات Google".
- يمكنك إعداد مشروعك باستخدام Cloud Pub/Sub واستخدام ميزة
ساعات لمحاولة
إنشاء قائمة صدارة للطلاب في الوقت الفعلي لعرض نتائج الاختبار.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-04-09 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-04-09 (حسب التوقيت العالمي المتفَّق عليه)"],[],["This content details using Apps Script with the Google Forms API. Key actions include enabling the Forms API and setting up an Apps Script project. It demonstrates obtaining an OAuth access token via `ScriptApp.getOAuthToken()` and making REST calls with `UrlFetchApp.fetch()`. A web app example allows users to create forms, view them by ID, and interact with API methods. Additionally, it highlights the use of Forms API watches with Cloud Pub/Sub for creating, listing, deleting, and renewing watches. The app can be customized to suit specific needs.\n"],null,["# Apps Script sample web app\n\nThis page provides an overview of the Apps Script web app example for the\nGoogle Forms API.\n\nPrerequisites\n-------------\n\n- Enable the Forms API in your Google Cloud project.\n- Set up a new Apps Script project as described in the [GitHub README file](https://github.com/googleworkspace/apps-script-samples/blob/main/forms-api/demos/AppsScriptFormsAPIWebApp/README.md) for the sample web app.\n\nOverview\n--------\n\nThe Forms API allows any authenticated client to access the API\ndirectly using [REST](https://www.codecademy.com/article/what-is-rest).\n\nBecause Apps Script provides an easy way to obtain both a valid\n[OAuth Access Token](https://oauth.net/2/access-tokens/) and make REST calls,\nit's straightforward to integrate Apps Script directly with the Forms API.\nApps Script already provides an existing\n[Forms Service](/apps-script/reference/forms), which allows scripts to create,\naccess, and modify Google Forms. However, if you prefer to use the\nForms API directly from Apps Script, set up OAuth access as follows:\n\n1. Get a scoped and authenticated OAuth access token.\n\n `ScriptApp.getOAuthToken();`\n2. Include the OAuth token in the *options* argument provided in any REST\n calls to the API.\n\n `UrlFetchApp.fetch(Url, options);`\n\nSee\n[Set up an Apps Script project](/workspace/forms/api/guides/forms-apps-script)\nfor an example of this in action. The setup guide details the basic plumbing\nneeded to call the API---however, to provide intuitive access to the API for\nend users, you can also try out and modify our sample web app.\n\nWeb app example usage\n---------------------\n\nA complete example web app that calls all of the Forms API methods directly\nis available on\n[GitHub](https://github.com/googleworkspace/apps-script-samples/tree/main/forms-api/demos/AppsScriptFormsAPIWebApp)\nfor demonstration purposes.\n\n### Running the web app\n\nOnce you've set up your project and deployed it as a Web app, you can try some\nbasic operations.\n\n1. Create a new form by clicking the **Create Form** button.\n\n The new form is now visible in the **Form id:** field and you can open it by\n clicking **Open in Forms**.\n2. After opening the new form in a separate window, try adding a few questions\n manually, then click **Get Form by Id** and you'll see your new questions\n in the JSON output on the right.\n\nFeel free to explore the other methods available in the app and observe the\noutput on the right for each operation.\n\n### Working with Forms watches\n\nNotice also the buttons for forms\n[watches](/workspace/forms/api/reference/rest/v1/forms.watches). These use the\nForms API watches feature and perform basic operations to\ncreate, list, delete and renew watches. You need to set up a project with\n[Cloud Pub/Sub](https://cloud.google.com/pubsub) topics to use them.\n\nFor more information on Forms API watches and Cloud Pub/Sub, see\n[Set up and receive push notifications](/workspace/forms/api/guides/push-notifications).\n\nNext steps\n----------\n\nTry customizing the example app to suit your needs. Here are a few examples:\n\n- Create a *question bank* in a Google sheet, and then use the Apps Script [SpreadsheetApp](/apps-script/reference/spreadsheet/spreadsheet-app) service to fetch questions from a sheet to populate new forms.\n- Alternatively, your question bank can reside in a SQL database where you can use the Apps Script [JDBC Service](/apps-script/reference/jdbc) to populate forms with questions from the database.\n- Generate a quiz and save the scores in a Google sheet grade book.\n- Set up your project with Cloud Pub/Sub and use the [watches](/workspace/forms/api/guides/push-notifications) feature to generate a real-time student leaderboard to display quiz results."]]