Screenshots [0] •
Videos [0] •
Demos [0] •
Documentation [0] •
Tutorials [0] •
Articles [0] •
Knowledge Base [0] •
Zone [0]
Surveys Introduction
Carousel includes a specialized library for generation and management of survey applications. The following description gives a general overview of how the survey definition looks like. The surveys can be built using the Survey Editor [1].
Questions
Each survey is described in a single xml file that should contained the definition of the survey's question groups. Question Group is a set of questions of some association (i.e. personal information questions, "golden questions", etc). The reason for grouping the questions is to extend the possible ways of survey processing (how to do that is described in the "Survey Rules System" section). The listing below shows the definition of a sample question group
![]() |
![]() |
|
Listing 1 - definition of a question group |
||
<Survey name="hotel survey">
...
<Group id="1" name="personal details">
<Q id="1" A="Please state your name" type="free text">
<R id="1" A="Firstname"/>
<R id="2" A="Surname"/>
</Q>
<Q id="2" A="Gender" type="mutually exclusive">
<R id="4" A="Male"/>
<R id="5" A="Female"/>
</Q>
<Q id="3" A="What is your age" type="mutually exclusive">
<R id="6" A=" less than 20"/>
<R id="7" A="20 to 35"/>
<R id="8" A="35 to 50"/>
<R id="9" A="more than 50"/>
</Q>
</Group>
...
</Survey>
|
||
![]() |
![]() |
In the XML above the <Group> element specifies the group's unique id and name. Each <Q> element defines one question belonging to the group. The id attribute is a question's unique identifier, the A attribute specifies the actual question (text of a question). The type attribute, indicating the question's type, can get one of the following values: mutually exclusive - user selects exactly one of the listed responses (these kinds of questions are usually rendered with checkboxes), mutliple choice - user selects one or more of the responses (rendered with radiobuttons), free text - user types the responses (rendered with text fields). The responses itself are defined by <R> elements nested inside the question element that they belong to. The id attribute is an unique identifier and the A attribute specifies the text of certain response.
Survey Rules System
The rules system is designed for the simple sort of rules used is surveys. Each set of rules is "attached" to a question group and describes the survey processing after answers for all questions in a certain group are given by the user. The listing below shows the sample rules definition.![]() |
![]() |
|
Listing 2 - rules defintion |
||
<Survey name="hotel survey">
...
<Group id="1" name="personal details">
...
<Rules>
<Rule name="rule one" target="3" id="1">
<Response question="12" option="38" answer="Yes"/>
<Response question="13" option="40" answer="NO"/>
</Rule>
<Rule name="rule two" target="4" id="2">
<Response question="13" option="40" answer="Yes"/>
</Rule>
</Rules>
</Group>
...
</Survey>
|
||
![]() |
![]() |
The meaning of the XML above is as follows: the <Rules> element specifies a set of rules associated with a certain question group. Each <Rule> element specifies a one rule. The target attribute defines an identifier of a question group to which the survey should proceed when answers given by the user match the conditions contained in a rule. Each <Response> element specifies a one condition. The question attribute is an identifier of a question, the option attribute is an identifier of one of question's available option, the answer attribute defines the actual answer that should be given to the question.
Carousel includes a simple rules engine that supports the types of rules described above, however if a more complete rules engine is required one can be plugged in. In order to do that the RulesEngine interface implementation must be provided and then pointed to by the XRulesEngine startup parameter of the project. The RulesEngine interface consists of two methods shown in the listing below.
![]() |
![]() |
|
Listing 3 - RulesEngine interface |
||
public void handleGroup( QuestionGroup group,
Vector responses, XmlElement rules );
public void handleAnswer( QuestionGroup group,
Condition response, XmlElement rules );
|
||
![]() |
![]() |
The handleGroup(...) method is invoked every time the user finishes answering to questions of a ceratin question group. It takes three parameters: the group is an object describing the group, the responses is a vector containing the answers given by the user, the rules parameter defines the rules associated with the group - this is simply a xml element nested inside the group definition and the name of which is "Rules", the actual content of the element can be specific to the rules engine that is used. The second method, handleAnswers(...) is invoked every time the user gives an answer for a single question (i.e. by clicking a radio button), the meaning of the group and rules parameters is the same as in the handleGroup method. The response parameter specifies the last answer given by the user (the one that caused the method invocation). The implementation of these two methods can use the convienient Survey API which consists of methods tasked with survey managment (i.e. adding/deleting questions to/from groups, saving user responses, etc. ) and thus gives the ability to apply different kinds of rules, to rotate questions, etc.



