Translations of this page:
 

Table of Contents

question()

void question(string|array QuestionIdentifier, array|string Items, [string Options])

Displays the question with the specified questionIdentifier in the questionnaire. The function question() is mainly used in conjunction with Filters and filter questions.

  • QuestionIdentifier
    • (string) The four-digit identifier is composed of the identifier of the rubric and question (two digits each) and must be enclosed in quotation marks (single or double), e.g. 'XY01'.
    • (array) An array with multiple question identifiers can also be specified. These will then be represented as combined question, just as when using the combine=… parameter.
  • Items
    Optionally, the second parameter can be used to specify which items of the question are to be shown and/or in which order this is done. The identifiers of the items are specified either as an array (array(2,4,6,8)) or separated by a comma as a string ('2,4,6,8). Numerical ranges can also be specified in the item list, e.g., '1,3,5-10' or array(1,3,'5-10') to describe items 1, 3, 5, 6, 7, 8, 9, and 10.
  • Options
    A whole set of options is available for fine tuning. For each question() command any number of options can be specified. Put each option in quotes (single or double) and separate multiple options with commas (see examples below).
    • 'show-title=no'
      Question text is not displayed, numbering is suspended.
    • 'show-explanation=no'
      The explanation/instructions are not displayed.
    • 'show-items=no'
      The items or dodge options are not displayed.
    • 'spacing=<n>'
      Distance under the question in pixels.
    • 'number=<n>'
      Displays the number <n> before the question instead of counting up automatically or hides the number completely with “number=no”.
      Tip: By the way, you can also generally switch off the numbering in the questionnaire (Create questionnaireSettings). With the option number=<n> or number=yes you can then assign a number to individual questions.
    • 'anchor=<amount>'
      Repeat the anchoring (prefix, graphical, numerical, and verbal) of a scale or polarity profile every <number> items. Useful for questions with numerous items.
    • 'anchor=none'
      Hides the anchoring (leader, graphical, numerical and verbal anchoring) of a scale or polarity profile completely.
    • 'random'
      The items of the question are output in random order. This parameter dynamically overrides the item sorting setting in the question.
    • 'random=<n>'
      <n> Items are randomly selected and displayed in random order.
    • 'combine=<Identifier other question>'
      Create a combined question (combined questions).
    • 'gap=<value>'
      gap between the input fields of a combined question in pixels (e.g. 'gap=20').
    • 'gap=line'
      Show a line between the combined questions. The distance or line is displayed equally between all combined questions.
  • Options
    Some options allow to dynamically override settings in the question:
    • 'filter=<value>'
      Prefix for database key in a question of type “extended selection” or “text input with selection recommendation” (e.g. 'filter=country' to display all database entries whose key starts with “country”). For the encoding of an answer to work correctly with the selection recommendation, at least part of the prefix must be entered in the question itself as prefix for database key. By means of question() a narrowing down can then be done. vorgenommen werden.
    • 'direction=<up|down>'
      Arrange selection options of a scale or horizontal selection in ascending (up) or descending (down) order.
    • 'composition=<default|extended|dense>'
      Adjust setting for Assignment of a question. This parameter dynamically overwrites the corresponding setting in the question.
    • 'align-labels=<center|inside|outside|eachline>'
      Align verbal anchoring in a scale that labels only the extremes.
    • 'shading=<auto|none|start-shaded|start-unshaded|all-shaded|all-unshaded>'
      Shading of the items.
    • 'flip-inputs'
      In most questions you can set whether the input fields (e.g. boxes to check) should be on the left or on the right of the labels. With this parameter you can invert the setting.

Notes

Important: A call to the function question() is equivalent to dragging and dropping a question into the questionnaire. If you include a question with the question() command (e.g. in a filter), then make sure that the same question was not additionally placed on the page by dragging it in. Otherwise the question will appear twice.

Important: SoSci Survey distinguishes between upper and lower case letters in the identifier and all options.

Note: Both the identifier and other options must be written as a string, usually in single or double quotation marks (see examples).

Tip: You can dynamically display only those items that the participant has selected in another question. For more information see Transfer items to another question.

Tip: You do not have to type the question() command by hand. You can also simply drag a question into a PHP-code element, see Introduction to PHP code: Programming more conveniently (questions and texts).

Examples

question('BS10'); // Daily television usage.
question('BS01', '2,1,4,5'); // Items 2, 1, 4 and 5 are asked here.
question('NH02', 'random=3'); // 3 items are randomly selected
question('AA01', 'show-title=no'); // hide question text
 
// The following three lines show items 1 to 4 and 6 of question BS07 respectively
question('BS07', array(1,2,3,4,6));
question('BS07', array('1-4',6));
question('BS07', '1-4,6');
 
question('SK01', 'spacing=4');  // Show a scale and directly below it ...
question('SK02', '1', 'show-title=no');  // ... the first item of an open text entry "Other: ___".
en/create/functions/question.txt · Last modified: 05.09.2023 22:42 by swissel.uni-mannheim
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki