Welcome to the LimeSurvey Community Forum

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

Using $aFields with export_responses

  • conwa02976
  • conwa02976's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 weeks ago #149091 by conwa02976
Using $aFields with export_responses was created by conwa02976
I have seen this question in a couple other topics but have not seen a real good answer yet. We are using Ruby to call the export_responses method but we need to pull a field from the survey participants table and this parameter looks like it will do it but I can't seem to format the array correctly. If I just wanted to pull one field, we will say it is Field1, from the participants table for all completed surveys with the data, how would I format that array to work as a parameter?
The topic has been locked.
  • conwa02976
  • conwa02976's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 weeks ago #149104 by conwa02976
Replied by conwa02976 on topic Using $aFields with export_responses
Okay, so I got this to work and I figured out that when you add that Optional Selected Fields array parameter to the method you only get back the fields that you have in that array. You do not get back the full response dataset. Bummer!!!

Now, my problem is when I add either the "qid" or "title" for a question in that array I don't get anything back. I only get the data for the fields I am pulling from the survey participants table, no actual response data.

When I compare this to the manual Export from the quesXS suite it is like some kind of 'AND' is being performed. When I choose what statements I want exported from the 'Select columns' listbox AND what token fields I want from the 'Choose token fields' listbox then I get back all of the data responses AND whatever I choose from the token fields. That is expected.

On the other had, from the API when I do not add the Optional fields array I get back all of the data responses like I want but when I add the Optional fields array parameter to the method I only get back the field(s) from the survey participants table, I get nothing back from the data layer. I would think the API export_responses would match the queXS front end manual capability and give you everything back, the data responses AND the Optional fields that have been chosen.
The topic has been locked.
More
7 years 3 weeks ago #149108 by jelo
Replied by jelo on topic Using $aFields with export_responses

conwa02976 wrote: I would think the API export_responses would match the queXS front end manual capability and give you everything back, the data responses AND the Optional fields that have been chosen.

Why should that be the case? As far as I'm aware of queXS the integration with LimeSurvey is via accessing the database directly. Not loosely coupled via an API.
Or is the transition already done? Looks like WIP:
code.launchpad.net/~adamzammit/quexs/quexs-remotelime

I think you should open a bugreport on the tracker.
The API code isn't used that much in comparism to the rest of the codebase.
If it is no bug, it might be a feature request.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 weeks ago #149114 by holch
Replied by holch on topic Using $aFields with export_responses
ahhhh, good find Jelo!

Would be great to have a queXS that uses only the API.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
More
5 years 5 days ago #181676 by mguacci
Replied by mguacci on topic Using $aFields with export_responses
Is ther a way to include all fields to export, including participant custom attributes?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 days ago - 5 years 4 days ago #181762 by tpartner
Replied by tpartner on topic Using $aFields with export_responses
If the survey is not anonymous, you can export the token data.

- manual.limesurvey.org/Export_responses#Export_responses

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 4 days ago by tpartner.
The topic has been locked.
More
5 years 4 days ago #181777 by mguacci
Replied by mguacci on topic Using $aFields with export_responses
First of all, thank you for your answer. I understand how to export all data via UI. Is there a way to do the same using Remote Control API?
I didn't find any example about filling $aFields parameter for method export_responses.

Thank you.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 days ago #181780 by DenisChenu
Replied by DenisChenu on topic Using $aFields with export_responses
With current remote control API : you can :
1. Export response
2. Export related token
And you have what you want

Else you can extend Limesurvey remote control API .

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
5 years 3 days ago #181783 by mguacci
Replied by mguacci on topic Using $aFields with export_responses
DenisChenu, I'm using ajax to invoke Remote Control Api, with this params configuration:

var params = {
"method": exportResponsesFunction,
"params": {
"sSessionKey" : sessionKey,
"iSurveyID" : survey.sid,
"sDocumentType" : "xls",
"sLanguageCode" : null,
"sCompletionStatus" : "all",
"sHeadingType" : "full",
"sResponseType" : "long",
"aFields": ["firstname","lastname","email","attribute_1","attribute_2","attribute_3"]
},
jsonrpc: "2.0",
id: "exportResponses"
};


But result is always the same: no token data appears in the xls file.

How have I to fill $aFields param? I didn't find examples on the Web.

I would appreciate if you could give me any kind of suggestion.

Thank you.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 days ago #181789 by DenisChenu
Replied by DenisChenu on topic Using $aFields with export_responses
I write : do it in 2 times export the responses, and after export related participant : api.limesurvey.org/classes/remotecontrol...rticipant_properties
Code:
"method": exportResponsesFunction,
?
api.limesurvey.org/classes/remotecontrol...hod_export_responses

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • evently
  • evently's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
4 years 11 months ago #182084 by evently
Replied by evently on topic Using $aFields with export_responses
Hi,
to get particular questions back with the remote control the aFields array should be an array as you have, but the questions need to be added not with their questioncodes but with their database name, eg 123456X789X10 so {SURVEYID}X{GROUPID}X{QUESTIONID}. But you would need to get the internal code for every question you want to export..

I recently had the same problem, so I wrote a helper for my php remote control package, not sure if it would help you with ruby but it's here: github.com/evently-nl/limeremote/blob/ma...emoteHelperTrait.php

Best regards,
Stefan (stefan(at)evently.nl)
Evently
Looking for beta testers: interested in connecting Zapier to Limesurvey or
creating Telegram and Messenger bots from Limesurvey? Email me!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #182097 by DenisChenu
Replied by DenisChenu on topic Using $aFields with export_responses

evently wrote: …
I recently had the same problem, so I wrote a helper for my php remote control package, not sure if it would help you with ruby but it's here: github.com/evently-nl/limeremote/blob/ma...emoteHelperTrait.php

It work only for single question type, not for multiple or specific (ranking for example).
gitlab.com/SondagesPro/RemoteControl/rcA...ntrolHandler.php#L51
or
gitlab.com/SondagesPro/coreAndTools/getQ...eyCodeHelper.php#L65

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: evently
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose