Survey Creator
Scenario
A school department wants to create a standard digital template to use when administering tests to students. Since the template is to be a standard format across multiple classes, the department requires that teachers be able to enter questions appropriate to their individual classes. To simplify things, the department decides to allow three types of questions: True/False, Multiple Choice, and Free-Form Essay (write-in). So, in short, teachers create questionnaires for the students, determining what type of answer to collect for each. The form is then given to the students taking the test, who step through the questions one-by-one. After the test, the teachers compile the answers, creating a master form for grading. The two main views of the form will look similar to the following:
Wizard-Style Form: One Question at a Time
The heart of the wizard-like functionality of the solution to this scenario is the use of an index counter by which a view is then filtered when the form is being edited. The "Next" and "Back" buttons we see in so many cases appear on this InfoPath solution but they simply change the value of the counter, adding one to the index if "Next" is clicked, subtracting one if "Back" is clicked. In this case, the index counter is placed on the repeating section that is the container for test questions in this form.
Data Source
We will use a repeating group of questions; each question will have a questionText (what's being asked) and one of the following subnodes (implemented as a choice group):
1) trueFalse: keeps track of the student's answer to this question, if this question is a true/false question. Boolean.
2) writeIn: keeps track of the student's essay answer to a write-in question. Text or Rich-Text (XHTML).
3) multipleChoice: we need to remember two things here:
- possible choices (provided by the teacher; repeating group of text fields)
- student answer
Since we want to show students only one question at a time, we will need an auxiliary index field to remember the current question that's being shown. The index counter used by the filter is a field that does not take any direct user input. Give the field a value of 1, which will then be incremented using the buttons.
All-in-all, the data source looks similar to the following:
Views
This forms solution is structured around a repeating section field that appears in both views. To create the duplicate repeating sections, create two views and place a repeating section in the first view. Next, open the second view, open the data source task pane, and drag the repeating section field onto the canvas.
To show the students one question at a time, we need to apply a filter: open the student view and then open the Properties of the repeating section in that view. Click the display tab and then click the "Filter Data…" button. Since we will set the counter to be the question number, and since we want to display only the current question, set the filter to display data for which index = position() .
Navigation among the questions is enabled by "Next" and "Back" buttons included in the student view. Insert two buttons into the student view. Double-click the first button: Select "Rules and Custom Code" in the action menu, give the button the label "<< Back" and click the "Rules…" button. Add an action as appears below:
For the "Next >>" button, follow a similar procedure as for the back button but add 1 to the value of index in the above dialogue.
Now we need to take care of the actual question display: each question requires a serial number, the text of the question, and the field for response (which could be one of several pre-defined types.) The teacher's view contains user-editable fields for question text and a choice of answer type; the Student view displays the text of the question and contains the editable response field.
In detail:
Question Text: collected through a Text Box in the Teacher view and then displayed using an Expression Box in the Student view.
Response data is contained in a choice group. The Teacher selects the most appropriate of the three response types permitted by the form and, in the case of multiple choice, adds the necessary choices to a numbered list. No "answer" data field appears in the Teacher view of any of the answer types because all the teacher need do is choose the type of answer. The default Choice Group appears with two Choice Sections but can contain as many as necessary, simply insert the Choice Group and then add more Choice Sections. For this scenario, add the Choice Group and Sections to the Teacher view and then label the Choice Sections with the appropriate answer type. For the multiple-choice Choice Section, add a Numbered List control to the section to contain the options for any multiple-choice section.
The controls to hold student responses to questions are contained in a Choice Group placed into the Student view by dragging the existing Choice Group into that view from the Data Source Task Pane. This action creates a mirror of the Choice Group structure contained in the Teacher view but without the controls or text placed into the Teacher view. Into the Choice Sections in the Student view place, respectively, a set of 3 Option Buttons for True/False/I Don't Know, a Rich Text field for written response, and a List Box for multiple choice. This last has the slight complication that we want to pull in the options the teacher set for the particular question. To do this go to the "Data" tab of List Box Properties and select the second option under "Data": "Look up values in the form's data source." Select the field that holds the values from the Numbered List and these will populate the List Box for each multiple choice question.
To display the question number, add an expression box that displays the value of the index. Type "Auto" into the width property of the expression box and the control will size itself to the value. To display the total number of questions, use an expression box in which you use the following formula where the fields used are the Choice Sections within the Choice Group used to contain responses:
The basic mechanics of this test form are now complete. What remains to be set up are things like submission and review options and settings. Some examples of possible additions to this scenario are as follow:
- View permissions so the students can only see the view intended for them.
- User roles limiting what members of the student body are permitted to take the test.
- A review and submission function that shows the "Review and Hand-In Test" button only after all questions have been viewed. This button would then take students to a summary view of all of their question-answer pairs along with links to return to a particular question should they want to change their answers and a button to finally submit the test. (This option is a logical product of the calculation and display of the total number of questions and of the current question - making it simple to determine when the user has reached the end of the slate of questions.)
- Settings for the teacher to merge all answers into a single master form for grading, especially if marks depend on comparison among all the answers. The summary field, once marked, could produce individual reports for students that could be e-mailed out automatically (they would be required to authenticate themselves with their school e-mails to be able to take the test in the first place.
- Submit settings to send all the tests to a MOSS document Library.
The sample form template that has this technique is attached; make sure to download the XSN to your computer before opening it. Note that this technique works in InfoPath 2003 and 2007, but will not work in browser-enabled form templates.
Jonathan
Program Manager
Thanks to our brilliant ex-colleague Ned Friend for building the sample form template.
Comments
Anonymous
January 24, 2007
PingBack from http://www.do-ict.nl/2007/01/25/infopath-tutorial-survey-creator/Anonymous
April 24, 2007
Hi, I was looking over your survey as an alternative to using a SharePoint survey. Just curious how the teacher questions would be stored as part of the form?Anonymous
May 09, 2011
What I am trying to find out is how to access an existing survey from within a Sharepoint system, edit that survey format in Infopath, and return that edited format template back into the Sharepoint system. bblades@mitre.orgAnonymous
April 22, 2012
The comment has been removedAnonymous
July 18, 2012
is there any possible way you can get this (blogs.msdn.com/.../1320134.ashx) link to work? all the information i need is in this articleAnonymous
April 09, 2013
I've just signed up for a brilliant tool called http://www.surveymoz.com I find it much easier than using infopath.Anonymous
July 08, 2013
I was able to download the template and actually recreated it with the two different views, but I am unable to get the questions to be part of the document. Can you please provide guidance on how that piece works.Anonymous
August 20, 2013
A good alternative to this would be SoGoSurvey. Check it out at http://www.sogosurvey.com/.Anonymous
October 16, 2013
Check this out. www.lab5connect.com/SurveyAnonymous
November 11, 2013
I was able to download the template and actually recreated it with the two different views, but I am unable to get the questions to be part of the document. Can you please provide guidance on how that piece works.Anonymous
April 07, 2014
Sounds good but there is not enough info here to recreate it. Can we get complete step-by-step instructions?Anonymous
April 28, 2014
Check this out. http://www.inqwise.com - professional online survey software.Anonymous
February 23, 2015
A good alternative to this would be Mobosurvey. Check it out at http://www.mobosurvey.com/. User friendly, professional features and cheap.Anonymous
April 02, 2015
Information was good, I like your post. Looking forward for more on this topic. <a href="staygreenacademy.com/.../">SharePoint Development Training Online</a>