I'm not sure if you are aware, but IOM does know the difference
between:
1) Live
2) Test (use IOM.Info.IsTest)
3) Debug (use IOM.Info.IsDebug)
Although this is not directly related to AutoAnswer, it may still
help you a bit. IOM.Info.Test is when your project is in Test mode
or if you put Test=1 on the URL. IOM.Info.IsDebug is true when you
run the survey in mrStudio, which is where AutoAnswer takes place.
IOM.Info.IsDebug is great for this type of logic because it will
never, ever run in the live or test survey. You can, for example,
set specific values that let you get thru complicated parts of the
survey (which might trip up the autoanswer).
Don't forget there are also 'metadata hints' which only get read by
the autoanswer facility. This was purposely implemented for the
purpose of getting past complicated sections of a survey (during
autoanswer). You can find more information in the DDL.
Hope this helps.
And thanks for the great topic,
Jamey
--- In NADUG@yahoogroups.com, "mailhodge" <mailhodge@...> wrote:
>
> 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
>