automated export of survey results for import in R

More
4 years 4 months ago #96586 by svollmar
svollmar created the topic: automated export of survey results for import in R
Hello,

we have integrated LimeSurvey 2.00 into our workflow for managing our proband data (we have written a lot of MySQL, PHP and Python code). At our institute, LimeSurvey is used as a web front end for surveys, management of invitations and reminders is handled by our system, as is the generation of tokens; we have patched "application/helpers/SurveryRuntimeHelper.php" to trigger (via ZMQ) an immediate response from our internal system when a survey has been completed. So far, we are very satisfied with the whole setup.

However, we would like to take integration one step further: if certain surveys are completed, they should be evaluated and the results be transferred to some internal databases. As mentioned above, we can already trigger arbitrary code of ours when the survey has been completed. We can also manually export data for import in R (this seems to be the cleanest method) and would like to automate that step: is there a way to have LimeSurvey write the R files for a particular $sid to some file? We can run code locally on the machine serving LimeSurvey, or use a remote PHP call with a URL.

Many thanks in advance.
Stefan
The following user(s) said Thank You: r0bis

Please Log in to join the conversation.

More
4 years 4 months ago #96595 by mdekker
mdekker replied the topic: automated export of survey results for import in R
Have you tried remote control? You might not need the remote control but you can see how export results is handled there. I believe there is some documentation on the subject, but if you get stuck you can always ask for help here.

---
Menno Dekker

Please Log in to join the conversation.

More
4 years 4 months ago #96647 by svollmar
svollmar replied the topic: automated export of survey results for import in R
Dear mdekker,

thank you for mentioning "remote control". We have just tried the API via JSON-RPC with

...
$responses = $myJSONRPCClient->export_responses ($sessionKey, $survey_id,
"csv",
"de",
"full",
"long"
); //Export response data to pdf,csv,xls,doc
file_put_contents("/tmp/a.csv", base64_decode($responses));
...

and got the expected result - great!
However, so far we can only export the CSV version of a given survey. Is there a way to also export the "R syntax" file?
Many thanks in advance,
Stefan
The following user(s) said Thank You: stevelegare

Please Log in to join the conversation.

More
4 years 4 months ago #96674 by mdekker
mdekker replied the topic: automated export of survey results for import in R
At the moment this is not possible as R and SPSS exports have a different code base then the other exports. It is on the roadmap for a future version to make all exports behave the same but unfortunately I can give no ETA for that feature.

Maybe your best shot for now would be to look at the file /application/controllers/admin/export.php and look at the exportr() method.

---
Menno Dekker

Please Log in to join the conversation.

More
4 years 4 months ago #96678 by svollmar
svollmar replied the topic: automated export of survey results for import in R
Been there, done that - but I did not see a good (or any) way to call the code there in an automated fashion. I would need to supply the survey id and then, somehow, call exportr().

Anyway, exporting the CSV file in a (clean) and automated fashion was the important part, the R file (as I understand it) only needs to be generated once for each survey (unless the structure changes).

Thanks,
Stefan

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now