Shared lists and dummy questions

Created: - Updated:

This article covers these topics:

Introduction to shared lists and dummy questions

Shared lists are pseudo-questions which are place-holders for choice lists, which can be included in other questions. The shared list question itself is never shown on the client device as a question.

You can use shared lists to set up dummy questions, which are questions that are hidden from the respondent. A dummy question can be used to store a calculated value that can then be referenced in scripts, while keeping this calculated value invisible to the respondent. Note that is possible to add pre and post conditions to a dummy question.

Shared lists are defined using the following tag:

<choicelist>

Attributes

Attribute

Description

type

"choicelist"

alias

Question alias.

order

Choice order: "fixed" or "randomized"

Sub elements

<choice>

Defines a choice for a single or multi-choice question.

Attribute

Description

id

Numerical id of this choice

label

Label text of the choice. If "label" attribute is not set but "text" attribute is set, the compiler will move the text value to the label.

text

Optional text that can be used to give more detailed text for a choice. (optional)

alias

Alias for the choice. (optional)

icon

Resource id of an image to display beside this choice. (optional)

selected

Flag that says if item should be initially selected or not. Default false.

anchored

Flag that says if the position of this choice should be fixed even if the choice order is randomized. (optional)

exclusive

Flag that says if choice cannot be combined with other choices. Applies only to multiple choice questions. (optional)

<include>

The <include> element can be used as a sub-element of <choice>. It allows you to incorporate choices from/to another multiple-choice question, single-choice question (not slider) or shared list. For more information about including choices see Advanced choice filtering.

Set question answer

The setans(Qref,value,type) action is used to set the answer of a specific question to a specific value.

setans attributes

Attribute

Description

Qref

Question reference, either an alias or an id with the #-prefix

value

Value to set the answer to

type

Type of answer, optional, defaults to the type of the question

The value for a multiple-choice question can be wrapped in parenthesis to set specify multiple choices, e.g. setans(Q5,(1,3,4)). If you want to use a variable as value parameter, it has to be in the format shown in the example below, with the dollar sign as prefix:

<precondition then="setans(Q2,$var(ans1))"/>

If you need to set an answer from a multiple-choice question, the following script will give you the answer IDs, for example 1,5,8:

<precondition then="setans(Q3_dummy,$answerid(Q3))"/>

The following script will give you the answers as a text string (e.g. Toyota,Nissan,Mercedes):

<precondition then="setans(Q3_dummy,$answer(Q3))"/>

setans answer types (Set Answer)

Attribute

Description

text

Text answer packet

numeric

Numeric answer packet

date

Date answer packet

choice

Choice answer packet (single)

multichoice

Multichoice answer packet

For example, when using dummy questions or shared lists you will need to use setans() to punch the dummy question's answer to your current question, as in the following example:

Dummy Question:

<question type="choicelist" alias="Q_DUMMY" (parameters)>

  <choice id="1" label="brand1" (parameters) />

  <choice id="2" label="brand2" (parameters) />

  <choice id="3" label="brand3" (parameters) />

  <choice id="4" label="brand4" (parameters) />

</question>

By using the setans() function, you can punch the answers in the dummy question and record that brand1 has been selected in Q1 and brand3 has been selected in Q2, as in the following example:

<question type="single" alias="Q5" (parameters)>

  <precondition then="setans(Q_DUMMY, [1,3])"/>

(...)

</question>

Examples

Example 1

The  following example includes all choices from Q1 excluding choice id 1.

<choice id="3" label="going to include, not shown">

  <include from="Q1" exclude="Q1:1"/>

</choice>

The following example includes all choices from Q2, but only shows those choices that were selected in Q2 (equivalent of an "if" condition on the choice).

<choice id="4" label="going to include, not shown">

  <include from="Q2" filter="true"/> 

</choice>

Example 2

Q1 random(1,4) randomly generates a number between 1 and 4 and ends up with 2 thus sets the variable rndmgames to 2. As the variable rndmgames equals 2 the variable games is set to Outrun, Archon II or Decathlon. Q2 Choice 5 will show "Multiplayer games such as Archon II or Decathlon".

Question 1 script (dummy)

<question type="info" text="dummy should not be shown" id="1" alias="Q1">   

    <precondition then="setvar(rndmgames,random(1,4))"/>   

    <precondition if="var(rndmgames)==1" then="setvar(games,'Archon, Bubble Bobble or North and South')"/>                    

    <precondition if="var(rndmgames)==2" then="setvar(games,'Archon II or Decathlon')"/>   

    <precondition if="var(rndmgames)==3" then="setvar(games,'Summer Games or Winter Games')"/>   

    <precondition if="var(rndmgames)==4" then="setvar(games,'California Games or World Games')"/>   

    <precondition then="skip"/>

</question>

Question 2 script (dummy) 

<question type="multi" max_select="32767" min_select="1" order="fixed" style="more-options-below" enable_lookup="false" id="2" text="Please select from the list below all the video games you have played the last week" alias="Q2">

    <choice id="1" label="Last Ninja II" anchored="false" exclusive="false" alias=""/>

    <choice id="2" label="Pirates" anchored="false" exclusive="false" alias=""/>   

    <choice id="3" label="Giana Sisters" anchored="false" exclusive="false" alias=""/>   

    <choice id="4" label="Out Run" anchored="false" exclusive="false" alias=""/>   

    <choice id="5" label="Multiplayer games such as $var(games)" anchored="false" exclusive="false" alias=""/>   

    <choice id="6" label="None of these" anchored="true" exclusive="true" alias=""/>

</question>

See also

Filtering