Question type - Array (Texts)

From LimeSurvey Manual
Jump to: navigation, search
Other languages:Deutsch 100% • ‎English 100% • ‎español 7% • ‎日本語 3% • ‎Nederlands 100% • ‎slovenščina 97%

Contents


Short description

The Array (Text) question type allows for an array of text boxes with a set of subquestions as the "y-axis", and another set of subquestions as the "x-axis".

SC MFT.jpg You can also limit this question type to allow numerical answers only (see the question attribute "Numbers only") and "Show totals" for enabling then display of totals for rows, columns or both:

Array text numbers totals.PNG

Core settings

Mandatory (mandatory)

Description

This option lets you require that all parts of the question be answered. If you have a question with multiple sub-questions, and want to require that some but not all parts be answered, use the min_answers question attribute instead.

Valid values

  • Yes
  • No (default)



Validation (using regular expressions) (preg_validation)

Description

This option lets you specify a regular expression with which to validate all parts of a question.

If any question or sub-question value does not meet the validation requirements, the background color of the text entry field will be changed to red (New in 1.92 ) so that users can easily see which parts of the question need to be corrected. Thus, you can do on-page validation and do not need to wait for the user to click submit in order to validate the question.

Valid values

  • Any valid regular expression

Example

  • See multiple examples here



Relevance equation

Notice.png
Hint: This features is available starting in version 1.92


Description

If the value of the relevance equation is "1" or "true", the question is "relevant" in the survey context, i.e. it is shown to the survey participant. If not, the question is hidden. All questions let you specify a relevance equation. Relevance is the successor to conditions and supports much more complex conditional logic.

Syntax Highlighting

Whenever you save the relevance equation, it will be evaluated and syntax-highlighted. Any errors will be color coded so that you can quickly detect and fix them.

Valid values

Any equation, using Expression Manager syntax, without surrounding curly braces.

Examples

Here are good examples of syntax highlighting


Advanced settings

Random answer order (random_order)

Description

This attribute causes LimeSurvey to ignore the existing order of answer options/subquestions, and instead it orders them randomly. It is important to note that this random order will be reordered each time the question is displayed, so if someone returns to a question, the order will probably be different from the first time they saw it. Having the answers display randomly is useful to remove the possibility of bias from answers to questions. Please note that if a question has subquestions the order of subquestions will be randomized, not the order of the answer options.

Available options

  • Randomize on each page load
  • Off (default)



Answer width (answer_width)

Description

This value sets the answer column width in percentage. For example if you set this to value 60 then 60 percent of the question width will be used for the answer text (in most question types this is the most left column). The remaining width will be equally divided between the answer options.

Valid values

  • Any integer values from 1-100.



Input box width (text_input_width)

Description

This attribute sets the width of the text input box, but does not limit the number of characters that can be entered.

Example

This is usually stated as the number of characters. So a number of 10 implies that the input field is 10 characters wide.



Randomization group name (random_group)

Notice.png
Hint: This features is available starting in version 1.92


Description

Place questions into a specified randomization group, all questions included in the specified group will appear in a random order.

Valid values

Just enter any string you like (for example: 'group1'). All question which have set the same string will have their place in the survey randomized (=randomly exchanged among each other).



Always hide this question (hidden)

Description

If you prefill a question by URL you can use this setting to hide the question and its value from the survey participant at all. This overrides any conditions because the particular question is never even embedded in a page. If you just want to hide a question (for example if you want to store a value calculated on the fly) then use Javascript embedded in the question source code.

Notice.png
Hint: The question are not diplay in HTML, it can be set with an equation question or survey URL, but not in javascript

Available options

  • On
  • Off (default)



Array filter (array_filter)

Description

The Array filter advanced settings allow you to use any multiple choice question to select or set which responses display in a subsequent list, array or multiple choice question.

Starting in 1.92, subsequent questions can be filtered on any array question types, including:
  • Multiple choice
  • Multiple choice with comments
  • Multiple short text
  • Multiple numeric
  • Array (5 point, 10 point, Yes/No/Unknown, Increase/Same/Decrease, Column)
  • Array (Dual Scale, Text, Numbers)
  • Ranking

Furthermore, each of these types of questions can filtered.

The only exception is Array (Column), which can filter other questions, but can not itself be filtered.

To set a filter

