Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

automated export of survey results for import in R

  • svollmar
  • svollmar's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 9 months ago #96586 by svollmar
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
The topic has been locked.
  • mdekker
  • mdekker's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #96595 by mdekker
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
The topic has been locked.
  • svollmar
  • svollmar's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 9 months ago #96647 by svollmar
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
The topic has been locked.
  • mdekker
  • mdekker's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #96674 by mdekker
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
The topic has been locked.
  • svollmar
  • svollmar's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 9 months ago #96678 by svollmar
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
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose