# الحسابات

تُستخدم الحسابات لإنشاء حقول مخفية تقوم تلقائيًا بحساب قيم بناءً على إجابات أخرى في النموذج.

في XLSForm، تُعرّف الحسابات باستخدام `نوع السؤال calculate` هذه الحقول لا تُعرض للمستخدم، لكنها تعمل في الخلفية وتخزن النتائج لاستخدامها لاحقًا أو لتحليلها.

في ngSurvey، سيتم حفظ القيم المحسوبة كحقول مخفية وتضمينها في مخرجات بيانات النموذج، مثلها مثل الإجابات الأخرى.

## 🔢 كيفية تعريف حساب

لإنشاء حساب:

1. استخدم نوع `نوع السؤال calculate` في `ورقة survey` في ورقة survey.
2. عيّن اسمًا للحقل.
3. استخدم `عمود calculation` لتعريف المنطق.
4. اختياريًا، استخدم عمود `label` للاستخدام الداخلي (لن يُعرض على المستخدم).

#### مثال: مجموع النقاط من إجابات متعددة

| النوع                | الاسم        | عمود calculation      |
| -------------------- | ------------ | --------------------- |
| integer              | q1           |                       |
| integer              | q2           |                       |
| integer              | q3           |                       |
| نوع السؤال calculate | total\_score | ${q1} + ${q2} + ${q3} |

في هذا المثال:

* يجيب المستخدم عن ثلاثة أسئلة رقمية (`q1`, `q2`, `q3`).
* الـ `total_score` يقوم الحقل بجمع تلك القيم الثلاث معًا.
* قيمة `total_score` يتم حفظها في بيانات النموذج، حتى لو لم تُعرض أبداً.

#### دوال حسابية مفيدة

يمكنك استخدام معظم العاملات والدوال القياسية، مثل:

* رياضيات: `+`, `-`, `*`, `div`, `mod`
* نص:  `string-length(), regex, round, substr, concat`
* منطق: `if(condition, true, false)`, `coalesce()`
* التواريخ: `today()`, `now()`, `date()`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ngsurvey.com/ar/projects/import-export/xlsform/wrqh-alastbyan/alhsabat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
