I want dynamic survey application in asp.net mvc any example all questions are true/false. any example.
Loading
I want dynamic survey application in asp.net mvc any example all questions are true/false. any example.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Deepak TewatiaPosted Dec 20, 2022, 6:56 PM
Hi mark,
I will guide you step by step, how to create dynamic survey application in ASP.NET MVC.
you need to create an ASP.NET MVC project in Visual Studio.
You can do this by selecting "File > New > Project" and then selecting "ASP.NET Web Application" from the list of templates.
On the next screen, select "MVC" as the project template.
then, you need to create a model to represent the survey questions and answers.
you can use the below code:
This model has three properties: ID, Text, and Answer.
The ID property is an integer that represents the unique ID of the question.
then, Text property is a string that contains the text of the question.
and last Answer property is a boolean that represents the correct answer to the question (true or false).
then, you need to create a controller and views to display the survey to the user and capture their answers.
you can use the below code:
here i am using list of hard coded questions you can fetch all from DB
This controller has three actions: Index, Index (POST), and Results.
The Index action displays the first question in the survey to the user.
and then Index (POST) action handles the form submission from the survey and checks the user's answer against the correct answer. If the answer is correct, it increments the score. If the answer is incorrect, it does not increment the score.
and last Results action displays the survey results to the user.
also need to create a view for each action in the controller.
index view : Index view should display the survey question and a form for the user to submit their answer.
Results View: Results view should display the survey results to the user.
Thanks
Aravind GovindarajPosted Dec 20, 2022, 6:45 PM
Please find the solution for the same
1. Create a page where you can enter survey questions, that supposes to be stored in your database. This option can able to do only by admin users.
2. Normal use can able to see the question that has been set it up by the admin. It means this user has an access only two methods in api i.e., GET and POST
GET => It uses to retrieve survey question
POST => It is used to insert the record.
While insert record you need to map, Question Number | UserId or User Name or Guest if anonymous user | True /False