Using $aFields with export_responses

More
2 years 1 month ago #149091 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?

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
2 years 1 month ago #149104 by conwa02976
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.

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #149108 by jelo

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

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #149114 by holch
ahhhh, good find Jelo!

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

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
1 month 5 days ago #181676 by mguacci
Is ther a way to include all fields to export, including participant custom attributes?

Please Log in or Create an account to join the conversation.

More
1 month 4 days ago - 1 month 4 days ago #181762 by tpartner
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: 1 month 4 days ago by tpartner.

Please Log in or Create an account to join the conversation.

More
1 month 4 days ago #181777 by mguacci
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.

Please Log in or Create an account to join the conversation.

More
1 month 4 days ago #181780 by DenisChenu
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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
1 month 4 days ago #181783 by mguacci
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.

Please Log in or Create an account to join the conversation.

More
1 month 4 days ago #181789 by DenisChenu
I write : do it in 2 times export the responses, and after export related participant : api.limesurvey.org/classes/remotecontrol...rticipant_properties
"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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
4 weeks 1 day ago #182084 by evently
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!

Please Log in or Create an account to join the conversation.

More
4 weeks 1 day ago #182097 by DenisChenu

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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: evently

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!