Many of the questions that are part of my questionnaire have conditional responses based on prior questions. As a made up example if the interviewee states that they don't own any pets I can skip all the cute questions about pet ownership. Another item is that I want folks to enter two pieces of data on some screens ~ to provide a start and end date for a project. Another likely scenario is that I may want to vary my list of items they have to choose from based upon a prior response.
One idea I had was to build out a multselectquestion where a text box is displayed along side each item i) start date ______ ii) end date ______. Maybe there is cleaner way to accomplish this?
Curious to also know if anyone has incorporating their own date validation routines.
Looking forward to getting some feedback as once I get over these hurdles I think I will be on my way with using this toolkit.
Regards,
NT
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Since your questions cover several topics, I'm going to break my reply into separate posts.
Conditionally asking questions are easy, you just need onLoad() to return false for the questions you don't want to ask. In Sonar's XML, or example, if "pets" is the id of a yes/no question about having pets, then you can have a question like:
<NumberInputQuestion id="number_of_pets" min="1" max="100">
<text>How many pets do you have?</text>
<onLoad lang="java">
if (pets.selected.text.equals("yes")) {
return true;
} else {
return false;
}
</onLoad>
</NumberInputQuestion>
If you have more than one question involving pets, you can put them all inside of a <ComponentContainer> with the same <onLoad> logic, and the entire container will be skipped.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In order to have multiple inputs like start and end date, you have two choices. The easiest is to use two different <FormattedInputQuestion>s inside of a <ComponentContainer>, like this:
<SimpleContainer id="startandend">
<text>Please enter the start and end date of your project</text>
This will ask for the start date first, then after that is entered it will ask them for the end date. The text of the <SimpleContainer> will appear above both questions. In the (hopefully) near future, I'm going to include a new question type that will let you bundle multiple questions on a single screen, like Quancept's Multiask question type. Until then, if you have a good knowledge of Java, you can create your own question types and screens, and Sonar can use those.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The <FormattedInputQuestion>s I used above have a pattern that will enforce a MM/DD/YYYY format on the input, you can then use Java's DateFormat.parse() function to validate the date. Here is an example using the start question from aove:
<FormattedInputQuestion id="start" pattern="[1..12]/[1..31]/\d{4}">
<text>Start Date:</text>
<onContinue>
try {
DateFormat.getInstance.parse(start.value);
} catch (ParseException e) {
window.alert("The date you entered is not valid.");
return false;
}
</onContinue>
</FormattedInputQuestion>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No problem, I hope I was able to get you started using Sonar. If you can, I would like to know what you are using it for, and how it is working for you. As always, any feedback that can improve the product is welcome, as is any assistance in terms of programming or testing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Many of the questions that are part of my questionnaire have conditional responses based on prior questions. As a made up example if the interviewee states that they don't own any pets I can skip all the cute questions about pet ownership. Another item is that I want folks to enter two pieces of data on some screens ~ to provide a start and end date for a project. Another likely scenario is that I may want to vary my list of items they have to choose from based upon a prior response.
One idea I had was to build out a multselectquestion where a text box is displayed along side each item i) start date ______ ii) end date ______. Maybe there is cleaner way to accomplish this?
Curious to also know if anyone has incorporating their own date validation routines.
Looking forward to getting some feedback as once I get over these hurdles I think I will be on my way with using this toolkit.
Regards,
NT
Since your questions cover several topics, I'm going to break my reply into separate posts.
Conditionally asking questions are easy, you just need onLoad() to return false for the questions you don't want to ask. In Sonar's XML, or example, if "pets" is the id of a yes/no question about having pets, then you can have a question like:
<NumberInputQuestion id="number_of_pets" min="1" max="100">
<text>How many pets do you have?</text>
<onLoad lang="java">
if (pets.selected.text.equals("yes")) {
return true;
} else {
return false;
}
</onLoad>
</NumberInputQuestion>
If you have more than one question involving pets, you can put them all inside of a <ComponentContainer> with the same <onLoad> logic, and the entire container will be skipped.
In order to have multiple inputs like start and end date, you have two choices. The easiest is to use two different <FormattedInputQuestion>s inside of a <ComponentContainer>, like this:
<SimpleContainer id="startandend">
<text>Please enter the start and end date of your project</text>
<FormattedInputQuestion id="start" pattern="[1..12]/[1..31]/\d{4}">
<text>Start Date:</text>
</FormattedInputQuestion>
<FormattedInputQuestion id="end" pattern="[1..12]/[1..31]/\d{4}">
<text>End Date:</text>
</FormattedInputQuestion>
</SimpleContainer>
This will ask for the start date first, then after that is entered it will ask them for the end date. The text of the <SimpleContainer> will appear above both questions. In the (hopefully) near future, I'm going to include a new question type that will let you bundle multiple questions on a single screen, like Quancept's Multiask question type. Until then, if you have a good knowledge of Java, you can create your own question types and screens, and Sonar can use those.
The <FormattedInputQuestion>s I used above have a pattern that will enforce a MM/DD/YYYY format on the input, you can then use Java's DateFormat.parse() function to validate the date. Here is an example using the start question from aove:
<FormattedInputQuestion id="start" pattern="[1..12]/[1..31]/\d{4}">
<text>Start Date:</text>
<onContinue>
try {
DateFormat.getInstance.parse(start.value);
} catch (ParseException e) {
window.alert("The date you entered is not valid.");
return false;
}
</onContinue>
</FormattedInputQuestion>
Hello Michael,
Thanks for providing such detailed responses to my posting.
Regards,
NT
No problem, I hope I was able to get you started using Sonar. If you can, I would like to know what you are using it for, and how it is working for you. As always, any feedback that can improve the product is welcome, as is any assistance in terms of programming or testing.