locked
Architecture for Questionary kind of application RRS feed

  • Question

  •  

    Hi

     

    I will be starting working on an application which has so many questions and user needs to input the answers. Here the questions are not static. We show or hide a set of questions based on the answers provided by User.

    For example for the question like Marital Status if User says Married a set of questions need to be populated and if says not married another set of questions need to be populated.

     

    There are multiple topics as Menu items and user can select any topic.

    There are about 10-20 questions on each topic ( Here one topic will be dispalyed at a time as a Page to user).

    There may be additional topics we need to show on the menu based on user answers in the page.

    For example if User Selects his country as US we need to show US related topics in the menu and is it is some other country that particular countries topics should be there in the menu.

     

    Can somebody help me in suggesting Application Architecture for this. I will use VS 2005 or 2008 to develop this.

     

    Regards,

    Kiran

    Monday, March 10, 2008 9:01 PM

Answers

  • one way, you can keep all the question and answers in xml files.

     

    For eg:

    Code Snippet

    <AllQuestions>

    <Question id="Q05">

    <QuestionText>Which country you are located?</QuestionText>

    <QuestionAnswers Type="RadioButton">US, UK, Canada</QuestionAnswers>

    <QuestionDisplayLocation Tab="1">10,40</QuestionDisplayLocation>

    </Question>

     

    <Question id="Q06">

    <QuestionText>What is your marital status?</QuestionText>

    <QuestionAnswers Type="RadioButton">Married, Single, Separated</QuestionAnswers>

    <QuestionDisplayLocation Tab="1">30,40</QuestionDisplayLocation>

    <QuestionDepends id="Q05">US, UK</QuestionDepends>

    </Question>

    </AllQuestions>

     

    Now you can build an application that can parse through this XML and build user interface dynamically.  There is quite a lot that can be done based on how you design your schema for xsd.

    Keeping in XML makes it easier to make changes to the question, answers, where to display in screen dynamically without having to go through a whole lot of testing...  Your application itself should be agnostic to what is in the XML.  It should be built based on the XSD.

     

    I would be interested to know other ways to do it, if there are additional posts...

    Tuesday, March 11, 2008 1:24 AM
  • That seems like a reasonably good idea.

     

    If you don't have the dependencies on other questions directly, you could transform the answers xml file using an Xslt as the users answers the questions.  By this I mean that you could wrap the display logic for a question with an xslt if condition to only output if whatever question evaluated to a particular value.

     

    That does sound a little like InfoPath, which if the solution is relatively simple, and isn't going to get any more complex, you could use, however if it is likely to become a much bigger project in the future you might like to consider the xml and xslt solution in a web page perhaps.

     

    Whichever way you do this, the implementation isn't likely to be all that pretty.  The xslt solution allows you some flexibility since it allows template matching, so with the right structure to your xml, you will need to write a lot less xslt code.

     

    I hope this helps,

     

    Martin Platt.

    Tuesday, March 11, 2008 2:56 AM
  •  kkolli wrote:

    1. From the above example for every user action we need to navigate thru XML, transform it and post it back as HTML to the client.Is it good idea to do transformation on Client side or server side thru AJAX. Which method you feel that is better. User will have lot of interaction on the page and need to change the questions accordinging to his answers.

    Not sure if AJAX applicable here. Note that Survey solutions are often attacked by malicious users. With AJAX this is often much harder to implement secure solution. IMHO server-side transformation is better in this situation.

    [offtop] We do have thousands of malicious requests on our survey servers, HTML/SQL injection, DOS (AJAX calls too) and so on...

    [/offtop]

     kkolli wrote:

    2.How to Save this whole data. All questions that we asked the user and his answers should be saved. Database Tables with so many fields or as a Single XML CLOB.

    All the questions and answers should be reviewed by Reviewer.

    IMHO, XML BLOB is more flexible. BUT, at the same time XML is much less maintainable; imagine all those software updates(when your assemblies expect new format, but your database still holds old formats), imagine reporting (just build by wizard or hours of walking with XSLT), imagine performance (update of the record, instead of the update of the whole XML).

    Sunday, March 23, 2008 4:12 PM

