- Posts: 4
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
6 months 1 week ago - 6 months 1 week ago #251289
by ClimateCentre
Get question code AND question text in export via remote control API was created 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).
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!
===
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11660
- Thank you received: 2742
6 months 1 week ago - 6 months 1 week ago #251295
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Get question code AND question text in export via remote control API
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]
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
6 months 1 week ago - 6 months 1 week ago #251310
by DenisChenu
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.
Replied by DenisChenu on topic Get question code AND question text in export via remote control API
Looking at
api.limesurvey.org/classes/remotecontrol...hod_export_responses
It must be in $aAdditionalOptions
Try to send
(found in HTML view of export).
It must be in $aAdditionalOptions
Try to send
Code:
['headstyle' => 'codetext']
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
6 months 1 week ago #251313
by ClimateCentre
Replied by ClimateCentre on topic Get question code AND question text in export via remote control API
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:
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?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
6 months 1 week ago #251316
by DenisChenu
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.
Replied by DenisChenu on topic Get question code AND question text in export via remote control API
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
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
6 months 1 week ago - 6 months 1 week ago #251323
by ClimateCentre
Replied by ClimateCentre on topic Get question code AND question text in export via remote control API
Thank you! I tried
in $aAdditionalOptions. Unfortunately, this does not have any effect.
Could this additional option be called something else (other than 'codetextseparator')?
Code:
['codetextseparator' => '. ']
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
6 months 1 week ago #251327
by DenisChenu
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.
Replied by DenisChenu on topic Get question code AND question text in export via remote control API
Sorry,Thank you! I tried
in $aAdditionalOptions. Unfortunately, this does not have any effect.Code:['codetextseparator' => '. ']
Could this additional option be called something else (other than 'codetextseparator')?
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 months 5 days ago #252442
by ClimateCentre
Replied by ClimateCentre on topic Get question code AND question text in export via remote control API
I have created a feature request here:
bugs.limesurvey.org/view.php?id=19259
Please Log in to join the conversation.