Now that all the issues are on the table, on with the show....
In this example we will randomize the order of 3 pages (page1.jsp, page2.jsp, and page3.jsp). There are 4 options for what type of random you can use. For this example we will use redirectRandomOrderTo, of just plain random.
<%@include file="include_questionnaire.jsp"%> <survey:surveypage pageName="Page 1" pageWidth="600" nextPage="random.jsp" submitButtonText="Next" showSubmitButton="true" timeResponses="false" rememberPageUserIsOn="true" pageToLoginTo="index.jsp" tableToVerifyLoginTo="Users" isLoginPage="false" /> <%@include file="survey_end.jsp"%> |
<%@include file="include_questionnaire.jsp"%> <survey:surveypage pageName="Page 2" pageWidth="600" nextPage="random.jsp" submitButtonText="Next" showSubmitButton="true" timeResponses="false" rememberPageUserIsOn="true" pageToLoginTo="index.jsp" tableToVerifyLoginTo="Users" isLoginPage="false" /> <%@include file="survey_end.jsp"%> |
<%@include file="include_questionnaire.jsp"%> <survey:surveypage pageName="Page 3" pageWidth="600" nextPage="random.jsp" submitButtonText="Next" showSubmitButton="true" timeResponses="false" rememberPageUserIsOn="true" pageToLoginTo="index.jsp" tableToVerifyLoginTo="Users" isLoginPage="false" /> <%@include file="survey_end.jsp"%> |
3. Create a new document in you favorite text editor (e.g. Word Pad, SimpleText, etc.) with the following (you can simply copy and paste this) :
<%@include file="include_questionnaire.jsp"%> <% if (redirectRandomOrderTo("Users", "RandomPageOrder", new String[]{"page1.jsp", "page2.jsp", "page3.jsp", " })) { } else { redirectTo("doneWithSurvey.jsp"); } %> <%@include file="survey_end.jsp"%> |
General random.jsp Code Explanation:
In general, this is an if statement that says, in the randomPageOrder column of the Users table, keep track of the order of pages the participant has visited. When the participant has randomly visited all of these listed pages, send them to the doneWithSurvey.jsp page.
Each part explained:
Code |
Explination |
---|---|
|
In this case it tells Web Survey Toolbox that this is the beginning of a questionnaire jsp file. |
|
The type of randomization you are using |
|
The table you are going to save the pages the participant has visited |
|
The column in the table you are going to save the pages the participant has visited. |
|
In this case, it tells Web Survey Toolbox to randomize the pages listed next. |
|
The pages you are randomizing |
|
The page that participants will be pointed to after they have visited all of the pages. |
|
The last page a participant will see. It conveniently has a link that starts the survey over for the next person. It could be ANY jsp page in your survey however. |
|
Tells Web Survey Toolbox that this is the end of a survey jsp file. |
4. Save the random page as random.jsp and upload it.
5 Testing. Open up your survey on the web, and log in. Run through each of the pages until the survey ends. You may need to do this more then once to see the randomization effect. This is especially true of the other types of randomization such as redirectToRandomOrderAndBalanced.
(I call this "nested randomization")
For this example, we will randomize 3 measures named A, B, and C as above. This time, each measure has 9 very wordy long answer questions spread across 3 pages each so they can fit on a small screen without the need to scroll. Please note for the sake of sanity, this example is intentionally short. You can add as many pages, measures and questions as needed for you own application.
At the top layer, we want to randomize the order of each of the 3 measures A, B, and C. For example, ABC, CBA, BCA, etc. Underneith, measure A consists of pages 1-3, B pages 4-6, and C pages 7-9
Additionally, we will randomize the pages underneith measures A, B and C - pages 123, 456, 789 respectively. (e.g. 123, 231, 213 & 654, 456, 564, etc.). A matrix would look like this:
Measures |
A |
B |
C |
---|---|---|---|
Pages |
123 |
456 |
789 |
Questions |
123456789 |
123456789 |
123456789 |
The setup: -
<%@include file="include_questionnaire.jsp"%> <survey:surveypage pageName="Page 4" pageWidth="600" nextPage="random1.jsp" submitButtonText="Next" showSubmitButton="true" timeResponses="false" rememberPageUserIsOn="true" pageToLoginTo="index.jsp" tableToVerifyLoginTo="Users" isLoginPage="false" /> <%@include file="survey_end.jsp"%> |
<%@include file="include_questionnaire.jsp"%> <survey:surveypage pageName="Page 9" pageWidth="600" nextPage="random2.jsp" submitButtonText="Next" showSubmitButton="true" timeResponses="false" rememberPageUserIsOn="true" pageToLoginTo="index.jsp" tableToVerifyLoginTo="Users" isLoginPage="false" /> <%@include file="survey_end.jsp"%> |
4. Next, we will need a total of 4 random jsp pages. Three will be used for the measure pages (random.jsp, random1.jsp, and random2.jsp for pages 1,2,3 & 4,5,6 & 7,8,9 respectively) and the 4th - randomMeasure.jsp for the measures A, B, and C.
For random1.jsp, random2.jsp and randomMeasure.jsp we will need to make an extra column in the User Table. In the Survey Manager, Choose - Data - Users. Click in the data portion of the randomPageOrder column (not the header) then click the "Add Column" button and name the first added column randomPageOrder1 and make sure it is a String. Repeat creating randomPageOrder2, and randomMeasure.
5. To create the random pages follow step 3 in the first example. After the first is created (random.jsp), save it as random1.jsp, random2.jsp, and again as randomMeasure.jsp. The code in your random pages should look like this:
<%@include file="include_questionnaire.jsp"%> <% /** random.jsp will randomize pages 1-3 **/ if (redirectRandomOrderTo("Users", "RandomPageOrder", new String[]{"page1.jsp", "page2.jsp", "page3.jsp"})) { } else { redirectTo("randomMeasure.jsp"); } %> <%@include file="survey_end.jsp"%> |
<%@include file="include_questionnaire.jsp"%> <% /** random1.jsp will randomize pages 4-6 **/ if (redirectRandomOrderTo("Users", "RandomPageOrder1", new String[]{"page4.jsp", "page5.jsp", "page6.jsp"})) { } else { redirectTo("randomMeasure.jsp"); } %> <%@include file="survey_end.jsp"%> |
<%@include file="include_questionnaire.jsp"%> <% /** random2.jsp will randomize pages 7-9 **/ if (redirectRandomOrderTo("Users", "RandomPageOrder2", new String[]{"page7.jsp", "page8.jsp", "page9.jsp"})) { } else { redirectTo("randomMeasure.jsp"); } %> <%@include file="survey_end.jsp"%> |
<%@include file="include_questionnaire.jsp"%> <% /** randomMeasure.jsp will randomize measures A, B, and C **/ if (redirectRandomOrderTo("Users", "randomMeasure", new String[]{"random.jsp", "random1.jsp", "random2.jsp"})) { } else { redirectTo("doneWithSurvey.jsp"); } %> <%@include file="survey_end.jsp"%> |
6. Next download and change the nextPage parameter on your index.jsp file so it points to randomMeasure.jsp. It should look like this:
//index.jsp code example <%@include file="include_questionnaire.jsp"%> <% /** To use this type of survey, rename this file from "index2.jsp" to "index.jsp". (The default "index.jsp" automatically moves pages around). Then, you'll be able to control each page, its details, and where it goes next all in the JSP code in here and on "page1.jsp", etc. **/ %> <survey:surveypage pageName="Login" nextPage="randomMeasure.jsp" submitButtonText="Start Survey" showSubmitButton="true" percentQuestion="60" rememberPageUserIsOn="true" retrieveValuesFromDB="false" createUsersAtLogin="true" isLoginPage="true" /> %@include file="survey_end.jsp"% |
7. Now upload all jsp files and test. (Don't forget to click save on the Survey Manager when you are done creating measures!)
If there are no errors, (usually type-o's) You are done! If there are errors, look at the error messages, fix, then upload and test again.
There is yet another level of randomization offered by this program. You can randomize the question order inside each of the pages.
Furthermore, you can add as many layers of jsp randomization as you wish. In addition to mixing random and non-random pages and measures. For example our second example:
Measure |
A |
B |
C |
---|---|---|---|
Pages |
123 |
345 |
789 |
Could easily look like:
Section |
1 |
|
|
2 |
|
---|---|---|---|---|---|
Measure |
A |
B |
C |
D |
E |
Pages |
123 |
45678 |
9,10,11,12 |
13,14,15 |
16,17 |
Questions: as many as you need.......
In this case you would add additional random.jsp pages for measures D, and E, and another for section 1 and 2 or you can do so for just E and leave D not randomized. You would mix random with non-random measures by setting the nextPage Variable in your pagex.jsp pages from a random page to a measure page.
The sky is the limit!