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.
Application Modernization Industry Quick Guides
Application modernization enables you to optimize business processes and transform the way you do business today, and in the future. Our industry experts have collected the latest application modernization trends impacting the automotive, financial services, healthcare, and manufacturing verticals.
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.
Survey List Configuration
- Turn on the Team Collaboration Lists Web-level feature:
- Create a Survey list:
- Create your questions and response options. The only two things I change are the question and choice text:
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.
- 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
- Add web part to the page (I have it in the Custom section):
- The Web part will ask you to set up its list:
- 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:
- If you were lazy and didn’t create a list in the previous section, you will get this:
- 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
- My project is not using WSP Builder, so you can deploy directly from Visual Studio.
- I added an update method that refreshes the survey after its settings have been edited in the tool part.
- 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.
- 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.
- I didn’t copy over all the resource files for different cultured from the original project, so you may wish to do that…