IdCode: an introduction

Compatibility:IdSurvey 5IdSurvey 6

IdCode is the questionnaire in script format. It has a simple but powerful syntax that you can use to quickly create pages, questions, answers, etc…
IdCode works in parallel with the graphical user interface so you can go to IdCode from any page in a second.

For other articles, consult the “IdCode” section of this knowledge base.

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

With IdCode you can copy and paste parts of the questionnaire to create similar questions or pages with one click.

When working with the code you’ll see that the programming is facilitated. Each object of the questionnaire has a specific color and codification. If the object is not correctly formatted, it won’t be displayed in its corresponding color. If one object is displayed in light grey with red dots than it means that the code of the object is not accepted by IdSurvey (for example, if the code of the page contains spaces or if you use the same code for two questions in the questionnaire).

Let’s quickly see now colors and codifications of each object of the questionnaire!

IdCode_introduction

SECTION

Section codifications are displayed in green. The section has to be opened before the first page included and closed after last page included.
To open a section you use codification: /section codeofthesection (e.g. SEC1)
To close a section you use codification: /endsection

PAGE

Page codification is displayed in light blue. Unlike sections, pages only need to be opened. If there’s a section, leave an empty line between the section and page code.
To open the page you use codification: /page codeofthepage (e.g. P1)

TIP: As a convention, while choosing the page codes we follow this rule: use “P” to distinguish pages + code of the first question contained in the page. For example, I know that in page P1 the first question would be the one with code “1”. This is the naming convention that you will find in this knowledgebase, but you can use any convention you like.

GROUP OF QUESTIONS

Groups are displayed in brick red. Group of questions has to be opened before the first question included and closed after the last question included. Leave one empty line between page and group code and between group and question code. 
To open a group you use codification: /group codeofthegroup (e.g. G1)
To close a group you use codification: /endgroup

QUESTIONS

Questions are displayed in violet. Questions only have to be opened. Leave one empty line between the page and the question code and between question and answer codes.
To create a question leave an empty line after the page code then directly write question code (e.g. Q1). Then start a new paragraph to write the text of the question.
To create answer options leave an empty line between question text and first option. Answer options codes are displayed in blue.

TYPES OF QUESTIONS You can specify in the code the type of question you want to create. You have to write desired codification near question code after a dash sign and greater than sign (->).

single (default) e.g. Q3 ->s (or no codification)
multiple e.g. Q3 ->M
mono (exclusive) e.g. Q3 ->m
text (open end) e.g. Q3 ->T
long text (multiline) e.g. Q3 ->TM 

ANSWERS

Answer options of simple questions are displayed in blue. Simply write them in line below the question text leaving one empty space between question text and first answer option.
You have to write code of the option and text of the answer all in the same line.
You can specify different types of options also for a single answer using the same codification of questions.

single (default) e.g. Q3 ->s (or no codification)
multiple e.g. Q3 ->M
mono (exclusive) e.g. Q3 ->m
text (open end) e.g. Q3 ->T
long text (multiline) e.g. Q3 ->TM

GRID/MATRIX

To create a grid question leave an empty line after the page code then directly write question code (e.g. Q1). Then start a new paragraph to write the text of the question.
Differently than simple questions, grids have rows and columns. Rows are displayed in violet, columns are displayed in blue.

To create rows leave an empty line after question text then write rows codification: /rows
Go to a new paragraph and write in line all rows text as follow: .codeoftherow text of the row (we suggest to use .1,.2,.3,.4 etc. for rows codes)

To create columns go to a new paragraph right below last colum text and  write columns codification: /cols
Go to a new paragraph and write in line all colums text as follow: codeofthecolumns text of the row

As for simple questions, you can specify the type of grid you want to create. You have to write desired codification near question code after a dash sign and greater than sign (->).

single (default) e.g. Q3 ->s (or no codification)
multiple e.g. Q3 ->M
mono (exclusive) e.g. Q3 ->m
text (open end) e.g. Q3 ->T
long text (multiline) e.g. Q3 ->TM

To manage exceptions on single cells (one or more cell with different settings like type or logic condition) you have to use the instruction /cells and specify which cell (concatenation row code and column code) has to have different characteristics.

ADVANCED GRID/MATRIX

To create an advanced grid question leave an empty line after the page code then directly write question code (e.g. Q1). Then start a new paragraph to write the text of the question.

Differently than simple grid, advanced have rows, columns and cell templates. Rows are displayed in violet, columns are displayed in violet also, cell templates are displayed in blue.

If you specify just one cell template, it will be applied by default to all columns. If you insert more than one cell template you should write the codification near the column text you want the template to be applied (see pic below). All columns with no specification will have celltemplate 1 applied by default.

To create cell template leave an empty line after question text then write codification: /celltemplate code (e.g. /celltemplate 1)
Then go to a new paragraph and write the settings you want applied to an entire column.

To create rows go to a new paragraph then write rows codification: /rows
Go to a new paragraph and write in line all rows text as follow: .codeoftherow text of the row (we suggest to use .1,.2,.3,.4 etc. for rows codes)

To create columns go to a new paragraph right below last colum text and  write columns codification: /cols
Go to a new paragraph and write in line all colums text as follow: codeofthecolumns text of the row

To manage exceptions on single cells (one or more cell with different settings like type or logic condition) you have to use the instruction /cells and specify which cell (concatenation row code and column code) has to have different characteristics.

single (default) e.g. Q3 ->s (or no codification)
multiple e.g. Q3 ->M
mono (exclusive) e.g. Q3 ->m
text (open end) e.g. Q3 ->T
long text (multiline) e.g. Q3 ->TM

Leave A Comment?