How To Build A Survey: Using the surveypage tag
Overview And Example
All Parameters
Overview And Example
The surveypage tag will load the survey and the questions that you made in the Survey Editor:
|
File: page1.jsp (included in the default survey template) |
|
<survey:surveypage
pageName="Page 1"
nextPage="page2.jsp"
submitButtonText="Next"
pageWidth="600"
rememberPageUserIsOn="true"
pageToLoginTo="index.jsp"
tableToVerifyLoginTo="Users"
userIDField="ID"
isLoginPage="false"
/> |
This is called a "JSP tag" -- it loads a little program which creates HTML and puts it into the page. The tag's name is "survey:surveypage", shown at the beginning. This loads one page of the survey. The text in the middle is parameters. Let's go through the important ones.
surveypage parameter: pageName
Parameter in page1.jsp
|
pageName="Page 1"
|
Place to edit in Survey Editor
|
|
The "pageName" parameter tells you which page in the Survey Editor to use when the repondent visits this web page. So, when you want a particular JSP page to load a page that you made in the survey editor, name it in the Survey Editor as shown above, and then change the "surveypage"'s "pageName" to that name.
surveypage parameter: nextPage
|
Parameter in page1.jsp
|
|
nextPage="page2.jsp"
|
The "nextPage" parameter tells you which page to go to after this page. The name is the name of the JSP file. So, for example, here after the respondent fills out page1.jsp (which is "Page 1" in the Survey Editor), the respondent will next go to "page2.jsp" (which is "Page 2" in the Survey Editor, if you look inside "page2.jsp").
By using "pageName" and "nextPage", you can create a series of JSP files which will take the respondent through the survey. The rest of the parameters are much less important -- if you only know two parameters, know those two.
surveypage parameters
|
Survey Flow |
|
Parameter in surveypage
|
What It Does |
|
pageName="Page 1"
|
The page to load from the Survey Editor. [more]
|
|
nextPage="page2.jsp"
|
The next page to go to after this one. [more]
|
|
Visual Options |
|
Parameter in surveypage
|
What It Does |
|
submitButtonText="Next"
|
The name of the submit button on the web page. [see in page]
|
|
pageWidth="600"
|
This is the width of the web page in pixels. So, for example, since some user's screens are 640, the default is 600, to leave some extra space for the scroll bar, window, etc. If your respondents are from a known population and you think they will have at least 800x600 sized screens, you may wish to make this "750" or so, etc. [see in page]
|
|
showSubmitButton=
"true"
|
Whether or not to show a button on the bottom of the page, in this case, the "Next" button. Default is true. Change to "false" to make the button invisible. [see in page] |
|
headerBackgroundColor=
"6699ff" |
header background color (blue by default) |
Change the default color for the page, so all questions that don't have a specific color picked for them will use that color. The color is in HTML hex code. See a html color chart for examples. |
|
backgroundColor1="dcdcdc"
|
the first alternating background color (dark gray by default) |
|
backgroundColor2="eeeeee" |
the second alternating background color (light gray by default) |
|
Login Options |
|
Parameter in surveypage
|
What It Does |
|
pageToLoginTo=
"index.jsp"
|
The login page -- this is usually index.jsp. Whenever a user has not logged in yet, it redirects to the login page. (i.e. the user is not logged in if they don't have a unique ID in the database to know where to save the data -- the user may not actually have manually log in to get this, it can be automatically generated).
|
|
tableToVerifyLoginTo=
"Users"
|
The database table that respondents information will be loaded and saved from. "Users" is the default, and we recommend that you leave it that way.
|
|
userIDField="ID"
|
This is the field in the "Users" table (as set above) and in the "Answers" table that is a unique identifier for each respondent.
|
|
isLoginPage="false" |
Whether this page is a login page -- e.g. index.jsp has this as "true" and everything else has this as "false".
|
|
Other Options |
|
Parameter in surveypage
|
What It Does |
|
timeResponses="false"
or "true" |
Whether or not to keep track of how long it takes the user to fill out the page. Note that this is very innacurate, due to the amount of time it takes to load an HTML page. You probably shouldn't use this, because you're unlikely to get good data out of it, but you can try. Default is "false".
|
|
rememberPageUserIsOn=
"true"
or "false"
|
Whether or not to remember the page that the user was last on. This goes in the "Users" table (as set by tableToVerifyLoginTo) in the variable named "CurrentPage", and you can use it to see whether or not people have gotten far into the survey. If it is true and a user logs in to the survey a second time, they will jump to the last page that they haven't completed. Change this to "false" to make them start at the first page every time they log in.
|
|
databaseName=
"<%=databaseName%>"
|
This is now optional, and is an obsolete parameter. If you have it, do not modify it. It is set automatically for you, and is required to be there. Basically, it points to the database that the data is saved in, which is automatically loaded from WEB-INF/classes/Configuration.properties
|
There are more parameters that are undocumented that you may want to use. The full documentation is available as JavaDocs for SurveyPage and the JavaDocs for Survey (Survey is the superclass of SurveyPage, which means that everything Survey can do, SurveyPage can do).
More about Building a Survey
|
|