Recently we posted an article on how to use Autoanswer and from that article we got a request to do an article on how to use hints. So here you are , an article on autoanswer hints and how to use them.
So what are autoanswer hints? well they are properties that we can set in our mdd that helps autoanswer answer specific questions that might be difficult for the autoanswer player to answer. For example, if you have an email question and you are using regular expressions to check the format of the text entered to validate if it is a real email address or not, the autoanswer player will not be able to generate an email address, because basically all it knows is that it needs to create a random text string, not an email address.
So how do we set them up , well its easy , if you are using Desktop Author you can select your question you want to add hints to and click on the advanced properties link in the explorer and then you will see the following screen
You should see that we have three boxes we can put things in they are, ( as described in the DDL )
AllowedCategories : For categorical questions, this string property defines a subset of categories from which Professional can choose an answer. For example, if a question’s category names are the seven days of the week, you could set the value of this property to monday, tuesday, saturday to specify that Professional can choose the answer only from those three categories.
When specifying the value of this property, do not enclose the value within braces. When specifying more than one category name, separate the category names using commas. If the question includes factors, specify the category names as described above and not the factor values.
Max : For numeric and date questions, this property defines the maximum value that can be used as an answer. For text questions, this property defines the maximum length of the answer. For categorical questions, this property defines the maximum number of categories that Professional should choose.
For numeric and date questions, set the data type of this property to match the question type (either long, double, or date). For text and categorical questions, set the data type to long.
Min : For numeric and date questions, this property defines the minimum value that can be used as an answer. For text questions, this property defines the minimum length of the answer. For categorical questions, this property defines the minimum number of categories that Professional should choose.
For numeric and date questions, set the data type of this property to match the question type (either long, double, or date). For text and categorical questions, set the data type to long.
Value : The actual value that Professional should use for the answer. You can use this hint for any type of question. If the hint is for a categorical question, specify the category name or names using the same method as that described above for allowedCategories.
For numeric and date questions, set the data type of this property to match the question type (either long, double, or date). For text and categorical questions, set the data type to string.
so how do we set these values in Professional , first off we need some metadata let’s take our email example,
Metadata(en-AU, Question, Label) Email "Please enter email address" text; End Metadata
Next we need to add an Autoanswer context, To do this you need to click on the label manager in Professional
Then click on the context tab, followed by Add and check the custom option and enter the words “Autoanswer”. Then click Ok,followed by Ok.
Next you will need to click on the view menu option in Professional and go down to the contexts link , then place a tick next to the words Autoanswer.
If you have done everything correctly you should see the following in your metadata,
Metadata(en-AU, Question, Label) AUTOANSWER lcl(en-AU, Autoanswer, Label); '### END LCL MAP ### HDATA - AUTOANSWER:-; Email "Please enter email address" AUTOANSWER:- text; End Metadata
Next we need to change our email metadata to look like this,
Email "Please enter email address" AUTOANSWER:- AUTOANSWER: [ Value = "smarterDimensions@live.com.au" ] text;
So what does all this say , well first off we have the question name and text , nothing new here then we have the AutoAnswer Context text, what this means is that if we wanted to , when the autoanswer context was used we could display different words to the user, but because we are talking about the autoanswer player here we don’t care what the words displayed are , so we just take the words from the default context which in this case is the Question Context. If we did want to have different words the you would need to change the AUTOANSWER:- to something like
AUTOANSWER: "Email Address: "
Next we assign a custom property called Value to the Email Question autoanswer context which has the value of “smarterDimensions@live.com.au“. So now we are ready to play the survey in professional and autoanswer. When you do this, if you look at the output tab, you should see entries for the Email question like the ones listed,
8/01/2010 8:55:06 AM: Creating Interview: HInts 99 of 100 8/01/2010 8:55:06 AM: Attaching Debugger to Debug Site 8/01/2010 8:55:06 AM: Auto answered: Navigation = Next, Question = Email, Type = Simple, DataType = Text, Response = smarterDimensions@live.com.au. (Hint(s) used: Value = smarterDimensions@live.com.au.)
So we have shown you how to set the hints for a text response, and it should be obvious that if you wanted to use other question types then you just need to set the Max or Min values in the same way. Here are some examples,
A Single Response Question using Value,
SingleResponseQuestion "" AUTOANSWER:- AUTOANSWER: [ Value = "D" ] categorical [1..1] { A "A" AUTOANSWER:-, B "B" AUTOANSWER:-, C "C" AUTOANSWER:-, D "D" AUTOANSWER:-, E "E" AUTOANSWER:-, F "F" AUTOANSWER:- };
A Multiple Response Question using AllowedCategories
MultiResponseQuestion "" AUTOANSWER:- AUTOANSWER: [ AllowedCategories = "A,B,C" ] categorical [1..] { A "A" AUTOANSWER:-, B "B" AUTOANSWER:-, C "C" AUTOANSWER:-, D "D" AUTOANSWER:-, E "E" AUTOANSWER:-, F "F" AUTOANSWER:- };
A numeric Question using max and min
NumericQuestion "" AUTOANSWER:- AUTOANSWER: [ Max = 10, Min = 20 ] long;
The full code for this article can be found in :
http://CodeCorner.SmaterDimensions.Com @ Adding AutoAnswer Hints to your MDD
I must recommend against using this method. It is very cumbersome and difficult to implement. An easier solution is to use the IOM.Info.IsAutoAnswer property. This allows the “hints” to be entered in the routing and doesn’t require adding/using contexts with difficult to read formats.
Examples
If ( IOM.Info.IsAutoAnswer ) Then
email = “smarterDimensions@live.com.au
Else
email.Ask()
End If
If ( IOM.Info.IsAutoAnswer ) Then
MultiResponseQuestion.Categories.Filter = {a,b,c}
End If
MultiResponseQuestion.Ask()
If ( IOM.Info.IsAutoAnswer ) Then
NumericQuestion.Validation.MinValue = 10
NumericQuestion.Validation.MaxValue = 20
End If
NumericQuestion.Ask()
If ( IOM.Info.IsAutoAnswer ) Then
zip = CText(RanInt() MOD 100000)
While ( Len(zip) < 5 )
zip = "0" + zip
End While
Else
' Check for valid 5 or 5-4 digit zip code
zip.Validation.Function = "CheckZipCode"
zip.Ask()
End If
This is a very cool way of doing things Roger. Thanks for the update. As you say, more controll.