Enter the question code of a multiple options question to use as the source information into the setting for array filter. For example, if your source multiple option question code is "Q1" enter "Q1" into either the 'Array Filter' input or the 'Array Filter Exclusion' input in the advanced settings of the question you want to filter. Only answer options that are selected in question Q1 will be visible in the array_filter-ed question.

Starting in 1.92, you can enter multiple array_filter options for a single question, separated by semicolons

Array filter question settings require the questions being used to have exactly matching lists of answers. If the questions do not have exactly the same set of answers and codes, then the filters will break.

Starting in 1.92, if Q2 has sub-questions that are not present in Q1, they will always be displayed rather than breaking the filters.

Cascading

The Array filter will cascade – that is you can select a question which filters another question, which filters another question, and so on.

Array filter example

Ticking items ‘One’, ‘Three’ and ‘Four’ in the first question results in the entries 'One', 'Three' and 'Four' displaying in the subsequent question which uses array filter

Multi option question

Code:Q1

Question: Which animals do you like?

1 Cat

2 Dog

3 Zebra

Array 5 Point Choice Question

Code:Q2

Question: Rate these animals on a scale of 1 to 5, where 1 is I like them a little and 5 is I like them a lot

Array filter example 2 - Using Multiple Short Text

Note: This features is available starting in version 1.92

Array filter with multipe short text.jpg

Here is the Limesurvey Group file for the above demo

limesurvey_group_32.lsg

Array filter example 3 - Cascading Array Filters

This sample survey shows use of array_filter, array_filter_exclude, and exclude_all_others, plus cascading array filters.

ls2_cascading_array_filter.lss



Array exclusion filter (array_filter_exclude)

Description

The Array filter exclusion advanced setting allows you to use a multiple choice question to select or set which responses won't display in a subsequent list, array or multiple choice question.

Starting in 1.92, subsequent questions can be filtered on any array question types, including:
  • Multiple choice
  • Multiple choice with comments
  • Multiple short text
  • Multiple numeric
  • Array (5 point, 10 point, Yes/No/Unknown, Increase/Same/Decrease, Column)
  • Array (Dual Scale, Text, Numbers)
  • Ranking

Furthermore, each of these types of questions can filtered.

The only exception is Array (Column), which can filter other questions, but can not itself be filtered.

To set a filter

Enter the question code of a multiple options question to use as the source information. For example, if your source multiple option question code is "Q1" enter "Q1" into 'Array filter exclusion' input in the advanced settings of the question you want to filter.

Starting in 1.92, you can enter multiple array_filter_exclude options for a single question, separated by semicolons

The source question has to contain exactly the same list of answers/subquestion as the question you wish to filter. Your question will then only display those answers/subquestion that were not selected in the multiple options question.

If the questions do not have exactly the same set of answers/subquestions and codes, then the filters will break.

Starting in 1.92, if Q2 has sub-questions that are not present in Q1, they will always be displayed rather than breaking the filters.

Cascading

The Array filter exclusions settings will cascade – that is you can select a question which filters another question, which filters another question, and so on.

Example

Ticking items 'One' and 'Three' in the first question results in those questions not being displayed in the subsequent question which uses array filter exclusion

Multi Option Question

Code:Q1

Question: Which animals do you like?

1 Cat

2 Dog

3 Zebra

Array 5 Point Choice Question



Show totals for (show_totals)

Description

Show totals for either rows, columns or both rows and columns'

Example:

Array text numbers totals.PNG

Available options

  • None (default)
  • Rows
  • Columns
  • Both rows and columns



Numbers only (numbers_only)

Description

If you set this option the participant can only enter numbers in the text boxes.

For equation question types this setting indicates that the result will be a number only, not a string. This will guarantee proper calculations/conversion in follow-up equations regarding the decimal mark.

Behavior by Question-Type

  1. Default: If the subject enters a value that is not a number, that value is immediately cleared from the text box so that the subject can enter an appropriate value.
  2. Array(Texts): Setting this to "No" will overrule "Show totals for" and "Show grand total" setting and total text boxes will not be displayed.
  3. Equation: Setting this option to "Yes" will force equation results to be converted to a numeric value. If the equation result is not a number (and not blank), the equation will return NaN and saved as an empty string in responses table.

Available options

  • Yes
  • No (default)



Show grand total (show_grand_total)

Description

