# Models

### Survey

Survey is defined by (express) `express/models/Survey.js`and (Angular) `src/app/Survey.ts`

#### Old Format (Depreciated)

`{`\
&#x20; `_id: string`\
&#x20; `publish: boolean`\
&#x20; `name: string`\
&#x20; `range: Enum(7,9,11)`\
&#x20; `cols: Integer[]`\
&#x20; `statements: string[]`\
&#x20; `users: User[]`\
`}`

#### New Format (v3)

`{`\
&#x20; `_id: string`\
&#x20; `publish: boolean`\
&#x20; `name: string`\
&#x20; `range: Enum(7,9,11)`\
&#x20; `cols: Integer[]`\
&#x20; `register: string[] // NEW - For registration page fields`\
&#x20; `questionnaire: string[] // New - For questionnaire page fields`\
&#x20; `statements: string[]`\
&#x20; `users: User[]`\
`}`

`*WIP: Currently in angular, cols[] is referred to as grid[] in the template, this may be changed in future for consistency.`

#### Description

*\_id*\
A identification string generated by MongoDB

publish\
A flag that is set to indicate that the Survey is in read-only mode after being published (no editing of data allowed)

*name*\
The name of the survey

*range*\
The horizontal-x range of the survey's Q-sort table

*cols*\
An array holding a statement/cell count for each column of the Q-Sort table display.

```
Grid display is [ cellcount, ... ]
  i.e. [2, 3, 4, 3, 4, 3, 2] =>
        _ _ _ _ _ _ _
        _ _ _ _ _ _ _
          _ _ _ _ _
            _   _
```

![Example](/files/-LMKWx1uuSb8Vehh5kiC)

*statements*\
An array of statement strings

*users*\
An array of UserData objects

*register*\
A string array holding data related to the fields of the registration page, i.e. 'age', 'gender', 'nationality', 'language', etc.

*questionnaire*\
A string array holding data related to the fields of the end of survey questionnaire page, i.e. \['q1', 'q2', 'q3'], etc.

#### Validation

* *name* must be under the survey name limit (100)
* *each statement in statements* must be under the statement string limit (350).
* *statements* must not exceed statement max count limit (80).&#x20;
* *range* and *cols* must correspond to values that are within horizontal-x range limits. `i.e. range=[7,9,11] cols.length=[7,9,11]`

\*\*Planned/WIP\*\*

* *users* must not exceed a maximum user count to be determined
* Total statements in database must not exceed a maximum survey count to be determined

### User

User is defined by (express) `express/models/User.js`and (Angular) \*WIP: need to define in angular

#### Old Format (Depreciated)

`{`\
&#x20; `_id:string`\
&#x20; `age: Integer`\
&#x20; `gender: Enum(Male, Female, Other)`\
&#x20; `main_lang: string`\
&#x20; `other_lang: string`\
&#x20; `progress: Enum(0, 1, 2, 3)`\
&#x20; `question_ans: string[]`\
&#x20; `sort_agree: Integer[]`\
&#x20; `sort_neutral: Integer[]`\
&#x20; `sort_disagree: Integer[]`\
&#x20; `matrix: Integer[][] // [col][cell]`\
`}`

#### New Format

`{`\
&#x20; `register_ans: String[]; // [field1ans, field2ans ...]`\
&#x20; `question_ans: String[5]`\
&#x20; `progress: Enum(0, 1, 2, 3)`\
&#x20; `sort_agree: Integer[]`\
&#x20; `sort_neutral: Integer[]`\
&#x20; `sort_disagree: Integer[]`\
&#x20; `matrix: Integer[][] // [col][cell]`\
`}`

#### Description

*\_id*\
A identification string generated by MongoDB

~~*age*~~\
~~*Reported age of participant*~~

~~*gender*~~\
~~*Reported gender of participant*~~

~~*main\_lang*~~\
~~*Reported Main Language of participant*~~

~~*other\_lang*~~\
~~*Reported Other Languages of participant*~~

*register\_ans*\
String Array holding response data for the registration page. I.e. first element = respondent's age, second element = respondent's gender, etc.

*question\_ans*\
An array of length 5 holding end questionnaire response strings

*sort\_agree*\
*sort\_disagree*\
*sort\_neutral*\
Arrays of index values that correspond to the parent statements object's statements array. Represent the 3 containers in the initial sorting phase (agree, disagree, neutral).

*matrix*\
A matrix that represents Q-Sort Table response data, in the form of index values that correspond to the parent statement object's statements array.

```
Grid display is [ cellcount, ... ]
  i.e. [2, 3, 4, 3, 4, 3, 2] =>
        _ _ _ _ _ _ _
        _ _ _ _ _ _ _
          _ 9 _ _ _
            _   _
Grid data is represented as [col][cell], 
i.e. matrix[3][2] = 9 means that the 2nd cell of the 3rd column holds statement 9.
```

![Example](/files/-LMKWx1uuSb8Vehh5kiC)


---

# 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://qmethod.gitbook.io/project/documentation/models.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.
