Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Azure

Working with Data in the Surveys Application : Displaying Data (part 3) - Displaying Questions & Displaying the Summary Statistics

6/29/2011 6:14:12 PM
- Windows 10 Product Activation Keys Free 2019 (All Versions)
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

3. Displaying Questions

The application stores the definition of a survey and its questions in table storage. To render the questions in a page in the browser, the application uses the MVC EditorExtensions class.

Tailspin chose this mechanism to render the questions because it makes it easier to include additional question types at a later date.

When the Display action method in the SurveysController class in the TailSpin.Web.Survey.Public project builds the view to display the survey, it retrieves the survey definition from storage, populates a model, and passes the model to the view. The following code example shows this action method.

[HttpGet]
public ActionResult Display(string tenant, string surveySlug)
{
var surveyAnswer = CallGetSurveyAndCreateSurveyAnswer(
this.surveyStore, tenant, surveySlug);

var model =
new TenantPageViewData<SurveyAnswer>(surveyAnswer);
model.Title = surveyAnswer.Title;
return this.View(model);
}

The view uses the EditorExtensions class to render the questions. The following code example shows how the Display.aspx page uses the Html.EditorFor element that is defined in the System.Web.Mvc.EditorExtensions class.

<% for (int i = 0;
i < this.Model.ContentModel.QuestionAnswers.Count; i++ ) { %>

...

<%: Html.EditorFor(m=>m.ContentModel.QuestionAnswers[i],
QuestionTemplateFactory.Create(
Model.ContentModel.QuestionAnswers[i].QuestionType)) %>
...
<% } %>

This element iterates over all the questions that the controller retrieved from storage and uses the QuestionTemplateFactory utility class to determine which user control (.ascx files) to use to render the question. The user controls FiveStar.ascx, MultipleChoice.ascx, and SimpleText.ascx are in the EditorTemplates folder in the project.

4. Displaying the Summary Statistics

The asynchronous task  that generates the summary statistics from surveys stores the summaries in BLOB storage, using a separate BLOB for each survey. The Surveys application displays these summary statistics in the same way that it displays questions. The following code example shows the AnalyzeSurveysController class in the TailSpin.Web project that reads the results from BLOB storage and populates a model. action method in the

public ActionResult Analyze(string tenant, string surveySlug)
{
var surveyAnswersSummary =
this.surveyAnswersSummaryStore

.GetSurveyAnswersSummary(tenant, surveySlug);

var model =
this.CreateTenantPageViewData(surveyAnswersSummary);
model.Title = surveySlug;
return this.View(model);
}

The view again uses the Html.EditorFor element to render the questions. The following code example shows a part of the Analyze.aspx file.

<% for (int i = 0;
i < this.Model.ContentModel.QuestionAnswersSummaries.Count;
i++ ) { %>
<li>
<%: Html.DisplayFor(m => m.ContentModel
.QuestionAnswersSummaries[i],
"Summary-" + TailSpin.Web.Survey.Public.Utility
.QuestionTemplateFactory.Create
(Model.ContentModel.QuestionAnswersSummaries[i]
.QuestionType))%>
</li>
<% } %>

The user control templates for rendering the summary statistics are named Summary-FiveStar.ascx, which displays an average for numeric range questions; Summary-MultipleChoice.ascx, which displays a histogram; and Summary-SimpleText.ascx, which displays a word cloud. You can find these templates in the DisplayTemplates folder in the TailSpin.Web project. To support additional question types, you must add additional user control templates to this folder.

Other -----------------
- Microsoft Azure: Enterprise Application Development - Queue Storage
- Microsoft : Azure Enterprise Application Development : Web Role
- Microsoft Azure: Enterprise Application Development - Worker Roles
- Working with Data in the Surveys Application : Saving Survey Response Data
- Working with Data in the Surveys Application : Testing and Windows Azure Storage
- Working with Data in the Surveys Application : A Data Model for a Multi-Tenant Application
- Enterprise Application Development : Azure Monitoring and Diagnostics
- Enterprise Application Development : Azure Diagnostics­ under the hood & Enabling diagnostic logging
- Building a Scalable, Multi-Tenant Application for Windows Azure : Scaling the Surveys Application
- Building a Scalable, Multi-Tenant Application for Windows Azure : Scaling Applications by Using Worker Roles
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
Celebrity Style, Fashion Trends, Beauty and Makeup Tips.
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server