I would like to be able to pull statistics from survey to include in completed page of every survey. The statistics should be calculated real time. Use case: polling.
The survey respondent should see one multiple choice question:
Who would you vote for:
1. Sanders
2. Clinton
After user submits, the completed page should show: (calculating from all respondents the percentage that have voted for Clinton and Sanders)
"You voted for Clinton, and so did 30% of all respondents.", or "30% of 300 respondents chose Clinton"
Is there a way to pull statistics with javascript or php by entering code on the template editor? I can pull just the respondent data and know how to work with that data, but I dont know how to pull data realtime from all respondents and aggregate the data for each survey completed page.
I can think of setting up a server app that accesses the database or api and pulls data and creates report pages, and then use the url redirect function to replace the completed page. But is there an easier way to do this through templates or built in reporting in limesurvey?
I appreciate any pointing in the right (easiest) direction.
There is no built-in way to access previous results from within the survey. The solution would be, as you suggest, a remote file that queries the database. You could redirect to that file or make an AJAX call from the end screen.
Cheers,
Tony Partner Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Thank you both for your suggestions. Can the new API be used to pull answers from all respondents? I see a mention of export in csv format, but is there actually an api call that will return json formatted answer results from a particular survey?