Libraries are stored sections of source code for surveys. They save time by eliminating the need to rewrite code.
[[INCLUDE library_name_here]]
Note: Surveys must be recompiled to reflect library changes.
Details
- Libraries are stored in the Libraries applet and can be referenced in multiple surveys on the same server.
- Libraries can be placed anywhere in the survey code.
- Everything in an included library becomes a part of the survey code by default.
- You can limit the widgets and classes in order to only pull in a portion of the library.
- There is no limit to the number of libraries you can include.
Creating and using library code
The example below shows the helpful_classes library which defines a series of classes.
# Library named helpful_classes setclass: dollar4 size: 4 prefix: $ datatype: whole setclass: dollar5 size: 5 prefix: $ datatype: whole setclass: dollar6 size: 6 prefix: $ datatype: whole
To utilize the helpful_classes library in a survey, use the include
directive in double square brackets as shown below. Then, apply the class
tag to use one of the defined classes in a question.
[[INCLUDE helpful_classes]] ... 1. How much money did you spend at the mall during your last visit? class: dollar5
Limiting the widgets returned from a library
To use only a portion of the library, specify an array or list of widget IDs to include. For example:
[[include helpful_classes: dollar4, dollar5]]
Comments
0 comments
Please sign in to leave a comment.