We have found that while mrStudio provides a huge advantage with the
AutoAnswer tool, it has a hard time completing in most of our
scripts. The main problem arises from the fact that if you perform
custom validation on a question or series of questions, mrStudio is
not "smart" enough to answer the question properly and thus fails
during its data generation.
Some of our initial solutions caused a lot of headache to implement
and also posed the potential of launching a study into field
with "AutoAnswer" logic which would cause bad data collection. The
nice and simple solution would be to have a native IOM property that
would tell you if the program was running in AutoAnswer mode or not;
however, this feature is not within the IOM feature set.
We found that by creating our own property we can achieve this same
logic:
dim propAutoAnswer
set propAutoAnswer = IOM.Properties.CreateProperty()
propAutoAnswer.Name = "isAutoAnswer"
propAutoAnswer.Value = false
IOM.Properties.Add(propAutoAnswer)
Now you can access the property like so:
IOM.Properties["isAutoAnswer"].Value
Now, everywhere you have access to the IOM, you have access to the
isAutoAnswer property and can adjust your logic accordingly.
However, one of the most common complaints we get is how long our
variable names are or how "deep" into objects we have to traverse to
get logic. To remedy this we also created a local dim variable
called isAutoAnswer in the main routing section. This is the
variable which the programmer would edit if about to run AutoAnswer:
dim isAutoAnswer
isAustoAnswer = false
One of our concerns though is maintaining the same value for both
the local dim variable in the routing as well as the property. In
addition, we want to ensure that there is NO possibility of a study
going live with isAutoAnswer set to true. To remedy this we place
the following logic:
if (IOM.Info.IsDebug) then IOM.Properties
["isAutoAnswer"].Value = isAutoAnswer
isAutoAnswer = IOM.Properties["isAutoAnswer"].Value
The first line only sets the isAutoAnswer property IF in mrStudio,
if you are are on the server this line never executes and as a
result the default value of false (set when we created the custom
property) will remain. The second line ensures that the local dim
variable in the routing is in sync with the IOM property. IF the
programmer left the value of isAutoAnswer = true on the server, then
the IOM.Properties["isAutoAnswer"] would not be set and remain
false, then the isAutoAnswer value is forced to false and all logic
would run properly.
With these two methods you can now run logic in both the main
routing and any function/sub which has the IOM passed to it (this
includes validation functions).
Routing example:
If isAutoAnswer then q1.Validation.Function = "q1Validate"
q1.Ask()
Function example
Function ValidateSum(Question, IOM, Attempts)
If IOM.Properties["isAutoAnswer"].Value then
ValidateSum = true
Exit Function
End if
...rest of validation...
End Function