Cloud

Quick Survey for 2010

MSDN has a neat web part you can use for polls – Quick Surveys. Unfortunately the link to read more leads to an error. Since I had to figure out what might have been at that mysterious location, I figured I’d document the findings. I made some minor updates to the code to work a little smoother with SharePoint 2010. The changes are documented below and I hope to publish the code back tom MSDN shortly. For the time being, if you would like to use the code, please let me know and I will send you the project.

Functionality

The Quick Survey web part (QSWP) displays questions and results of polling in bar graph or pie chart form. It pulls questions from a Survey list type in the current web. If your source survey has multiple questions, the QSWP will display all the questions vertically.

imageimage image

Survey List Configuration

  1. Turn on  the Team Collaboration Lists Web-level feature:image
  2. Create a Survey list:image
  3. Create your questions and response options. The only two things I change are the question and choice text:
    image
    image
    NOTE: If you create multiple questions, they will be displayed stacked vertically when you add the survey web part to your page and configure it.
  4. Make sure your would-be respondents have permissions to add items to your survey list. Sometimes you will see that your users see only the results of the survey even though they have not responded. This can happen if they don’t have permissions to the survey list.

Web Part Configuration

  1. Add web part to the page (I have it in the Custom section):image
  2. The Web part will ask you to set up its list:
    image
  3. If you created a survey list in the previous section you will be able to select a survey source list and display mode for your survey:
    image
  4. If you were lazy and didn’t create a list in the previous section, you will get this:
    image

Code

The web part essentially gathers all the survey responses, generates a graphic, and displays it in the web part. image

  • The references in red need to be added to the project if you are copying over the code to your own project
  • The web part is deployed through a feature called QuickSurvey2010.
  • SurveyResults.ashx surfaces the latest survey results.
  • Resources.resx contains standard messages displayed in the web part.
  • ChartTypeToolPart.cs and ListSelector TollPart.cs are responsible for web part editing menu.
  • Constants.cs contains the path to resources file and the chart colors.
  • GraphicsUtils.cs draw the chart
  • QuickSurvey.cs contains the we part logic.
  • SurveyResultsIterator.cs is responsible for display of survey results.
  • SurveyResultsHandler.cs is responsible for conversion of survey responses to the chart.

Project Changes from Previous Version

  1. My project is not using WSP Builder, so you can deploy directly from Visual Studio.
  2. I added an update method that refreshes the survey after its settings have been edited in the tool part.
  3. I’m assuming that the web part will be used in a publishing context, so it will ask the user to publish the page after configuring the web part.
  4. I added a constants class where you have the survey colors listed and the path to your resource files. If you want to brand the survey for your organization, I think having the colors saved there is a little easier.
  5. I didn’t copy over all the resource files for different cultured from the original project, so you may wish to do that…

Thoughts on “Quick Survey for 2010”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Darya Orlova

More from this Author

Subscribe to the Weekly Blog Digest:

Sign Up
Follow Us
TwitterLinkedinFacebookYoutubeInstagram