Tamilselvi
Joined: 22 Jul 2009 Posts: 3
|
Posted: Wed Jul 22, 2009 2:16 pm Post subject: How to calculate the votes in a survey |
|
|
Hi,
As a newbie, am creating survey using ROR. Am having three models
Survey
Questions
answers
I need to get the questions and answers from tose table and display in survey form. also while selecting the answers it should be stored in the survey table and the vote_count for the corresponding answer should be increased by 1.
i dont have much idea in the vote_count part. could anyone give some help on this.
Thanks in advance |
|
sivakrishna.m
Joined: 01 Jan 2008 Posts: 160 Location: Narsipatnam
|
Posted: Thu Jul 23, 2009 12:19 pm Post subject: Re:How to calculate the votes in a survey |
|
|
Hi Tamilselvi,
It is very simple to calculate the vote_count for a specified Query, to calculate vote_count in survey table follow the process:
1.In survey table structure should be like Q_id, A_id, Vote_count (default value Zero).
2.If any body selected an Answer for a specified Question, save the Question Id, Answer Id and Vote count as 1.
3.So for the second point , you have follow some criteria’s , first of all you have to check the “Answer Id “ And “Question Id” equal or not. If they are equal then increase the vote_count value by 1 or else create new record with that “Question Id”, “Answer Id” and Vote count as zero.
4.After saving the results, you can get the total vote_count for an answer related to a question.
Any Queries, Please feel free to ask.
Thanks,
Siva Krishna. |
|