Dear All
Am using CAPI for data collection but I desire to set time limits on particular forms and variables e.g. the to set a limit of 30 seconds for all questions on a form to be answered within 30 seconds. if they are answered in less than 30 seconds, there is a field that captures the time remaining but if it is beyond 30 seconds, the system automatically closes the form and moves to another one.
Please guide me on how it can be done.
James
Time limits
-
- Posts: 1845
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Time limits
There is no way to do exactly what you are asking to do, in part because CSPro does not have a timer that you can activate. The only place where logic can run is when a user moves from one field to the next. You can approximate what you are trying to do with code like this, which would check the time after each field is entered and would move to the next form if more than 30 seconds has passed. This code, however, would allow the user to spend more than 30 seconds on the form but once the user enters a field, if more than 30 seconds has passed, would move to the next form.
PROC GLOBAL
function GetTimeInSeconds()
numeric currentTime = systime();
numeric hh = int(currentTime / 10000);
numeric mm = int(currentTime / 100) % 100;
numeric ss = currentTime % 100;
GetTimeInSeconds = hh * 3600 + mm * 60 + ss;
end;
numeric startTime;
function StartTimer()
startTime = GetTimeInSeconds();
end;
function JumpAfter30Seconds()
if ( GetTimeInSeconds() - startTime ) > 30 then
skip to FORM_2;
endif;
end;
PROC FORM_1
preproc
StartTimer();
PROC FIELD_1
onfocus
JumpAfter30Seconds();
PROC FIELD_2
onfocus
JumpAfter30Seconds();
function GetTimeInSeconds()
numeric currentTime = systime();
numeric hh = int(currentTime / 10000);
numeric mm = int(currentTime / 100) % 100;
numeric ss = currentTime % 100;
GetTimeInSeconds = hh * 3600 + mm * 60 + ss;
end;
numeric startTime;
function StartTimer()
startTime = GetTimeInSeconds();
end;
function JumpAfter30Seconds()
if ( GetTimeInSeconds() - startTime ) > 30 then
skip to FORM_2;
endif;
end;
PROC FORM_1
preproc
StartTimer();
PROC FIELD_1
onfocus
JumpAfter30Seconds();
PROC FIELD_2
onfocus
JumpAfter30Seconds();