> ## Documentation Index
> Fetch the complete documentation index at: https://docs.didit.me/llms.txt
> Use this file to discover all available pages before exploring further.

# تقرير الاستبيان: مخطط JSON للإجابات

> مرجع تقرير الاستبيان في Didit: يشرح الأقسام والعناصر وأنواع العناصر والظهور الشرطي وإجابات كل عنصر في استجابات القرار V3.

يحتوي تقرير الاستبيان على النموذج المنظم الذي عُرض على المستخدم، والمسار الذي اتخذه عبر أي فروع شرطية، والإجابة الخاصة بكل عنصر مرئي. ويتم إرجاعه لكل عقدة، لذلك تحتوي مسارات سير العمل متعددة المثيلات (على سبيل المثال، استبيان واحد لكل UBO) على إدخال واحد لكل تكرار.

![تقرير استبيان Didit KYC يعرض الإجابات المنظمة والأقسام وأنواع العناصر](https://mintcdn.com/didit-0f962782/z6T2GHM4Zh-iSj-K/images/questionnaire-report.png?fit=max\&auto=format\&n=z6T2GHM4Zh-iSj-K\&q=85\&s=9e483a61e829c6b94dd2dc7592a2c59b)

## نظرة عامة

يصف كل رد على استبيان ما يلي:

* **إصدار الاستبيان** الذي رآه المستخدم (العنوان والوصف واللغات والبيانات الوصفية للإصدار والأقسام).
* **العناصر المرئية** للمسار الذي سلكه المستخدم بالفعل عبر مخطط النموذج — ويتم استبعاد العناصر المخفية بواسطة المنطق الشرطي من الرد.
* **الإجابة** لكل عنصر تفاعلي مرئي، بالشكل الذي يتطابق مع `element_type` الخاص به.
* **حالة** واحدة للرد ككل.

تتم إعادة تشكيل عناصر التنسيق بدلاً من الإجابة عليها: يصبح كل `SECTION_HEADER` حداً فاصلاً للقسم (يصبح عنوانه ووصفه هما `title`/`description` للقسم)، بينما تظل `HEADING` و`PARAGRAPH` و`SEPARATOR` في `items[]` دون مفتاح `answer` حتى يحتفظ التقرير بنفس الهيكل المرئي الذي رآه المستخدم.

## أين يظهر

يظهر تقرير الاستبيان كمصفوفة بصيغة الجمع **`questionnaire_responses[]`** في `GET /v3/session/{sessionId}/decision/`، لكل من جلسات KYC وKYB، كلما تم تشغيل ميزة الاستبيان. ويكون الحقل `null` حتى يبدأ مثيل واحد على الأقل من الاستبيان. ويحمل كل إدخال `node_id` حتى تتمكن مسارات سير العمل متعددة المثيلات من توضيح خطوة المخطط التي أنشأته.

```text theme={null}
GET /v3/session/{sessionId}/decision/
  ──▶ { "questionnaire_responses": [ { node_id, questionnaire_id, title, status, sections, … }, … ] }
```

## بنية العنصر

راجع [رد الاستبيان في مرجع نماذج البيانات](https://docs.didit.me/ar/reference/data-models.md#استجابة-الاستبيان) للاطلاع على المخطط القياسي.

```typescript theme={null}
interface QuestionnaireResponse {
  questionnaire_id: string;          // UUID of the questionnaire version that was answered
  title: string;                     // Questionnaire name, as set in the Console
  description: string | null;
  languages: string[];               // Supported language codes
  default_language: string;          // Default language code
  is_active: boolean;
  is_simple_questionnaire: boolean;  // true = flat list, false = branching graph
  questionnaire_group_id: string;    // UUID shared by all versions of the same questionnaire
  version: number;                   // Version number within the group
  published_at: string | null;       // ISO 8601 — when this version was published
  status: "Approved" | "In Review" | "Not Finished";
  sections: Array<{
    title: string | null;            // From the SECTION_HEADER that opens the section
    description: string | null;
    items: QuestionnaireItem[];
  }>;
  node_id: string | null;            // Workflow graph node that ran this questionnaire
}

interface QuestionnaireItem {
  uuid: string;                      // Form element UUID
  value: string;                     // Stable node id of the element within the questionnaire graph
  element_type:
    | "SHORT_TEXT" | "LONG_TEXT"
    | "DROPDOWN" | "SINGLE_CHOICE" | "MULTIPLE_CHOICE"
    | "NUMBER" | "EMAIL" | "PHONE" | "ADDRESS" | "COUNTRY"
    | "DATE_PICKER" | "TIME"
    | "CONSENT"
    | "FILE_UPLOAD" | "IMAGE"
    | "REPEATABLE_GROUP"
    | "HEADING" | "PARAGRAPH" | "SEPARATOR";   // layout-only — no answer key
  is_required: boolean;
  title: string | null;              // Localized
  description: string | null;        // Localized help text, or null when none is set
  placeholder: string | null;        // Localized
  choices: Array<{                   // DROPDOWN / SINGLE_CHOICE / MULTIPLE_CHOICE
    label: string;                   // Localized
    value: string;                   // Stable across languages
    requires_text_input?: boolean;   // Selecting this option triggers a free-text follow-up
  }> | null;
  max_files: number | null;          // FILE_UPLOAD / IMAGE upload cap (1–5)
  required_if: {                     // Conditional requirement rule, or null
    rules: Array<{ field: string; operator: string; value?: unknown }>;
    logic: "and" | "or";
  } | null;
  repeatable_config: {               // REPEATABLE_GROUP only, or null
    min_items?: number;
    max_items?: number;
    item_label?: string;             // Localized
    fields: Array<object>;           // Sub-field definitions (value, element_type, title, …)
  } | null;
  answer?: Answer | null;            // Omitted on HEADING / PARAGRAPH / SEPARATOR; null when unanswered
}
```

لا تظهر عناصر `SECTION_HEADER` أبداً في `items[]` — فهي تفتح قسماً جديداً وتوفر `title` و`description` الخاصين به.

### أنواع العناصر

| نوع العنصر | بنية الإجابة | ملاحظات |
| - | - | - |
| `SHORT_TEXT`، `LONG_TEXT` | `{ value: string }` | نص حر. |
| `EMAIL`، `DATE_PICKER`، `TIME` | `{ value: string }` | متغيرات نصية محددة النوع. |
| `NUMBER` | `{ value: number }` | رقم JSON — يتم التحقق من كونه رقمياً على جانب الخادم. |
| `COUNTRY` | `{ value: string }` | رمز ISO 3166-1 alpha-3 (مثل `"ESP"`)، يتم التحقق منه على جانب الخادم. |
| `PHONE` | `{ value: { countryCode, callingCode, number } }` | كائن هاتف منظم. |
| `ADDRESS` | `{ value: { street, streetExtraInfo, city, state, postalCode, country } }` | كائن عنوان منظم. |
| `DROPDOWN`، `SINGLE_CHOICE` | `{ value: string, text?: string }` | `value` هي قيمة الخيار؛ ويتم ملء `text` عندما يحتوي الخيار المحدد على `requires_text_input: true`. |
| `MULTIPLE_CHOICE` | `{ value: string[], text?: string }` | مصفوفة من قيم الخيارات. |
| `CONSENT` | `{ value: boolean }` | قيمة منطقية في JSON. |
| `FILE_UPLOAD`، `IMAGE` | `{ files: string[] }` | كل إدخال هو رابط موقّع مسبقاً. |
| `REPEATABLE_GROUP` | `{ items: Array<{ [fieldValue]: Answer }> }` | كائن واحد لكل تكرار، مفهرس بقيمة `value` الخاصة بكل حقل فرعي مع كائن الإجابة الخاص به. |
| `HEADING`، `PARAGRAPH`، `SEPARATOR` | *(لا يوجد مفتاح `answer`)* | تنسيق بحت — يتم الاحتفاظ به في `items[]` من أجل الهيكل. |

يتم إرجاع أي عنصر تفاعلي مرئي لم يُجب عنه المستخدم مصحوباً بـ `"answer": null`.

### الرؤية الشرطية

عندما يحدد الاستبيان مخططاً (منطقاً شرطياً)، يتم تضمين العناصر الموجودة فقط في المسار الذي سلكه المستخدم بالفعل. العنصر المخفي بواسطة فرع لم يتبعه المستخدم **لا** يظهر في `sections[].items` — حتى لو كان موجوداً في القالب. وتُحذف الأقسام التي لا تحتوي على عناصر مرئية بالكامل.

## قيم الحالة

تكون **الحالة** `status` على مستوى الرد إحدى ثلاث قيم. داخلياً، يتم دمج الحالة الأساسية (`Approved`، أو `In Review` عندما يفرض سير العمل مراجعة يدوية) مع أي قواعد حالة مخصصة متطابقة باستخدام أسبقية المنصة العامة Declined > In Review > Approved؛ ثم يتم تعيين نتيجة `Declined` على مستوى الاستبيان إلى `In Review` حتى يتعامل المسؤولون مع القرار النهائي أثناء المراجعة.

| الحالة | المعنى |
| - | - |
| `Not Finished` | لم يقم المستخدم بإرسال الاستبيان بعد. |
| `In Review` | تم الإرسال وفي انتظار مراجعة يدوية (يفرض سير العمل مراجعة يدوية، أو قامت قاعدة حالة بتصعيد الرد). |
| `Approved` | تم الإرسال وقبوله. |

## التحذيرات

تُصدر الاستبيانات كود تحذير واحداً، يتم إنشاؤه عندما تتطابق **قاعدة حالة مخصصة** تم تكوينها على عقدة الاستبيان مع إجابة:

| الوسم | الوصف |
| - | - |
| `CUSTOM_STATUS_RULE_TRIGGERED` | قامت قاعدة حالة في سير العمل بتقييم إجابة الاستبيان وتغيير (أو تأكيد) حالة الميزة. |

تحمل `additional_data` الخاصة بالتحذير الحقول `field` و`operator` و`rule_value` و`actual_value` و`target_status` و`score` عندما تحدد القاعدة درجة. ويتبع `log_type` الخاص به الحالة المستهدفة للقاعدة: `error` للحالة Declined، و`warning` للحالة In Review، و`information` في الحالات الأخرى.

على عكس الميزات الأخرى، لا يدمج إدخال الاستبيان مصفوفة `warnings[]` — يتم تسجيل سجلات القواعد التي تم تشغيلها في الجلسة تحت `feature: "QUESTIONNAIRE"` وتظهر في شاشة مراجعة Console (راجع أيضاً [قائمة تحذيرات التحقق من الشركات (KYB)](https://docs.didit.me/ar/business-verification/warnings.md#الاستبيانات)؛ ينطبق نفس الكود على جلسات KYC).

## مثال — استبيان مصدر الأموال

```json theme={null}
{
  "questionnaire_responses": [
    {
      "questionnaire_id": "9f7485e0-b00b-4d56-9d3e-7859b68d1213",
      "title": "Source of Funds",
      "description": "Reply to this questionnaire to help us understand the source of funds.",
      "languages": ["en"],
      "default_language": "en",
      "is_active": true,
      "is_simple_questionnaire": true,
      "questionnaire_group_id": "2b6a9d40-13a8-4b1e-9a6c-3f1d2e4b5a60",
      "version": 1,
      "published_at": "2025-11-02T09:14:55.000000Z",
      "status": "Approved",
      "sections": [
        {
          "title": null,
          "description": null,
          "items": [
            {
              "uuid": "618636d9-7d5c-41ce-b8d0-1ab2a4be20db",
              "value": "question_1",
              "element_type": "DROPDOWN",
              "is_required": true,
              "title": "What is your primary source of funds?",
              "description": null,
              "placeholder": null,
              "choices": [
                { "label": "Salary", "value": "salary" },
                { "label": "Business Income", "value": "business_income" },
                { "label": "Savings", "value": "savings" },
                { "label": "Investments", "value": "investments" },
                { "label": "Inheritance/Gift", "value": "inheritance_gift" },
                { "label": "Other", "value": "other", "requires_text_input": true }
              ],
              "max_files": 1,
              "required_if": null,
              "repeatable_config": null,
              "answer": { "value": "salary" }
            },
            {
              "uuid": "2d16b527-72be-42e0-8e96-b164b818386c",
              "value": "question_2",
              "element_type": "LONG_TEXT",
              "is_required": true,
              "title": "Provide details of the primary source.",
              "description": null,
              "placeholder": null,
              "choices": null,
              "max_files": 1,
              "required_if": null,
              "repeatable_config": null,
              "answer": { "value": "Software engineer at Acme Ltd since 2018." }
            },
            {
              "uuid": "1bf8a2a3-14ee-48a8-bb3d-175481aae4aa",
              "value": "question_3",
              "element_type": "SINGLE_CHOICE",
              "is_required": true,
              "title": "Will any funds originate from third parties?",
              "description": null,
              "placeholder": null,
              "choices": [
                { "label": "Yes", "value": "yes", "requires_text_input": true },
                { "label": "No", "value": "no" }
              ],
              "max_files": 1,
              "required_if": null,
              "repeatable_config": null,
              "answer": { "value": "yes", "text": "One-off gift from parents, EUR 8,000." }
            },
            {
              "uuid": "a90a073d-e098-404c-bbce-5130d8b12a13",
              "value": "question_4",
              "element_type": "FILE_UPLOAD",
              "is_required": true,
              "title": "Upload a proof of funds document",
              "description": null,
              "placeholder": null,
              "choices": null,
              "max_files": 3,
              "required_if": null,
              "repeatable_config": null,
              "answer": {
                "files": [
                  "https://<media-host>/.../payslip-jul.pdf",
                  "https://<media-host>/.../payslip-aug.pdf"
                ]
              }
            }
          ]
        }
      ],
      "node_id": "feature_questionnaire"
    }
  ]
}
```

## مثال — غير مكتمل

```json theme={null}
{
  "questionnaire_responses": [
    {
      "questionnaire_id": "9f7485e0-b00b-4d56-9d3e-7859b68d1213",
      "title": "Source of Funds",
      "description": "Reply to this questionnaire to help us understand the source of funds.",
      "languages": ["en"],
      "default_language": "en",
      "is_active": true,
      "is_simple_questionnaire": true,
      "questionnaire_group_id": "2b6a9d40-13a8-4b1e-9a6c-3f1d2e4b5a60",
      "version": 1,
      "published_at": "2025-11-02T09:14:55.000000Z",
      "status": "Not Finished",
      "sections": [
        {
          "title": null,
          "description": null,
          "items": [
            {
              "uuid": "618636d9-7d5c-41ce-b8d0-1ab2a4be20db",
              "value": "question_1",
              "element_type": "DROPDOWN",
              "is_required": true,
              "title": "What is your primary source of funds?",
              "description": null,
              "placeholder": null,
              "choices": [
                { "label": "Salary", "value": "salary" },
                { "label": "Other", "value": "other", "requires_text_input": true }
              ],
              "max_files": 1,
              "required_if": null,
              "repeatable_config": null,
              "answer": null
            }
          ]
        }
      ],
      "node_id": "feature_questionnaire"
    }
  ]
}
```

عندما يصل المستخدم إلى خطوة الاستبيان ولكنه لم يرسل الإجابات بعد، يتم إرجاع الرد مع `status: "Not Finished"` و`"answer": null` لكل عنصر مرئي. أما الجلسة التي لم تصل أبداً إلى الخطوة فلا تُنتج أي إدخال على الإطلاق — ويظل `questionnaire_responses` بقيمة `null` في حال عدم وجود أي مثيل.

## ملاحظات

* **تنتهي صلاحية روابط URL الخاصة بالملفات.** الإدخالات في `answer.files` هي روابط URL موقّعة مسبقاً (صالحة لمدة 4 ساعات افتراضياً). أعد استدعاء endpoint القرار عندما تحتاج إلى روابط URL جديدة.
* **التعريب.** يتم إرجاع `title` و`description` و`placeholder` للعنصر، و`label` للخيار، و`title`/`description` للقسم باللغة الإنجليزية عندما يدعم الاستبيان ذلك، وإلا فباللغة `default_language` الخاصة بالاستبيان. تبقى `value` الخاصة بالخيار ثابتة عبر جميع اللغات حتى تتمكن من بناء منطق عملك بالاعتماد عليها بأمان.
* **يُمثّل `description` الخاص بالعنصر نص المساعدة الخاص به.** يمكن لأي عنصر أن يحتوي على نص مساعدة، بما في ذلك الأسئلة، وتكون قيمته `null` في حال عدم تعيينه. لا يحتوي `SEPARATOR` على أي نص مساعدة مطلقاً.

## مواضيع ذات صلة

> [card] [نظرة عامة على الاستبيانات](https://docs.didit.me/ar/core-technology/questionnaires/overview.md)
>
> كيفية إنشاء الاستبيانات وإدارتها بإصدارات وربطها بسير العمل.

> [card] [نماذج البيانات — استجابة الاستبيان](https://docs.didit.me/ar/reference/data-models.md#استجابة-الاستبيان)
>
> المخطط المعتمد حقلاً بحقل لهذا الكائن.

> [card] [استرداد الجلسة](https://docs.didit.me/ar/sessions-api/retrieve-session.md)
>
> مرجع endpoint لـ payload القرار في الإصدار V3.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.