Monday, March 5, 2012

Create Poll for Sandbox or Office 365

I want to create Poll in Shared Environment that allow to create only components using Sandbox.
Sandbox has many limitation affect building this module:
  1. Cannot run component with elevated privilege or impersonate user. (Poll Component for anonymous users)
  2. Sandbox cannot serialize cookie only can read a cookie.

For these reason cannot build solution using sandbox to build a poll. Only Customize predefined controls using SharePoint Designer to build a poll.

Steps:

  1. Create 2 Lists:
    • Poll List with Fields Question(Text), Answer1(Text), Answer2(Text), Answer3(Text), Active(Yes/No)
    • Poll Result QuestionId, Answer1Count(Number Default 0), Answer2Count(Number Default 0), Answer3Count(Number Default 0)
  2. Create Workflow When you add a Poll Item in List It will add item in Poll Result.
  3. Give Add Permission of anonymous user in Poll Result.
  4. Create Active Workflow to allow only one active poll. If We activated Poll, Deactivate others.
  5. Create DataView For Displaying a Poll:
  • DataSource read the 2 lists read active poll and its results.
  • XSLT contains 2 View:
    1. Show Poll and allow user to vote. Appears if user didn't respond on this poll.
    This contains form question as title and questions as radio buttons in Forms and button for respond.
    When user click button. It will call client object model to increase selected answer count. and set cookie using JavaScript using jquery that he answer this question.
    you can use captcha using javascript:
    http://sharepointserver-2007.blogspot.com/2012/01/capatcha-using-javascript.html
    2. Show Results display Poll Result. . Appears if user respond on this poll.
    Validation that user respond this answer check if active poll Id exists in cookie that set in previous step. You can build graph for displaying results using div and style sheets.

This is simple Poll for sandbox or Office 365 you can add more enhancement.

No comments: