Warnings and Caveats

Now that all the issues are on the table, on with the show....

Basic JSP Randomization example:

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.

  1. Create 3 pages in the Survey Manager and make 3 long answer questions on each page. Name the pages Page 1, Page 2, and Page 3.
  2. Make the JSP pages for each of the three pages you created in the Survey Manager.
<%@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

@Include file="include_questionaire.jsp"

In this case it tells Web Survey Toolbox that this is the beginning of a questionnaire jsp file.

redirectRandomOrderTo

The type of randomization you are using

"Users"

The table you are going to save the pages the participant has visited

"RandomPageOrder"

The column in the table you are going to save the pages the participant has visited.

New String[]

In this case, it tells Web Survey Toolbox to randomize the pages listed next.

page1.jsp, page2.jsp, page3.jsp

The pages you are randomizing

Next page

The page that participants will be pointed to after they have visited all of the pages.

doneWithSurvey.jsp

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.

@include file ="survey_end.jsp

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.

More complex example: Randomizing multiple measures with multiple pages

(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: -

  1. Repeat step 1 in the first example in the Web Survey Toolkit GUI until you have 3 measures, consisting of 3 pages each - pages 1-9. Name each page, Page 1, Page 2, Page 3, etc. in the Survey Manager.
  2. Additionally, create a header in the Web Survey Toolkit GUI for each survey page noting their group and page number so we can test our results. For example, Measure A, Page 1; Measure A, Page 2 etc. and number each question 1-30 inside the question text.
  3. Repeat step 2 in the first example until all 9 jsp pages are created. However, in pages 4-6 change nextPage to random1.jsp, and in pages 7-9 to random2.jsp.
<%@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"%>