Overview
SurveyToGo supports usage of Timers.
Timers, as expected, are used to act as stop watch’s.
This How-To will introduce you to basic usage of timers in a few simple steps:
Step 1: Configuring a basic timer.
Step 2: How to use the time measured by a timer.
Step 3: Configuring an Action for elapsed timers.
Let’s Go !
Step 1: Configuring a basic timer.
Setting a timer is done by using the Set Timer function.
The Set Timer function gets 3 Parametrs, for example:
Timers.SetTimer(“MyTimer”,30000,false);
1st Parameter: Name of the timer as a string.
2nd Parameter: Time in milliseconds.
3rd Parameter: Boolean value – ‘true’ for reactivating the timer each time it is being elapsed,
‘false’ for NOT reactivating the timer each time it is being elapsed.
This script better be written in a Start Script of the question where you would like to start it.
If needed, you can also stop the timer inside a Start\End Script, for example:
Timers.PauseTimer(“MyTimer");
1st Parameter: Name of the timer to pause as a string.
Step 2: How to use the time measured by a timer.
Let’s say we want to measure a time between a beginning of a timer and a “Pause” of a timer.
This link will show you which script you should add in addition to your timers:
https://support.dooblo.net/hc/en-us/articles/208294935-How-To-Measure-Time-Of-Specific-Questionnaire-Parts
Step 3: Configuring an Action for elapsed timers.
Timers are enabled to have an ‘Action’ when a timer is elapsed, in order to configure such an action, you would need first of all to add this function to the ‘Advanced Scripts’ (Exactly is written):
function OnTimer(key)
{
}
This function is activated every time a timer in the survey is elapsed and runs the code written inside of it.
So, in order to configure a separate action for each timer you can add ‘if’ statements, for example:
function OnTimer(key)
{
if(key==“MyTimer”)
{
Prompt(“MyTimer was elapsed!!!”);
}
}
This function, would check if the current “key” (name of the timer that was elapsed) is equal to “MyTimer” (the name of the timer we configured), if it does, it would execute the code I wrote.
You can add an ‘if’ for each timer in the survey (if an action needed), for example:
function OnTimer(key)
{
if(key==“MyTimer”)
{
Prompt(“MyTimer was elapsed!!!”);
}
if(key==“test1″)
{
Prompt(“test1 was elapsed!!!”);
}
if(key==“test2″)
{
Prompt(“test2 was elapsed!!!”);
}
}
If you wish to move to the next question once a timer is elapsed, you can use the following code:
ExecutionMgr.GotoNext()
However, any action needed can be scripted.
That’s it!
Comments
Please sign in to leave a comment.