This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:
 

This is an old revision of the document!


Table of Contents

question()

void question(string questionID, array|string items, [string options])

Shows the question with the specified questionID in the questionnaire. The function question() is mainly used with Filters and Conditional Questions.

  • questionID
    The four-digit ID is composed of the ID of the section and the question (both two-digit) and must be given in quotation marks (single or double), e.g. 'XY01'.
  • items
    The second parameter can optionally be used to specify which items in the question should be shown and/or in what order this occurs. The item IDs are either specified as an array (array(2,4,6,8)) or separated with a comma as a string ('2,4,6,8'). In order to describe items 1, 3, 5, 6, 7, 8, 9 and 10, number ranges can also be specified in the item list, e.g. '1,3,5-10' or array(1,3,'5-10').
  • options
    There is a large range of options available for fine-tuning. Any number of options can be specified for each question() command. Put each option in quotation marks (single or double) and separate multiple options with commas (see example below).
    • 'show-title=no'
      Question title is not shown, numbering is suspended
    • 'show-explanation=no'
      Explanation/instructions are not shown.
    • 'show-items=no'
      Items are not shown.
    • 'spacing=<n>'
      Spacing beneath the question in pixels.
    • 'number=<n>'
      Shows the number <n> before the question instead of automatically incrementing or hides the number completely with “number=no”.
      Tip: You can also turn off numbering in the questionnaire in general (Compose QuestionnaireSettings). You can then give individual questions a number with the option number=<n> or number=yes.
    • 'anchor=<number>'
      Repeats the anchor (lead text, graphic, numeric and verbal anchor) in a scale or a polarity profile every <number> of items. Sensible for questions with a large number of items.
    • 'anchor=none'
      Completely hides the anchor (lead text, graphic, numeric and verbal anchor) in a scale or a polarity profile.
    • 'random'
      Items in a question are output in a random order. This parameter overwrites the setting for item sorting in the question dynamically.
    • 'random=<n>'
      <n> items are selected at random and output in a random order.
    • 'combine=<ID of a different question>'
      Creates a combined question. (Combined Questions).
    • 'gap=<specification>'
      Spacing between the input fields in a combined question in pixels (e.g. 'gap=20').
    • 'gap=line'
      Display a line between the combined questions. The space or the line is displayed equally between all combined questions.
  • options
    Some options are intended to dynamically overwrite the question's settings:
    • 'filter=<specification>'
      Prefix for the database key in a question type “Extended Selection” or “Suggesting Text Input” (e.g. 'filter=country' to show all database entries whose key begins with “country”).
    • 'direction=<up|down>'
      Arrange selection options in a scale or in a horizontal selection in ascending (up) or descending (down) order.
    • 'composition=<default|extended|dense>'
      Customize setting for Composition of a Question .
    • 'align-labels=<center|inside|outside|eachline>'
      Customize alignment of the verbal anchor in a scale with only the extremes labeled. This parameter overwrites the respective setting in the question dynamically.
    • 'shading=<auto|none|start-shaded|start-unshaded|all-shaded|all-unshaded>'
      Item shading.

Tips

Note: Calling up the function question() is equivalent to the drag & drop of a question into the questionnaire. If you integrate the command question() into a question (e.g. in a filter) make sure that the same question is not put on the page again via drag & drop. Otherwise, the question appears twice.

Note: SoSci Survey differentiates between upper and low case for the ID and all options.

Note: Both the ID as well as other options must be quoted as a string; as a rule in quotation marks (single or double). Please see examples.

Tip: You can only show items dynamically that the participant selected in another question. For more details please see Use Selected Items in Another Question.

Tip: You do not have to type the question() command by hand. You can just drag & drop a question into a PHP code element. See Introduction to PHP Code: Comfortable Programming (Questions and Texts).

Examples

question('BS10');  // Daily television use
question('BS01', '2,1,4,5');  // items 2, 1, 4 and 5 are called up
question('NH02', 'random=3');  // 3 items selected at random
question('AA01', 'show-title=no');  // hide question title
 
// The following three lines each show items 1 to 4 and 6 in question BS07
question('BS07', array(1,2,3,4,6));
question('BS07', array('1-4',6));
question('BS07', '1-4,6');
 
question('SK01', 'spacing=4');  // Display a scale and directly beneath ...
question('SK02', '1', 'show-title=no');  // ... the first item of a free text input "Other: ___"
en/create/functions/question.1468326309.txt.gz · Last modified: 12.07.2016 14:25 by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki