|Compatibilità:||IdSurvey 5||IdSurvey 6|
For other articles, consult the “IdCode” section of this knowledge base.
For other articles on display conditions search “display condition” in the knowledge base.
In this article you can learn more on designing display conditions with IdCode programming language.
To write the questionnaire of your survey with IdCode you can:
- click on “Import from script”, if you’ve just created your survey and it’s the first time you open “Questions” section
- click on the gearwheel button of the pages box and then on “IdCode – Display script” if you want to work on the code of the entire questionnaire
- click on the “IdCode” button you find on the top part of each page to work on the code of a single page
Display conditions influence and lead the interview path and they’re used to set when an item of the questionnaire has to be displayed to the respondent.
Display conditions can be inserted in IdCode after any item (sections, pages, group of questions, questions, answers, rows and columns) written in quotation marks and preceded by /F (for example /F “if(Q1==1)”
If correctly written, Display condition are displayed in orange in IdCode.
TIP: For a quick check on display condition coherence and consistency click on the gearwheel button of pagex box tools then on "Filter & Logic Control" and run a first check on what you wrote. Be always sure you wrote the symbols correctly, you used parenthesis to specify the order and priority of the instruction and you closed the instruction(s) with round brackets.
Comparison symbols that you can use to write your display condition are:
= = equal
< less than
> greater than
<= less than or equal to
>= greater than or equal to
Here’s some display conditions and functions you can set near to any item of your questionnaire:
Display if I answered with a specific option
if (‘question code’ ‘comparison symbol’ ‘answer code number’)
Display if I answered with specific options in different questions
if (‘question code’ ‘comparison symbol’ ‘answer code number’ ‘logical operator’ ‘second question code’ ‘comparison symbol’ ‘answer code number’…)
Display if I answered an open end question with a specific value
With this codification you check the open end answer given to a question. To do this you have to write code of the question between square brackets.
If(‘[question code between square brackets]’ ‘comparison symbol’ ‘numerical value’)
Display if at question a03 I wrote a number greater than 19
Display if a contact field contains a specific value
It’s possible to control the value of a field (e.g.: gender) in the contact database. In this case you have to put the name of the field between curly brackets.
Display is gender is male:
This function compares two dates (example: display the question just if the date of birth is greater than a specific date).
CompareDate date1,date2 (CompareDate DD/MM/YYYY,DD/MM/YYYY)
It gives back -1 if date1 is inferior (earlier) to date2, 0 if they’re equal and 1 if date1 is greater (following) than date2.
Display question just if the date of birth inserted in quest1 is greater than 01/01/1970
It checks the presence of a specific text within an open end answer.
It gives back 1 if the text searched is present, it gives back 0 if the text searched is not present.
Display a question just if in the open answer text of quest1 the word ‘sea’ is present
It allows to know the number of selected options in a multiple choice question.
It gives back the number of selected options to the question
Display the question just if for quest1 3 or more options were selected
if(CountCode quest1 >=3)
It allows to know, in a specific group, the total number of questions that were answered with a specific option.
CountResponsesWithCode questioncode1,questioncode2,. . ., questioncodeN, Answercode
It gives back the total number of questions in group questioncode1,questioncode2,. . ., questioncodeN answered with the option ResponsesWithCode
Display question just if interviewee answered with code 99 at least to 3 of the question in group quest1,quest2,quest3,quest4,quest5,quest6
if(CountResponsesWithCode quest1,quest2,quest3,quest4,quest5,quest6,99 >= 3)
It allows to know the total of questions answered with a specific text in a specific group.
CountResponsesWithText questioncode1,questioncode2,. . ., questioncodeN,’text to search’
It gives back the total of questions in group questioncode1,questioncode2,. . ., questioncodeN whose answer contains ‘text to search’
Display question just if interviewee answered with text ‘mouse’ at least to 3 of the question in the group quest1,quest2,quest3,quest4,quest5,quest6
if(CountResponsesWithText quest1,quest2,quest3,quest4,quest5,quest6,’mouse’ >= 3))
It allows to know the total of interviews completed in a specific sampling cell.
It gives back 1 if the sampling cell with name ‘quotaname’ is closed, 0 if it’s open
Display the question just if the sampling cell called ‘NorthEast’ is closed
if(CheckQuota ‘NorthEast’ ==1)
It gives a numerical value from the arithmetical expression that it has as argument.
Algebraic operators allowed are:
Module (or remainder) % (e.g. : 129%60 = 9)
Display question just if algebraic expression ([quest1]*60 + [quest2] + [quest3]*60)/60 is greater than 20.
if(ARITH(([quest1]*60 + [quest2] + [quest3]*60)/60) > 20)