All replies

  • one way, you can keep all the question and answers in xml files.

     

    For eg:

    Code Snippet

    <AllQuestions>

    <Question id="Q05">

    <QuestionText>Which country you are located?</QuestionText>

    <QuestionAnswers Type="RadioButton">US, UK, Canada</QuestionAnswers>

    <QuestionDisplayLocation Tab="1">10,40</QuestionDisplayLocation>

    </Question>

     

    <Question id="Q06">

    <QuestionText>What is your marital status?</QuestionText>

    <QuestionAnswers Type="RadioButton">Married, Single, Separated</QuestionAnswers>

    <QuestionDisplayLocation Tab="1">30,40</QuestionDisplayLocation>

    <QuestionDepends id="Q05">US, UK</QuestionDepends>

    </Question>

    </AllQuestions>

     

    Now you can build an application that can parse through this XML and build user interface dynamically.  There is quite a lot that can be done based on how you design your schema for xsd.

    Keeping in XML makes it easier to make changes to the question, answers, where to display in screen dynamically without having to go through a whole lot of testing...  Your application itself should be agnostic to what is in the XML.  It should be built based on the XSD.

     

    I would be interested to know other ways to do it, if there are additional posts...

    Tuesday, March 11, 2008 1:24 AM
  • That seems like a reasonably good idea.

     

    If you don't have the dependencies on other questions directly, you could transform the answers xml file using an Xslt as the users answers the questions.  By this I mean that you could wrap the display logic for a question with an xslt if condition to only output if whatever question evaluated to a particular value.

     

    That does sound a little like InfoPath, which if the solution is relatively simple, and isn't going to get any more complex, you could use, however if it is likely to become a much bigger project in the future you might like to consider the xml and xslt solution in a web page perhaps.

     

    Whichever way you do this, the implementation isn't likely to be all that pretty.  The xslt solution allows you some flexibility since it allows template matching, so with the right structure to your xml, you will need to write a lot less xslt code.

     

    I hope this helps,

     

    Martin Platt.

    Tuesday, March 11, 2008 2:56 AM
  •  

    Hi

    Thanks and I liked your post. I have 2 questions poping up in my mind to go with this kind solution

     

    1. From the above example for every user action we need to navigate thru XML, transform it and post it back as HTML to the client.Is it good idea to do transformation on Client side or server side thru AJAX. Which method you feel that is better. User will have lot of interaction on the page and need to change the questions accordinging to his answers.

     

    2.How to Save this whole data. All questions that we asked the user and his answers should be saved. Database Tables with so many fields or as a Single XML CLOB.

    All the questions and answers should be reviewed by Reviewer.

     

    Please share your thoughts.

     

    Regards,

    Kiran

    Friday, March 21, 2008 2:33 AM
  • I am not a big fan of JavaScript...  Both Ajax and Clientside DHTML heavily uses Javascript.  If I were given an option to choose one amont other, it would be Serverside AJAX as much as possible.

     

    I prefer to store information in XML so this stays within the flexibility of changing the xml without too much of code...

    Friday, March 21, 2008 7:00 PM
  •  kkolli wrote:

    1. From the above example for every user action we need to navigate thru XML, transform it and post it back as HTML to the client.Is it good idea to do transformation on Client side or server side thru AJAX. Which method you feel that is better. User will have lot of interaction on the page and need to change the questions accordinging to his answers.

    Not sure if AJAX applicable here. Note that Survey solutions are often attacked by malicious users. With AJAX this is often much harder to implement secure solution. IMHO server-side transformation is better in this situation.

    [offtop] We do have thousands of malicious requests on our survey servers, HTML/SQL injection, DOS (AJAX calls too) and so on...

    [/offtop]

     kkolli wrote:

    2.How to Save this whole data. All questions that we asked the user and his answers should be saved. Database Tables with so many fields or as a Single XML CLOB.

    All the questions and answers should be reviewed by Reviewer.

    IMHO, XML BLOB is more flexible. BUT, at the same time XML is much less maintainable; imagine all those software updates(when your assemblies expect new format, but your database still holds old formats), imagine reporting (just build by wizard or hours of walking with XSLT), imagine performance (update of the record, instead of the update of the whole XML).

    Sunday, March 23, 2008 4:12 PM