Professional > Interview scripting > Writing interview scripts > Creating questionnaire wizards for UNICOM Intelligence Author > UNICOM Intelligence Author questionnaire wizard examples > Complete source example > Complete UNICOM Intelligence Author wizard example
 
Complete UNICOM Intelligence Author wizard example
The following is a complete example of a Wizard script.
SetInitialValues:
'--- Start of IOM Script item SetInitialValues ---
QText.Response.Initial = ExampleQText.Label
QResponses.Response.Initial = ExampleQResponses.Label
Sum.Response.Initial = 100
Attempts.Response.Initial = 3
Template.Response.Initial = "Default"
'--- End of IOM Script item SetInitialValues ---


ExampleQText.MustAnswer = true
ExampleQResponses.MustAnswer = true

'--- Start of page Page ---
Page.QText.Style.Columns = 40
Page.QText.Style.Rows = 4
Page.QResponses.MustAnswer = true
Page.QResponses.Style.Columns = 40
Page.QResponses.Style.Rows = 6

Page.Attempts.MustAnswer = true
Page.Template.Style.Control.Type = ControlTypes.ctCheckButton
Page.Template.MustAnswer = true
Page.Ask()
'--- End of page Page ---


Script:
'--- Start of IOM Script item Script ---
' All QWzd questions have been asked. Use the answers to process
' the questionnaire library item.

Dim mdm, script, target
' A reference to the source is provided by the variable named source_mdm
' A reference to the target is provided by the variable named target_mdm
' target_mdm should not be modified – and may be a clone of the actual target MDD

Set mdm = source_mdm
' Add the responses
AddResponses(mdm, QResponses.Response, mdm.Fields["ConstantSumQ"].Elements)

' Set the max value to the sum
mdm.Fields["ConstantSumQ"].Fields["Value"].RangeExpression = "[1.." + CText(Sum.Response) + "]"

' Get the script from the Mdm, this includes both metadata and routing
script = mdm.Script
' Perform text replacement on the script version of the shell questionnaire
script = Replace(script, "<constantsum_qtext>", QText.Response)
script = Replace(script, "<constantsum_sum>", CText(Sum.Response))
script = Replace(script, "<constantsum_attempts>", CText(Attempts.Response))
If (Template.Response <> "Default") Then
script = Replace(script, "Card_Blue_TopAndBottomErrors.htm", Template.OtherTemplate.Response)
End If
' Apply the changed script back to the questionnaire library item
mdm.Script = script

source_mdm = mdm;
' we use the source_mdm variable as the value to insert upon completion
' because mdm is a reference to sourceMDM, modifications to the mdm
' variable affect the sourceMDM and will be picked up upon completion
' No need to save, calling program expects a variable called source_mdm with
' the MDM document
'--- End of IOM Script item Script ---

AddResponses:
'--- Start of IOM Script item AddResponses ---
Sub AddResponses(mdm, responses, elements)
' Takes multiple mr.Lf separated responses and adds them to the specified elements list
Dim elem, cats, cat_name, cat_label
cats = Split(responses, mr.Lf)
For Each cat_label in cats
If (cat_label <> "") Then
cat_name = mdm.MakeName(cat_label)
Set elem = mdm.CreateElement(cat_name, cat_label)
elem.Type = 0 'MDMLib.ElementTypeConstants.mtCategory
elements.Add(elem)
End If
Next
End Sub
'--- End of IOM Script item AddResponses ---
See also
UNICOM Intelligence Author questionnaire wizard examples