Timers

Created: - Updated:

This article covers these topics:

The <timeout> element

The <timeout> element can be used to specify actions that will be triggered when a defined timeout expires. The start time is the time at which the survey is first started. The timeout will be checked when the user taps the next button in a question; if more time has passed since the start of the survey, than the timeout duration, the target (action) will be invoked (triggered).

Timers are defined with the <timeout> tag.

Note: pausing or stopping a survey does not pause the timeout; the timeout will be counted from the time the survey was firsts started.

 

Attribute

Value Type

Description

Time

Integer

Time in minutes since the first start of the survey.

Target

Function

Action to invoke

Timeout examples

The first line in the following script causes the questionnaire to go to Q2 when more than 60 minutes have passed since the survey was started. The second line sets the variable timed_out to 1 when more than 15 minutes have passed since the survey was started:

<timeout time="60" target="goto(Q2)"/>
<timeout time="15" target="setvar(timed_out,1)"/>

If several timeouts are defined with the same time attribute (e.g. multiple <timeout>s have time="15"), only the first one will be checked, and each subsequent timeout with the same time value will be ignored.

For example, if both <timeout>s in the above examples had time="60", the app would go to Q2 and the variable wouldn't be set.

If, when the respondent taps the next button, more than one timeout would be triggered (i.e. in last example, the respondent took 70 minutes to pass this question, which is >60 and >15), each timeout would be flagged as triggered but only the latest (with the highest value of the time-attribute) would be triggered (i.e. app will go to Q2 and the variable won't be set).

Display a Timer

A survey timer can be used to display the timer in an info question. It displays the time left to invoke (or trigger) a target specified in the survey timeout element. Pausing or stopping a survey does not pause the timer - the timer will be counted from the time the survey was started. Adding an attribute "timer" to the info question XML can enable the survey timer.

Attribute Value
Timer Set a value given in Survey Timeout time value.

Survey timer example

Info question

 

<question type="info" title="question title" id="1" text="question text" alias="Q1" timer="15"/>

In the above code, the "timer" attribute has been set to value "15" (timer = "15"). This value should match the value of the attribute time in the timeout element as shown below.

Survey Timeout

 

<timeout time="15" target="goto(Q2)"/>

 

<timeout time="30" target="goto(Q7)"/>

 

Note: the timer will not be displayed if the value set in the timer attribute doesn't match with any one of the time values in the <timeout> elements.

Use cases

Survey Timeout is the right tool for timed questionnaires/activities

If you want to make sure the panellist/user entry/answer is complete within two minutes, add this line to your script:

<survey id="100"…..>

  <item id="1"/>

  <timeout time="2" target="endsurvey(screenout)"/>

</survey>

If you want to trigger a certain question/display an info screen after 2 minutes from the first one, add this line to you script:

<survey id="100"…..>

  <item id="1"/>

  <item id="2"/>

  <timeout time="2" target="goto(Q2)"/>

</survey>

You can stress the timed activity by showing the Survey Timer, say you want the activity to be completed within 5 minutes, you can start showing the Survey Timer counting down as follow:

<survey id="99" …>

  <item id="1"/>

  <item id="2"/>

  <timeout time="5" target="endsurvey(screenout)"/>

</survey>

<question type="info" title="question title" id="1" text="question text" alias="Q1" timer="5"/>


For an example, download survey3396-export.xml