[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating Dynamic Surveys - The Concept

Posted on 2006-04-04
4
Medium Priority
?
638 Views
Last Modified: 2012-06-21
I need a simple example (either ASP or PHP code) of how to

1. Store the survey questions in a database based on templates
2. Display these questions on a form dynamically
3. Code for how to save reponses on that form

Can anyone help me with that?

Thanks
:) SD
0
Comment
Question by:sciber_dude
  • 2
4 Comments
 
LVL 4

Assisted Solution

by:dukestaTAI
dukestaTAI earned 800 total points
ID: 16374361
Here is a sample of classic asp code that code that does a portion of what you are asking.  However you are asking for a full blown application which i would be glad to build for you on a consultant basis in either Classic ASP or ASP.NET.

The code below loops through records retrieved from a database connection(not shown) and displays the questions on a form dynamically. The process of posted data(not shown) writes the answers back to the databas in a user answer table for later review.  There are much more efficient ways of doing this with ASP.NET as well. I hope this answeres you question.

<form action="surveyprocess.asp" Method="post" onSubmit="return valid(this)">
      <ol>
      <%Do while not rs.EOF%>
      
      <li>
            <%=rs.fields("Question")%></li><br>
            <%  ID = rs.fields("id")%>
            <%  rsSurvey.MoveFirst
                  Do while not rsSurvey.EOF
                              
                              Rating = rsSurvey.fields("id")
                              Description = rsSurvey.fields("Description")%>
                              <input type="radio" name="Q<%=ID%>" Value="<%=Rating%>">&nbsp;<%=Description%><br>
                              
                              <%rsSurvey.MoveNext
                              
                  Loop
            %>
            
            <br>
            
      <%rs.MoveNext
      Loop%>
0
 
LVL 11

Author Comment

by:sciber_dude
ID: 16394086
Thank you for the code. I understand what you say. What would be the database structure for this kind of table?

:) SD
PS: Upped the points to 500
0
 
LVL 6

Accepted Solution

by:
nabsol earned 1200 total points
ID: 16402156
Hi
I had worked for a site to create survery builder. So may be i can help you in detail.

1. About Database Tables:

               ::Table Names::
              1. "Survey" (This table will store all the surveys; id, columns name, creator, status etc)
       
 Questions created:
              2. "Question" (This table will store questions ; id, survey_id, question_text, type_of_question (for mcq, t/f/ descriptive etc), required(if option is optional or required))
             
             
Responses gathered.
             3. "Response" This table will store responses each with its own id called ( response_id, survey_id, time_taken, response_date )

              4,5,6. For each type of question different table. i.e. To store true/false quesiton a table "tfResponse" (id, survey_id, response_id, question_id, trueorfalse), second may be "descriptiveResponse" (id, survey_id, response_id, question_id, description) and third for mcq responses.



Now when someone will create survey you will enter values in Question table (question_text, question type) . We had given interface to user so that user can select which quesion he wants to create and what are its options if its mcq.

When some will want to take survey pick all the quesion by survey_id which is in quesion and then show all the quesions according to the type.

if ($question_type == "tf")
{
   //output question text
   //output two radio buttons and two values
}
else if ($question_type == "descriptive")
{
   //output question text
   //output multiline or single line text box; you can also get when user was creating survey
}
......


To store responses simply use those "response" tables to store one entry in response table and get response_id and put that id in tf, descriptive tables.

Afterall you can also generate reports. :) Hope this helps


If need to know more in this topic or anything else feel free to post :)
By Nab
0
 
LVL 11

Author Comment

by:sciber_dude
ID: 16402700
This is awesome! Thank you.

:) SD
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question