Skip to content

Commit 3bc3d42

Browse files
مصطفى
1 parent 007937d commit 3bc3d42

1 file changed

Lines changed: 49 additions & 39 deletions

File tree

templates/standalone/helloWorld.gs

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,57 @@
11
/**
2-
* Copyright 2018 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
2+
* تشغيل هذه الدالة لإنشاء نموذج Google Forms مع Google Sheet مرتبط
3+
* ثم سيتم طباعة روابط النموذج والجدول في سجل التنفيذ (Logger.log).
154
*/
16-
// [START apps_script_hello_world]
17-
/**
18-
* Creates a Google Doc and sends an email to the current user with a link to the doc.
19-
*/
20-
function createAndSendDocument() {
21-
try {
22-
// Create a new Google Doc named 'Hello, world!'
23-
const doc = DocumentApp.create('Hello, world!');
24-
25-
// Access the body of the document, then add a paragraph.
26-
doc.getBody().appendParagraph('This document was created by Google Apps Script.');
5+
function createForm() {
6+
// اسم النموذج
7+
var formTitle = "نموذج تسجيل البيانات";
8+
var form = FormApp.create(formTitle);
9+
10+
// اسألنا عن الحقول اللي بعثتهم — إضافة العناصر:
11+
form.addTextItem().setTitle("الاسم الثلاثي").setRequired(true);
12+
form.addTextItem().setTitle("اسم الاب").setRequired(true);
13+
form.addTextItem().setTitle("اسم الأم").setRequired(true);
14+
form.addTextItem().setTitle("مكان وتاريخ الولادة").setRequired(true);
15+
form.addTextItem().setTitle("السكن السابق").setRequired(true);
16+
form.addTextItem().setTitle("السكن الحالي").setRequired(true);
17+
form.addTextItem().setTitle("العمل قبل الثورة").setRequired(false);
18+
form.addTextItem().setTitle("العمل بعد الثورة").setRequired(false);
2719

28-
// Get the URL of the document.
29-
const url = doc.getUrl();
20+
// الشهادة العلمية — خيارات
21+
var eduItem = form.addMultipleChoiceItem();
22+
eduItem.setTitle("الشهاده العلميه").setRequired(false);
23+
eduItem.setChoices([
24+
eduItem.createChoice("ابتدائي"),
25+
eduItem.createChoice("اعدادي"),
26+
eduItem.createChoice("تعليم اساسي"),
27+
eduItem.createChoice("ثانوي"),
28+
eduItem.createChoice("معهد متوسط"),
29+
eduItem.createChoice("اجازه"),
30+
eduItem.createChoice("اخرى")
31+
]);
3032

31-
// Get the email address of the active user - that's you.
32-
const email = Session.getActiveUser().getEmail();
33+
form.addTextItem().setTitle("الحاله الاجتماعيه").setRequired(false);
34+
form.addTextItem().setTitle("عدد الزوجات").setRequired(false);
35+
form.addTextItem().setTitle("اسم الزوجة").setRequired(false);
36+
form.addTextItem().setTitle("عدد الولاد").setRequired(false);
37+
form.addTextItem().setTitle("رقم البطاقة الشخصية").setRequired(true);
38+
form.addTextItem().setTitle("زمرة الدم").setRequired(true);
39+
form.addTextItem().setTitle("رقم واتس أب").setRequired(true);
40+
form.addTextItem().setTitle("حساب شام كاش").setRequired(true);
41+
form.addTextItem().setTitle("نوع السلاح").setRequired(true);
42+
form.addTextItem().setTitle("رقم السلاح").setRequired(true);
3343

34-
// Get the name of the document to use as an email subject line.
35-
const subject = doc.getName();
44+
// إضافة فاصل أو وصف بسيط
45+
form.addSectionHeaderItem().setTitle("ملاحظة");
46+
form.addParagraphTextItem().setTitle("ملاحظات إضافية (اختياري)").setRequired(false);
3647

37-
// Append a new string to the "url" variable to use as an email body.
38-
const body = 'Link to your doc: ' + url;
48+
// ربط النموذج مع Google Sheets جديد
49+
var sheetName = formTitle + " - ردود";
50+
var ss = SpreadsheetApp.create(sheetName);
51+
form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
3952

40-
// Send yourself an email with a link to the document.
41-
GmailApp.sendEmail(email, subject, body);
42-
} catch (err) {
43-
// TODO (developer) - Handle exception
44-
console.log('Failed with error %s', err.message);
45-
}
53+
// طباعة الروابط في السجل لتسهيل الوصول
54+
Logger.log("رابط النموذج: " + form.getPublishedUrl());
55+
Logger.log("رابط التعديل للنموذج (edit): " + form.getEditUrl());
56+
Logger.log("رابط Google Sheet المرتبط: " + ss.getUrl());
4657
}
47-
// [END apps_script_hello_world]

0 commit comments

Comments
 (0)