The Artima Developer Community
Sponsored Link

.NET Buzz Forum
NSurvey - Matrix Questions

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
David Cumps

Posts: 319
Nickname: cumpsd
Registered: Feb, 2004

David Cumps is a Belgian Student learning .NET
NSurvey - Matrix Questions Posted: Feb 22, 2005 1:36 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by David Cumps.
Original Post: NSurvey - Matrix Questions
Feed Title: David Cumps
Feed URL: http://weblogs.asp.net/cumpsd/rss?containerid=12
Feed Description: A Student .Net Blog :p
Latest .NET Buzz Posts
Latest .NET Buzz Posts by David Cumps
Latest Posts From David Cumps

Advertisement
NSurvey supports matrix questions in its surveys. The only problem with this type of question was that in the reporting section of NSurvey, it listed each row of a matrix question as a possible selection, but it didn’t include which matrix it belonged to. This leaded to a very confusing list, when you have several identical matrix questions which only differentiated in the main question asked.

The solution I had in mind was to change the output from “row question” to “matrix question – row question”. To do this, I first had to modify some stored procedures to include the ParentQuestionText field. After this I traced down the places where the possible questions were added to the dropdown list and added some logic to check if it was a matrix question and concatenated the matrix question with the row question.

One of the places where I had to do this was in the BarChartReport class, which was responsible for generating charts of the rated matrix questions. In the SetQuestionData method the following piece of code could be found

 

engine.Title.Text = Server.HtmlDecode(

       Regex.Replace(_dataSource.Questions[0].QuestionText, "<[^>]*>", " "));


Which I changed to the following:

 

if (_dataSource.Questions[0].IsParentQuestionIdNull()) {

  engine.Title.Text = Server.HtmlDecode(

Regex.Replace(_dataSource.Questions[0].QuestionText, "<[^>]*>", " "));

} else {

  String questionText = String.Format("{0} - {1}",

 _dataSource.Questions[0]["ParentQuestionText"].ToString(),

 _dataSource.Questions[0].QuestionText);

  questionText = questionText.Replace(Environment.NewLine, "");

  questionText = questionText.Replace("\t", "");

  questionText = questionText.Replace("<p>", "");

  questionText = questionText.Replace("</p>", "");

  engine.Title.Text = Server.HtmlDecode(

                    Regex.Replace(questionText, "<[^>]*>", " "));

}


This change, together with the changed procedure because the ParentQuestionText had to be used, resulted in charts with the correct title.



The only thing left was to make sure this change also occurred in the HTML report and the questions dropdown list.

To do this I had to add the following piece of code to the GetQuestionListWithSelectableAnswers method in the DataAccess part:

 

foreach (QuestionData.QuestionsRow row in questions.Questions) {

  if (!row.IsParentQuestionIdNull()) {

    row.QuestionText = String.Format("{0} - {1}",

                                    row["ParentQuestionText"].ToString(),

                                    row.QuestionText);

  }

}


These changes made the matrix questions display correctly, as you can see in this picture, which represents a five-question matrix.

Read: NSurvey - Matrix Questions

Topic: Bill Gates' Interview Previous Topic   Next Topic Topic: Tenets of Transparency for everyone

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use