Welcome to the LimeSurvey Community Forum

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

Get question code AND question text in export via remote control API

More
2 years 7 months ago - 2 years 7 months ago #251289 by ClimateCentre
I use LimeSurvey Cloud Version 6.3.0
===
Hi! I have a simple PHP script that exports all complete responses from a survey via the remote control API and drops them in a CSV file (which is fetched via Google App Script and imported into a Google Sheet, so that it can be visualized in Looker Studio).
Code:
$response = $lsJSONRPCClient->export_responses($sessionKey, $surveyID, 'csv', 'en', 'complete', 'I_need_BOTH_here');

The issue: the export_responses function has a parameter $sHeadingType that can be set to 'code', 'full' or 'abbreviated', but not to 'both' like in the normal LS statistics module that lets you select 'question code', 'question text' or 'both' for the graph labels. It would be much easier to navigate the spreadsheet when the questions (= column headings) appear as question code and question text (for example, "A1 What is your Name?").

Is there any way to export the responses of a survey with question code AND question text via the remote control API?

Thank you!





 
Last edit: 2 years 7 months ago by ClimateCentre. Reason: Clarified that this question is about the remote control API response export!

Please Log in to join the conversation.

More
2 years 7 months ago - 2 years 7 months ago #251295 by holch
Not sure what you mean. In LS 6 there are 4 options to export data:
1. Question code
2. Abbreviated question text
3. Full question text
4. Question code & Question text.

Point 4 is what you are looking for. Just checked on LS 6.3.0

[edit] Just noticed that you are talking purely about API[/edit]

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
Last edit: 2 years 7 months ago by holch.

Please Log in to join the conversation.

More
2 years 7 months ago - 2 years 7 months ago #251310 by DenisChenu
Looking at api.limesurvey.org/classes/remotecontrol...hod_export_responses

It must be in $aAdditionalOptions

Try to send
Code:
['headstyle' => 'codetext']
(found in HTML view of export).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
Last edit: 2 years 7 months ago by DenisChenu.

Please Log in to join the conversation.

More
2 years 7 months ago #251313 by ClimateCentre
Thank you, @DenisChenu! I tried it with $aAdditionalOptions, but this does not work.

However, it works when setting $sHeadingType to 'codetext' - apparently this is an undocumented fourth option. Can someone add this to the API documentation? This works:
Code:
$response = $lsJSONRPCClient->export_responses($sessionKey, $surveyID, 'csv', 'en', 'complete', 'codetext', 'long');

It's not pretty because the question code and question text get concatenated without a space or character in between, looking like this, for example: "A1bHow did you hear about us?". For comparison, when exporting responses via the normal web interface in LS6, the "Question code & Question text" option puts a ". " (period and empty space) in between code and text, which makes the heading more readable.

It would be amazing if $sHeadingType in the API were configurable similar to the LS6 web interface. Any chance this could be implemented?

Please Log in to join the conversation.

More
2 years 7 months ago #251316 by DenisChenu
Oh yes ! You're right : aAdditionalOptions only for extra option not in previous params :)
sHeadingType exist then put it here.

About
> It would be amazing if $sHeadingType in the API were configurable similar to the LS6 web interface

did you try codetextseparator => " . " in aAdditionalOptions ?

else
> apparently this is an undocumented fourth option

Please : create a mantis issue and a Pull request
Code of API doc is here : github.com/LimeSurvey/LimeSurvey/blob/d3...rol_handle.php#L3450

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

More
2 years 7 months ago - 2 years 7 months ago #251323 by ClimateCentre
Thank you! I tried
Code:
['codetextseparator' => '. ']
in $aAdditionalOptions. Unfortunately, this does not have any effect.

Could this additional option be called something else (other than 'codetextseparator')?
Last edit: 2 years 7 months ago by ClimateCentre.

Please Log in to join the conversation.

More
2 years 7 months ago #251327 by DenisChenu

Thank you! I tried
Code:
['codetextseparator' => '. ']
in $aAdditionalOptions. Unfortunately, this does not have any effect.

Could this additional option be called something else (other than 'codetextseparator')?
Sorry,

Looking at code : it's not implemented … i think we can put whole extra options here , but not …
github.com/LimeSurvey/LimeSurvey/blob/d3...rol_handle.php#L3492

Solutions
1. Report the issue as Feature request and wait …
2. Report the issue as Feature request and create Git Pull request, wit but less time.
3. Hack code (bad … solution for updating)
4. Create your own remote control export function as a plugin : sample github.com/LimeSurvey/LimeSurvey/blob/d3...rol_handle.php#L3492 (but old) quick but complex.

My advice : do 2+3


 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

More
2 years 6 months ago #252442 by ClimateCentre

Please Log in to join the conversation.

More
1 year 3 days ago #270502 by sergiobaiao
Hi there ClimateCentre,

Did you succeed in this? I wanted to create a Looker Studio report for my Limesurveys also. Can you please share a "how-to" if possible?

Please Log in to join the conversation.

More
1 week 1 day ago - 1 week 1 day ago #274353 by Mazi
The remote control API is maintained by the LimeSurvey developers. So filing a feature request at bugs.limesurvey.org asking them if this can be implemented is the best approach.

Alternatively, if you hosting allows installing plugins, one code code a simple Limesurvey plugin which extends the remote control API and adds such a custom export feature.

But this requires your hosting to allow plugin installation. If you are using "LimeSurvey Cloud", this will not be an option. In this case I recommend our LimeSurvey optimized hosting, see survey-consulting.com/limesurvey-hosting/

 

Best regards/Beste Grüße,
Dr. Marcel Minke
survey-consulting.com
offlinesurveys.com
Feel free to contact me by email for professional LimeSurvey support!
Last edit: 1 week 1 day ago by Mazi.

Please Log in to join the conversation.

More
5 days 20 hours ago #274388 by jelo
Interesting comparison. The "starting at 25 EUR/USD" might need a further explanation. Unlimited storage is nowhere available. Conducting surveys seldom cause a storage problem. So I understand the intention of that claim. But these days a third party in the survey business could challenge that as misleading (German UWG).
 

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Please Log in to join the conversation.

More
5 days 19 hours ago #274393 by Mazi
@jelo, "Starting at" means that you can book additional services like your own domain for 9€/month.
And yes, if people are planning a survey with e.g. 200k participants, we ask them to get in touch with us so we can assign additional ressources to their system which will lead to slightly higher costs.

Given the fact that even collecting 200k responses will not cause the database size to grow notably, we decided to not bill by response because it turns out that this is not very user friendly especially if your system gets blocked if the response limit is reached.

Best regards/Beste Grüße,
Dr. Marcel Minke
survey-consulting.com
offlinesurveys.com
Feel free to contact me by email for professional LimeSurvey support!

Please Log in to join the conversation.

More
5 days 12 hours ago #274395 by jelo
I'm aware of that but not everybody is checking your order form to see what is included and what is an addon with a small price added.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose