Like many of the list templates provided out-of-the-box, the SharePoint Survey has some useful basic functionality but the limitations quickly become apparent. A client recently asked to use the Survey list but to give users who had completed the survey some simple feedback with additional information where questions had not been answered correctly. There is no easy way to do this with the Survey list, but with a bit of customization, the following solution was developed.

This approach takes the SharePoint Survey list and moves it one step closer to being a Quiz.

Create a new view in the Survey list using SharePoint Designer

Once you have created your survey and populated it with questions you will need to create an additional view in your Survey list using SharePoint Designer. In the case of our customization, all questions were to be answered with Yes or No, so judging if the users had responded correctly was straightforward.

The view we require is one which filters on the Author field, which needs to be set to [Me]. In this way the view will provide information only from the response to the survey of the current user. In addition, the view will need to contain the answers to all the questions in the Survey.

Create a Custom List which will contain correct answers to Survey questions

Create a custom list with a column for the Survey name and columns for each Question and the further explanation of the correct answer if the answer provided in the Survey response was incorrect. In addition, you will need in this case a numeric column for each question which will contain the code for the correct answer, 1 for Yes and 0 for No.

Once this list has been created, we will customize the display form for the list using InfoPath Designer.

You will need to add another data connection to the form, apart from the Main one from the list. This data connection will by an XML connection to the new view created in the Survey list above. In order to create the connection, you will need the GUID for both the list and the view. (Both can be found when editing the view in SharePoint Designer).

Here is an example of the XML data connection from my test server:

http://win-sqpsjc4uhjv/sites/survey/_vti_bin/owssvr.dll?Cmd=Display&List=96BCAE05-CF9B-4C24-B727-C1E2970DE95D&View=C487ECC1-706B-4342-AD65-C8562CBB07CE&XMLDATA=TRUE&noredirect=true

You will need to replace the server and site names in your path, as well as the GUIDs from your list and view.

Set this data connection up as a Secondary connection in InfoPath for the Custom list form.

You are then free to organize the form as you wish. What I chose to do was align questions and additional information to be provided when the answer was incorrect and to use a rule in InfoPath to hide the answer if correct. The one tricky part is the need to have a field within the Main data connection which picks up the answer from each question, which can in turn be compared with the value for the correct answer in the custom list. Basically, the rule hides the additional explanation from the user is the answer was correct.

Advertisements