### Archive

Archive for the ‘Survey Logic’ Category

## Survey Logic – Module 05: Filtering Logic

January 21, 2013 Leave a comment

Filtering Logic

This video covers the SurveyToGo filtering logic.

return back to our videos page

Categories: Survey Logic, Videos

## Survey Logic – Module 06: Validation Logic

January 21, 2013 Leave a comment

Validation Logic

This video covers the SurveyToGo validation logic.

return back to our videos page

Categories: Survey Logic, Videos

## Script Writer’s Function Hand-Book

August 15, 2012 1 comment

This document contains most of the common every-day usable functions in SurveyToGo.
Explained, demonstrated and elaborated.
This document is directly connected to us, and is constantly updated with new functions and info by our professional team, stay updated!
A Survey Script Writers True Gem!

FilterAnswersByAnswers \ FilterTopicsByAnswers:

Explanation: This function gets a target question index and a source question.
It filters the Current Question’s answers through, according to the answers chosen in the source questions specified.

Input: Gets 2 Parameters

1st Parameter: The Target Question.

2nd Parameter: A Boolean value – ‘true’ for showing answers selected, ‘false’ for showing answers not selected.

3rd Parameter: The Source Questions.

Output: Filters the specified answer index’s

Example of How to write:
FilterAnswersByAnswers(CurrQues,true,QRef(15));
FilterAnswersByAnswers(CurrQues,
true,QRef(15),QRef(16),QRef(17));
FilterTopicsByAnswers(3,
false,QRef(2));

SelectedAnswerText:

Explanation: This function gets a target question index and returns the text of the answer selected

Input: Gets 2 Parameters.

1st Parameter: The Target Question index.

2nd Parameter: A Boolean value – ‘true’ for getting the ‘Other Specify’ input too, ‘false’ for not getting the ‘Other Specify’ input text.

Output: Text of the answer selected

Example of How to write:
SelectedAnswerText (5,true);
SelectedAnswerText (2,
false);

Answer:

Explanation: This function gets a target question index of only single choice questions such as:
(Single-Choice, Numeric, Open Ended, Scale, Expression)
and returns its selected answer index.

Input: Gets 1 Parameters

1st Parameter: The Target Question.

Output: Returns its selected answer index

Example of How to write:
Answer(CurrQues);

Contains:

Explanation: This function gets a target question index of only Multi-Selection questions and an answer index, and checks if this answer was selected.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Answer Index.

Output: returns ‘True’ if the given answer was selected – returns ‘False’ if the given answer was not selected.

Example of How to write:
Contains(2,1);

SetAnswerVisible \ SetTopicVisible:

Explanation: This function gets a target question index, a answer\topic index, and a Boolean value (true/false), and shows\hides the given answer\topic.

Input: Gets 3 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Answer\Topic Index.

3rd Parameter: A Boolean value. (‘true’ for showing – ‘false’ for hiding)

Output:

Example of How to write:
SetAnswerVisible(CurrQues,2,false);
SetTopicVisible(CurrQues,4,
false);

AnswerChoice:

Explanation: This function gets a target question index of a ‘Single-Choice-Grid’ question only, and a topic index.
it returns the index of the selected answer in the given topic.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Topic Index.

Output: returns an index of the selected answer in the given topic within the given multi-topic question.

Example of How to write:
AnswerChoice(CurrQues,3);
AnswerChoice(1,2);

NumOfSelectedChoices:

Explanation: This function gets a target question index of a multi-selection question only, and returns the number of selected answers.

Input: Gets 1 Parameters

1st Parameter: The Target Question Index.

Output: returns the number of selected answers.

Example of How to write:
NumOfSelectedChoices(CurrQues);

GetTopicCount:

Explanation: This function gets a target question index of a Single-Choice Grid question only, and returns the number of topics.

Input: Gets 1 Parameters

1st Parameter: The Target Question Index.

Output: returns the number of topics.

Example of How to write:
GetTopicCount(CurrQues);

AnswerIter:

Explanation: This function gets a target question index of questions that are within a loop of only single choice questions such as:
(Single-Choice, Numeric, Open Ended, Scale, Expression)
and an iteration index.
It returns the answer of the target question in the given Iteration Index.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Specific Iteration Index.

Output: Returns its answer in the given iteration index within the loop.

Example of How to write:
AnswerIter (CurrQues,
3);

AnswerIter (CurrQues,IterationIndex);

*NOTE:IterationIndex Represents the current iteration when running within a loop, so it’s value is set according to the iteration which is currently running.

ContainsIter:

Explanation: This function gets a target question index of questions that are within a loop of only multi-selection question, an answer index and an iteration index.
It checks if the given answer was selected in the target question within the given Iteration Index.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Specific Iteration Index.

3rd Parameter: The Specific Iteration Index.

Output: returns ‘True’ if the given answer was selected in the given iteration – returns ‘False’ if the given answer was not selected in the given iteration index.

Example of How to write:
ContainsIter(CurrQues,
3,7);

ContainsIter (CurrQues,2,IterationIndex);

*NOTE:IterationIndex Represents the current iteration when running within a loop, so it’s value is set according to the iteration which is currently running.

Random():

Explanation: This function gets an integer and returns a random number between the 0 and the integer number given minus 1.

Input: Gets 1 Parameter.

1st Parameter: Maximum number. (Please note that the number generated is between zero till a number that is 1 less than the maximum number given)

Output: returns a random integer within the given range.

Example of How to write:
Random(5);

Random(732);

SelectedAnswerText():

Explanation: This function gets a target question index and a Boolean and returns a text string with all the answers chosen in the given question index, separated with a comma.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: ‘true’ for including any ‘Other Specify’ text, ‘false’ for not including any ‘Other Specify’ text.

Output: returns a text string with all the answers chosen in the given question index, separated with a comma.

Example of How to write:
SelectedAnswerText(12,true);

SelectedAnswerText(CurrQues,false);

SetAnswer():

Explanation: This function gets a target question index and a target answer index and sets this answer is chosen in the given question index

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Answer Index

Output: doesn’t return anything, just sets the answer given.

Example of How to write:
SetAnswer(5,2);
SetAnswer(CurrQues,8);

## How To Use & Implement ‘For’ Loops

July 8, 2012 Leave a comment

Overview

‘For’ loops are a very common function\feature which is one of the basic fundamentals of programming.
It used in most of the known programming languages and it is very useful for many different scenarios.

SurveyToGo Studio is open for usage of C# and JavaScript syntax which both have ‘For’ Loops.
This ‘How-To’ will introduce you to ‘For’ loops and will explain how to use them in SurveyToGo.

Step 1: Introduction & Structure of ‘For’ loops.

Step 2: Implementing ‘For’ loops in SurveyToGo.

Let’s go !

Step 1: Introduction & Structure of ‘For’ loops.

For loops are basically iterative loops which get 3 parameters and some code for action, here is how the structure of a ‘For’ loops looks like:

*Green Text are comments*

for( [Initial Expression] ; [condition] ; [Increment Expression] )

{                //Iteration Starts !

[ACTION];        //Action Code !

}                //Iteration Ends !

[Initial Expression] : This piece of code runs only once , at the moment the loop is entered.

[condition] : This piece of code is the condition which is checked each iteration before it begins.

[Increment Expression] : This piece of code is executed each time an iteration is ended.

Here is an example of how it would really be implemented:

for( var i=0 ; i<10 ; i++ )

{

SetAnswer(CurrQues,i);

}

* This loop will iterate 10 times, each time it will execute the code written. (notice I used ‘i’ in the code, which means each iteration its value will change !)

1st Param: Declaration of a variable called ‘i’ (this is in JavaScript, in C# ‘var’ should be replaced with ‘int’).

2nd Param: The condition of the loop, as long as ‘i’ value is less than 10, the loop will run.

3rd Param: Here we would usually want to increment by 1 our initialization variable every end of iteration, so the loop will meet it condition sometime and end, if the condition would not be met, the loop will keep on going forever and ever and ever…etc’.
* ‘++’ operator increments the variable from its left by 1.

Action Code (Withing the Curly Bracelets): Here you can write any code you have in mind, your only limit is your own imagination (and syntax limitations J).

Step 2: Implementing ‘For’ loops in SurveyToGo.

For loops can be implemented wherever you want\need to use them, except for entrance rules and jump rules.
You can implement them in Start\End scripts, Survey Init code, Advanced scripts, etc’.

I would show you a nice use of ‘For’ loops in SurveyToGo.
Lets say for the example that we have one multi-topic question (single choice grid) and one
Single-Choice question.
Multi-topic question will have worker names as topics, and grades as answers:

Let’s say, for example, that we want the next single choice question to show only workers which are rated less than average.
*The answers are:
1. Excellent.
2.Good.
3.Average.
4.Bad.
5.Horrible.

In that case we can use a ‘For’ loop that will iterate according the topics and will filter out only the ones suitable to our request, for example.
I would enter in the next question’s start script the following:

for(var i=1; i<=GetTopicCount(CurrQues1); i++)

{

if(AnswerChoice(CurrQues1,i)<=3)

{

SetAnswerVisible(CurrQues,i,false);

}

}

basically what I did here is configured a loop to run from 1 until the number of topics in the previous question, incrementing ‘i’ each iteration by 1.

Each iteration I checked if the answer of Topic i, in the previous question, is less or equal to 3.
If the answer is less or equal to 3, what means Average, good or Excellent, so I would like to hide that answer, by using SetAnswerVisible, with the value of ‘i’.
* The single choice question will have the same names in the same order as answers.

Eventually it would hide the workers rated 3 or less, and will show only the workers rated 4 or 5. (Bad, horrible.)

There is no limit to what you can do with ‘For’ loops, this is just a basic example of how you can use it for basic things in SurveyToGo.

That’s it!

Visit us at: http://www.dooblo.net

## How To Add Validation Rules

May 22, 2012 Leave a comment

Overview

SurveyToGo fully supports scripting and usage of validation rules.
From the simplest ones, to the most complicated.

A Validation rule is a script that is added to a question and will be checked each time the question is being advanced forward.
If the script is valid, it will proceed to checking the jump rule (if there is one), and continue to the next question.
If it is not valid, it would prompt a custom message, and will not allow continuing.

Step 1: Add a new instance of a validation rule.

Step 2: Configuring The validation rule’s condition.

Step 3: Configuring the Validation Rule’s Custom Message.

Adding a new instance of a validation rule.

In order to add a validation rule to a question, you should go to the questions ‘Rules’ tab.
Then, you should click the button for creating a new instance of a validation rule:

Configuring The validation rule’s condition

Now let’s add the condition:

Let’s say, for this example that the current question asks about:
“How many of your kids like chocolate?”

And that question number 2 asks:
“How many kids do you have?”

So this validation rule basically checks if the answer of the current question is greater than the answer of question 2, which is not reasonable – as if a person says he has 3 kids, but he answers that 5 of his kids like chocolate, it does not make sense.
Therefore the validation rule comes in hand.

Configuring the Validation Rule’s Custom Message.

Now, let’s add an error message to prompt:

This message will prompt if the answer would be greater than the answer of question 2 and will not allow continuing, as the validation rule says.

Important Note: When adding a validation rule in an expression question do not use Answer(CurrQues) as the answer value is not yet available at the stage when the rule is executed due to the order of actions within an expression question execution.

That’s it!

Visit us at: http://www.dooblo.net

## How To Add Entrance Rules (Skip Rules)?

May 22, 2012 Leave a comment

Overview

SurveyToGo fully supports scripting and usage of entrance rules (Skip Rules).
From the simplest ones, to the most complicated.

An entrance rule is a script that runs before a question is entered and decides whether this question will be asked or skipped.
If the script is valid, the question will be asked, if not, it would skip it.

Write your Entrance Rule.

You can find the entrance rule text box in each questions ‘Rules’ tab:

Now we can add an entrance rule as we wish.
For example:

This rule, will show the specific question, only if the answer of question 5 is answer 2.

You can add much more complicated rules and even use functions.
Further more, you can use the ‘Create Rule’ Wizard, however, it is more limited then writing your script on your own.

That’s it!

Visit us at: http://www.dooblo.net

## How To: Create Branch Rules

May 14, 2012 1 comment

Overview

SurveyToGo fully supports scripting and usage of branch rules (Jump rules).
From the simplest ones, to the most complicated.

In this ‘How to’ I will show you the simple steps in order to start implementing your branch rules (Jump rules).

Step 1: Add a new instance of a Jump Rule.

Step 2: Configuring The Branch rule’s condition.

Step 3: Configuring the Branch Rules Action & Target.

Step 1: Adding a new instance of a Jump rule.

A Branch rule is a condition that will be checked once a question was finished, if the condition is valid, the action configured would be executed:

First of all, you should go into the desired question’s Rules Tab and create a new instance of a branch rule, as the following picture:

Step 2: Configuring the Branch Rule’s condition.

If you click the ‘<Set condition>’ text box, you would be able to enter your own script for the condition, for example:
‘Answer(CurrQues)==2’

Any script that eventually returns a true\false value is valid here.

Step 3: Configuring the Branch Rules Action & Target.

By clicking on the ‘<Set Action>’ text box, you would be able to set the desired action:

And the same for the ‘Target’ text box, for example:

This branch rule, will go to question index 3, if the answer of the current question is 2.

That’s it !

Visit us at: http://www.dooblo.net