surveyjs / surveyjs-wordpress

Example of integration SurveyJS: Survey Library and Survey Creator into WordPress
https://wordpress.org/plugins/surveyjs/
36 stars 19 forks source link

How to get the results as proper JSON? #8

Open flowt-au opened 5 years ago

flowt-au commented 5 years ago

My WP survey has dynamic panels which I am going to need to "flatten" in order to make a sensible report. First step is to get the JSON of all results.

If I click the Copy button I do not get JSON. I get a mixture of text and json as below (is an abbreviated version of data from the test survey results). Any way to get clean JSON? Am I missing something.

‹ Kindlehill School, Blue Mountains — WordPress

question9 question6 For this student ... To what extent is the school meeting your expectations of your child/young person’s education What are your thoughts about the volunteer work you do at the school? Are you intending to send your child to Kindlehill High School? Whatever your response above, please expand on your thinking about High School. How would you rate your expectation of administration in terms of: Do you read? What does Kindlehill do well?
Test 1 Show in Survey [{"question2":{"Row 1":"Column 2"},"question3":{"Row 1":"Column 1"}},{},{}] {"0":{"Column 2":"1","improvements":"ghjk ghjkghkjg"},"To what extent do you value the balance of thinking, feeling, doing (willing) in your child/young person’s education?":{"Column 3":"1","improvements":"bhj "}}

{snip....}

} {"Kindlings":"Sometimes","Fortnightly newsletter via email":"Always"} all Show in Survey

Thanks, Murray

tsv2013 commented 5 years ago

It's easy to get full survey results (name, displayName, value, displayValue, data) programmatically: survey.getPlainData();

How to show flat survey in read only mode is demonstrated here - https://surveyjs.io/Examples/Library/?id=survey-displaymode&platform=jQuery&theme=default

You can use also the isSinglePage option.

But I'm not sure I understand your scenario.

flowt-au commented 5 years ago

Thanks! My question relates to this surveyjs-wordpress plugin, not surveyJS in general.

I was looking for the "export" button to get the result data as JSON directly from the WP interface. Or, even better, a button that runs the survey.getPlainData() on all the data and returns that.

At present, when you export to Excel or CSV matrix data is saved as JSON within an Excel cell which doesn't really help when it comes to reporting.

screen shot 2018-12-05 at 10 16 08 am

Ideally the Excel export should flatten the data automatically. As a fallback, getting the data as a "flat" JSON array means I can then use one of the JSON to excel converters. Better if surveyjs did that automatically though.

Thanks again, Murray

tsv2013 commented 5 years ago

Thank you, @flowt-au . I see now. I've marked this issue as an enchancement. This enchancement of the surveyjs-wordpress plugin (and surveyjs.io service site as well) makes sence. We'll definitely implement it. But I can't promise any timeline because we have a lot of tasks related to library and builder.

flowt-au commented 5 years ago

Cool. Thanks. I have stopped using the plugin because of this issue (and the others). Instead I have reverted to my own hosted version of SurveyJS and use an iframe in the WP site page to deliver it. Not ideal, but good enough for this project.

Thanks again, Murray