Show grand total for either columns or rows

Available options

  • Yes
  • No (default)



Insert page break in printable view (page_break)

Description

This attribute is only active when you actually print a survey from the Printable View. It forces a page break before the question. (Only the Opera browser does not need this since it handles the page breaks accordingly.)

Available options

  • Yes
  • No (default)



Minimum answers (min_answers)

Description

Can be used to ensure that a user selects at least a certain number of answers in a multiple choice question.

Valid values

  • Any integer value above 0
Notice.png
Hint: This feature changed with version 1.92
  • Any number
  • Any SGQA code
  • Any question code (variable name)
  • Any equation, using Expression Manager syntax, without surrounding curly braces.

Example

If set to 3, the user will only be able to submit the survey form if they have selected at least three check-boxes. In ranking questions, this ensures that at least three items are ranked. Please note that if you use this attribute with Ranking questions please set the question to non-mandatory - because when you leave it at mandatory all items need to be ranked which is counter-active to this feature.



Maximum answers (max_answers)

Description

Can be used to limit the total number of answers a user can select in a multiple choice question.

Valid values

  • Any number value
  • Any SGQA code (New in 1.92 )
  • Any question code (variable name) (New in 1.92 )
  • Any equation, using Expression Manager syntax, without surrounding curly braces. (New in 1.92 )

Example

If set to 2, the user will only be able to check at most 2 checkboxes or 1 checkbox + fill the Other field (if any). At ranking questions the participant would be able to only select 2 items at most.



Whole question validation equation (em_validation_q)

Notice.png
Hint: This features is available starting in version 1.92


Description

This is an equation that is used to validate the entire question (e.g all of its parts collectively for a multi-answer question). If the question fails the validation criteria, then then em_validation_q_tip message has the CSS style .error set to it. This tip uses the .em_q_fn_validation CSS style, which is hidden by default within template.css.

The main difference between this feature and the Sub-question validation equations (em_validation_sq option) is that for this feature, if the question (or question parts) fail validation, then an error message could be shown. For the sub-question validation, each text entry cell (e.g. in array, but also applies to single entry question types) will be styled so that the background color is pink.

Valid values

Example

    • You want to collect demographic information from users via a multiple short text question, and you want to validate that the user has entered a reasonable email and phone number.

This example shows how the question looks with invalid answers:

Validation-invalid-both.jpg

And here is what it looks like with one invalid answer:

Validation-invalid-phone.jpg

Here is how you edit a question to enter that information:

Validation-gui.jpg

And here is part of the Show Logic File output that lets you validate the accuracy of your expression and ensure there are no syntax errors:

Validation-logic.jpg

As you can see, the validation equation tests that both the email and phone are either empty or match a regular expression filter.

The validation tip only shows the warning message if the phone or email appears invalid.

Notice.png
Hint: Remember, LimeSuvey uses the Perl syntax for regular expressions, so they should start and end with / (slash character)!




Tip for whole question validation equation (em_validation_q_tip)

Notice.png
Hint: This features is available starting in version 1.92


Description

If you are using em_validation_q, this is an optional message to show as a question 'tip'.

Valid values

  • Any string

Example

  • See the example for the Question validation tip - it shows how the tip can be tailored to show which parts of a multiple short text question fail validation criteria.



Sub-question validation equation (em_validation_sq)

Notice.png
Hint: This features is available starting in version 1.92


Description

This is an equation that is used to validate each sub-question (text field) individually. Any text field that does not pass these validation conditions will have its background color turned pink (using the .em_sq_fn_validation CSS style) to highlight the error. Note that this is available in addition to the regular expression-based validation option.

Valid values

Any equation, using Expression Manager syntax, without surrounding curly braces.

Examples

Say you have a multiple short text question and you want to collect email addresses. You could use the regular expression validator to make sure the email address has proper syntax.

As another example, say you only want to allow numbers that are a multiple of 3, the equation would be:

(this / 3) == floor(this/3)

The reserved variable this is automatically replaced by a reference to the active text entry cell.



Tip for sub-question validation equation (em_validation_sq_tip)

Notice.png
Hint: This features is available starting in version 1.92


Description

If you are using em_validation_sq, this is an optional message to show as a question 'tip'.

Valid values

  • Any string

Example

  • Continuing the example of validating emails, the tip might be "Please enter valid email addresses."