# Information retreival

## How to check saved answers

One main difference between SynoTool and SynoSurvey is the way we can recover the responded answers. Every answer in Survey is saved in an JSON, commonly know as a Javascript Object Notation.

If you are testing, you can inspect the page by clicking `F12` or by doing `right click > inspect` .&#x20;

<figure><img src="/files/goJp1ePFrUH3tpVkpdRM" alt=""><figcaption></figcaption></figure>

This will open the developers tool for web programmers. Then, you need to go to the **Elements** tab. Right there you will find a script tag where they JSON is allocated. You can simply expand it to see what data has been saved from **previous questions**. This should look like this.

<figure><img src="/files/bC34UD8PA7bRNF8riwWD" alt=""><figcaption></figcaption></figure>

The variable holds the responses is called **response.** Each answer is wrapped into curly braces. This can contain different information regarding the type of the question. For more details, see the table below.

## Structure of the saved information

Here is a table that describes the meaning of each variable in the JSON.

### Simple response variables

| Name of variable |                                                                                                                                                                                                         Description                                                                                                                                                                                                        |
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|    `pageCode`    |                                                                                                                                            <p>Name of the page where the question is in.<br><br><strong>Example:</strong><br><img src="/files/yHh3uYavar6xCrG6XD2m" alt=""></p>                                                                                                                                            |
|  `questionCode`  |                                                                                                                                                    <p>Name of the question code.<br><br><strong>Example:</strong><br><img src="/files/EAmGR1x3b1i6RlkuU6eH" alt=""></p>                                                                                                                                                    |
|      `code`      |                                                                                                                                          <p>Answer code that belongs to the question code.<br><br><strong>Example:</strong><br><img src="/files/f044rtFWjmkF4knWv1k4" alt=""></p>                                                                                                                                          |
|      `label`     |                                                                                                                                             <p>The text of each answer in the question.<br><br><strong>Example:</strong><br><img src="/files/4g8DlO3digTsNMnqPXGY" alt=""></p>                                                                                                                                             |
|      `value`     | <p>The introduced value written in open texts. <br>They are also received when <strong>Other</strong> option is enabled in single/multiple questions.<br><br><strong>Single and multiple questions:</strong><br><img src="/files/Yk3MHLbeR1So8t8sFx1Y" alt=""></p><p><img src="/files/9RVPV1jsaaS5JFl29NoA" alt=""></p><p></p><p><strong>Open texts fields:</strong><br><img src="/files/9wwpjn74z3OJaE2pkqX3" alt=""></p> |

### Matrices response variables

| Name of variable |                                                              Description                                                             |
| :--------------: | :----------------------------------------------------------------------------------------------------------------------------------: |
|    `pageCode`    | <p>Name of the page where the question is in.<br><br><strong>Example:</strong><br><img src="/files/yHh3uYavar6xCrG6XD2m" alt=""></p> |
|  `questionCode`  |         <p>Name of the question code.<br><br><strong>Example:</strong><br><img src="/files/Cy7V452AbItmWXgi3pGR" alt=""></p>         |
|     `rowCode`    |          <p>The code of each row.<br><br><strong>Example:</strong></p><p><img src="/files/T9td31l8Rl4P4h65DXH8" alt=""></p>          |
|    `rowLabel`    |          <p>The text inside each row.<br><br><strong>Example:</strong><br><img src="/files/DhAHG6GSCeb75UMMmlnd" alt=""></p>         |
|   `columnCode`   |         <p>The code of each column.<br><br><strong>Example:</strong></p><p><img src="/files/EGxcM6CkRcEUxxTd3PW6" alt=""></p>        |
|   `columnLabel`  |     <p>The label of each column.</p><p></p><p><strong>Example:</strong></p><p><img src="/files/NuEC8Aotm6xBgd5vdAAA" alt=""></p>     |
|      `value`     |                                           *Variable is not used in this type of questions*                                           |

## Read answers using Javascript

If you want to retreive the whole information in the json file you can use the following snippet.

### Panelist & Parameters metadata

{% code overflow="wrap" %}

```javascript
let guid = response.parameters.id;           // GUID
let source = response.parameters.source;     // Provider source, i.e. 1 (Syno), 2 (Cint Buyer API), 3 (Cint Access)
let gender = response.parameters.g;          // Gender where M: Male and F: Female
let year_of_birth = response.parameters.yob; // Year of birth in yyyy format
let panelist_id = response.parameters.pid;   // Panelist ID
let postcode = response.parameters.p;        // Postal code
```

{% endcode %}

### :radio\_button:Single & :ballot\_box\_with\_check: Multiple Choice

{% code overflow="wrap" fullWidth="false" %}

```javascript
// Read all selected answer codes from a single/multiple choice
let selected_codes = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.code);

// Read all selected labels from a single/multiple choice
let selected_labels = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.label);

// Read all values from a single/multiple choice (for free answers in single/multiple choice)
let values = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.value);
```

{% endcode %}

### :record\_button: Single & :stop\_button:Multiple Choice Matrices

{% code overflow="wrap" fullWidth="false" %}

```javascript
// Read all selected answer codes from a single/multiple choice matrix
let selected_row_codes = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.rowCode);

// Read all selected labels from a single/multiple choice matrix
let selected_row_labels = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.rowLabel);
```

{% endcode %}

{% code overflow="wrap" fullWidth="false" %}

```javascript
// Read all selected answer codes from a single/multiple choice matrix
let selected_column_codes = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.columnCode);

// Read all selected labels from a single single/multiple choice matrix
let selected_column_labels = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.columnLabel);
```

{% endcode %}

### :writing\_hand: Single & Multiple Open Text


---

# 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://synoint.gitbook.io/survey-library/overview/information-retreival.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.
