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

  • ClimateCentre
  • ClimateCentre's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 1 week ago - 6 months 1 week 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: 6 months 1 week ago by ClimateCentre. Reason: Clarified that this question is about the remote control API response export!

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago - 6 months 1 week 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]

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

Last edit: 6 months 1 week ago by holch.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago - 6 months 1 week 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 service on demand , plugin development .
I don't answer to private message.
Last edit: 6 months 1 week ago by DenisChenu.

Please Log in to join the conversation.

  • ClimateCentre
  • ClimateCentre's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 1 week 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.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week 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 service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • ClimateCentre
  • ClimateCentre's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 1 week ago - 6 months 1 week 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: 6 months 1 week ago by ClimateCentre.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week 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 service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • ClimateCentre
  • ClimateCentre's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 months 6 days ago #252442 by ClimateCentre
I have created a feature request here: bugs.limesurvey.org/view.php?id=19259

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose