JustCode : Responses under radio buttons

This code shows us how to have our responses under the radio buttons.

Metadata(en-AU, Question, Label)
    Q1 "This is a Rating Scale {ReplaceMe}"
        categorical [1..1]
        {
        _1 "1 Poor",
        _2 "2",
        _3 "3",
        _4 "4",
        _5 "5 Good"
    };

End Metadata

And now for the routing.


Routing(Web)

    Q1.Style.Columns = 5

    Q1.Label.Inserts["ReplaceMe"] = "(Responses underneath)"
    Q1.Categories[..].Label.Style.ElementAlign=ElementAlignments.eaNewLine
    Q1.Categories[..].Style.Indent=0
    Q1.Categories[..].Style.Align=Alignments.alCenter
    Q1.Style.Orientation=orientations.orRow
    Q1.Ask()

End Routing

JustCode : Remove a language from MDD via script

This example show us how to open up an MDD file in read-write mode and remove a langauge from it.

' ****************************************
' Designed by : Smarter Dimensions
' Last Updated : 26th September 2009
' Open MDD file and remove language
' ****************************************

    Dim oMDM

    ' Create the MDM object and open the Short Drinks .mdd file in read-write mode
    Set oMDM = CreateObject("MDM.Document")
        oMDM.Open("c:\tempNew.mdd", ,2)

        oMDM.Languages.Remove("JPN")

        oMDM.Save()

        oMDM.Close()

JustCode : Randomize Cats V2

This function will randomize categories and make sure that some do not sit next to each other.

Sub q13aran(q,o)
    Dim cat, cat1, cat2, cat3, cats
    Dim idx, idx1, idx2, idx3
    Dim strFilt

    ' Randomize
    q.Categories.Order = o
    idx = 0
    idx1 = 0
    idx2 = 0
    idx3 = 0

    ' Find 3 categories interested in
    For Each cat in q.Categories
        idx = idx + 1
        If ( cat = {_18} Or cat = {_19} Or cat = {_20} ) Then
            If ( idx1 = 0 ) then
                idx1 = idx
                cat1 = cat.name
            ElseIf ( idx2 = 0 ) Then
                idx2 = idx
                cat2 = cat.name
            ElseIf ( idx3 = 0 ) Then
                idx3 = idx
                cat3 = cat.name
            End If
        End If
    Next

    ' If not next to each other, then keep what we have
    If ( (idx1 + 1) <> idx2 And (idx2 + 1) <> idx3 ) Then Exit Sub


    If ( (idx1 + 1) = idx2 And (idx2 + 1) = idx3 ) Then  ' If all 3 in a row
        If ( idx1 = 1 ) Then           ' First 3
            idx2 = idx2 + 1
            idx3 = idx3 + 2
        ElseIf ( idx3 = idx ) Then     ' Last 3
            idx1 = idx1 - 2
            idx2 = idx2 - 1
        Else                           ' in middle
            idx1 = idx1 - 1
            idx3 = idx3 + 1
        End If
    ElseIf ( idx1 = 1 And idx2 = 2 And idx3 = 4 ) Then  ' 1,2,4
        idx2 = 3
        idx3 = 5
    ElseIf ( idx1 = 1 And idx2 = 3 And idx3 = 4 ) Then  ' 1,3,4
        idx2 = 3
        idx3 = 5
    ElseIf ( (idx1 = (idx - 3)) And idx2 = (idx - 1) And idx3 = idx ) Then  ' last-3,last-1,last
        idx1 = idx1 - 1
        idx2 = idx2 - 1
    ElseIf ( (idx1 = (idx - 3)) And idx2 = (idx - 2) And idx3 = idx ) Then  ' last-3,last-2,last
        idx1 = idx3 - 4
        idx2 = idx3 - 2
    Else

        If ( (idx1 + 1) = idx2 ) Then
            If ( idx1 = 1 ) Then          ' idx1 is first category
                idx2 = 3
            Else
                idx1 = idx1 - 1
            End If
        End If

        If ( (idx2 + 1) = idx3 ) Then
            If ( idx3 = idx ) Then         ' idx3 is last category
                idx2 = idx2 - 1
            Else
                idx3 = idx3 + 1
            End If
        End If

    End If

    ' Convert list into a string of categories
    strFilt = ""
    idx = 1
    For Each cat in q.Categories
        If ( idx = idx1 ) Then
            strFilt = strFilt + cat1 + ","
            idx = idx + 1
        ElseIf ( idx = idx2 ) Then
            strFilt = strFilt + cat2 + ","
            idx = idx + 1
        ElseIf ( idx = idx3 ) Then
            strFilt = strFilt + cat3 + ","
            idx = idx + 1
        End If
        If ( cat <> {_18} And cat <> {_19} And cat <> {_20} ) Then
            strFilt = strFilt + cat.name + ","
            idx = idx + 1
        End If
    Next

    ' Put into custom order in .Categories
    strFilt = Left(strFilt,Len(strFilt) - 1)
    q.Categories.Filter = {}
    q.Categories.Order = OrderConstants.oCustom
    cats = split(strFilt,",")
    For idx = lbound(cats) to ubound(cats)
        q.Categories.Filter = q.Categories.Filter + CCAtegorical("{" + cats[idx] + "}")
    Next

    ' Catch all to ensure these are all captured - should never happen
    If ( FindItem(q.CAtegories,{_18}) is null ) Then q.Categories = q.Categories + {_18}
    If ( FindItem(q.CAtegories,{_19}) is null ) Then q.Categories = q.Categories + {_19}
    If ( FindItem(q.CAtegories,{_20}) is null ) Then q.Categories = q.Categories + {_20}

End Sub

JustCode : Randomize Cats V1

This function will randomize categories and make sure that some do not sit next to each other.

 Metadata(en-US, Question, Label)
q1loop "blah" loop
{
_1 "_1",
_2 "_2",
_3 "_3",
_4 "_4",
_5 "_5",
_6 "_6",
_7 "_7",
_8 "_8",
_9 "_9"
} fields -
(
q1 ""
categorical [1..1]
{
_1 "_1",
_2 "_2",
_3 "_3",
_4 "_4",
_5 "_5"
};

) expand;
End Metadata

And in the routing

Routing(Web)

Dim i

    q1loop.Categories.Order = OrderConstants.oCustom
    For i = 1 to 20   ' test 20 times
        q1loop.Categories.Filter = RanNotTogether(q1loop,{_3,_4,_5},Null)
        q1loop[..].q1.Response.Initial = {_1}
        q1loop.Ask()
    Next

'! Returns a category list of all categories in question.categories
where none of the categories in notTogether are next to one another
Caution should be taken to ensure that there is enough room to allow for
the notTogether codes to be separated by at least one other code
For example, a question with 9 items having 5 items that can't be together
is not possible.
ARGS:  question - question whose categories are used
notTogether - category list of categories that cannot appear together
seed - if not Null, then used as the random seed
RETURNS:  category list randomized so that none of the notTogether categories are next to each other
EXAMPLE:
q10loop.Categories.Order = OrderConstants.oCustom
q10loop.Categories.Filter = RanNotTogether,q10loop,{coke,pepsi,rccola},Null)
!'

Function RanNotTogether(question,notTogether,seed)
    Dim randomCodes,notTogetherCodes
    Dim randomCodeList,randomCode,codeCount
    Dim FinalArray[],strFilter

    ' Make array large enough for all categories
    ReDim(FinalArray,question.Categories.Count)

    ' Initialize array to blanks
    For codeCount = LBound(FinalArray) to UBound(FinalArray)
        FinalArray[codeCount] = ""
    Next

    ' Codes allowed to be together
    randomCodes = SelectRange(question.Categories - notTogether)

    ' Codes not allowed to be together
    notTogetherCodes = SelectRange(notTogether)

    codeCount = 0
    ' Place codes not allowed to be next to each other
    If ( seed is not null ) Then SetRandomSeed(seed)
    randomCodeList = ransequence(0,UBound(FinalArray),1)

    For Each randomCode in randomCodeList
        Select Case ( randomCode )
            Case 0 ' Can't have any to right
                If FinalArray[randomCode + 1] = "" Then
                    FinalArray[randomCode] = notTogetherCodes[codeCount]
                    codeCount = codeCount + 1
                End If
            Case UBound(FinalArray) ' Can't have any to left
                If FinalArray[randomCode - 1] = "" Then
                    FinalArray[randomCode] = notTogetherCodes[codeCount]
                    codeCount = codeCount + 1
                End If
            Case Else ' Can't have any to right or left
                If FinalArray[randomCode + 1] = "" And FinalArray[randomCode - 1] = "" Then
                    FinalArray[randomCode] = notTogetherCodes[codeCount]
                    codeCount = codeCount + 1
                End If
        End Select

        ' If placed all those that can't be together, then get out of loop
        if ( codeCount > UBound(notTogetherCodes) ) Then Exit For
    Next

    ' Add the remaining codes
    codeCount = 0
    For Each randomCode in randomCodeList
        ' If haven't used this position, then put in the next remaining code
        If FinalArray[randomCode] = "" Then
            FinalArray[randomCode] = randomCodes[codeCount]
            codeCount = codeCount + 1
        End If
    Next

    ' convert to a categorical list and return
    strFilter = ""
    For codeCount = LBound(FinalArray) to UBound(FinalArray)
        strFilter = strFilter + question.Categories[CCategorical(FinalArray[codeCount])].Name + ","
    Next
    RanNotTogether = CCategorical("{" + Left(strFilter,Len(strFilter)-1) + "}")
End Function

End Routing

2×4 Data Collection Interviewer Server Backup Application

I have been on holiday for the last few weeks and during that time I managed to get some articles written. Whilst on holiday I was asked by 2×4 if I wanted to have a play with their backup tool and of course I excepted. This article is about that app and it shows you what it can do and how you can do it in the first release. To be honest , and I get nothing for saying this , I think this will turn into a “Must Have App” for all those users out there , and I know a few , that struggle with or do not even do backups. With a couple of clicks you have backed up a project or restored it. No Complicate procedures , just a few clicks and you are done. Anyway , here is what I did and the screen shots that go with it.

Read more2×4 Data Collection Interviewer Server Backup Application

Terminate an interview

When we create surveys our aim is to collect valid answers on a particular subject from a valid respondent. We are not actually interested in some respondents answers because they might not fit the profile of the survey. For example if we were running a survey on women’s makeup we would not really want any men to fill in the survey. In this article we will see some ways in which the survey can be terminated so that we do not waste peoples time answering questions that are not really for them.

Read moreTerminate an interview

Browser IP Address, Latitude & Longitute information gathering

For a while now , i have been pondering how this could be done and if the results would be any use. What i am talking about is getting the users Latitude / Longitute & IP address that is running the survey. Now the first thing to mention is that it would not realy be their IP address, but the IP address or location of the machine that is used to connect to the internet. Anyway this is the code i came up with and i am sure it will be of use.

Another thing to mention is that if you are trying to run this on an intranet then it would not give you the results you wanted. It should be possible to design something similar and we may leave that for another article.

Read moreBrowser IP Address, Latitude & Longitute information gathering

Linking your surveys to your protal.

Lots of users have the need to link their surveys to other systems or portals. In this article we discuss some of the things that you can do to get all this to work. We will look at linking surveys to particular people, how we can get their existing database information into the survey data and how we can have one link that can decide what surveys they should be running, reducing the need to continually change the link they click on.

Read moreLinking your surveys to your protal.

%d bloggers like this: