View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
07641Feature requestsRemoteControlpublic2023-02-13 09:14
Reporteralibert Assigned Togabrieljenik  
PrioritynormalSeverityfeature 
Status feedbackResolutionreopened 
Summary07641: RemoteControl2 - export_responses - Tweak ResponseType to support all features like in frontend
Description

With export_responses it is only possible to set the repsonse type to 'short' or 'long'.
However in the frontend it is possible to convert answercodes from 'Y' or 'N' to another character (in out case "1" and "2).

This should be supported in the remote control API-function export_responses.

Additional Information

Possible solution in export_responses (remotecontrol.php):

public function export_responses($sSessionKey, $iSurveyID, $sDocumentType, $sLanguageCode=null, $sCompletionStatus='all', $sHeadingType='full', $sResponseType='short', $iFromResponseID=null, $iToResponseID=null, $aFields=null)
{
....
$oFomattingOptions->headingFormat=$sHeadingType;

    // Check if $sResponseType is an array
    // if yes set the formatting Options like this.
    if (is_array($sResponseType)) {
      $oFomattingOptions->answerFormat=$sResponseType['answerFormat'];
      $oFomattingOptions->convertY=$sResponseType['convertY'];
      $oFomattingOptions->yValue=$sResponseType['yValue'];
      $oFomattingOptions->convertN=$sResponseType['convertN'];
      $oFomattingOptions->nValue=$sResponseType['nValue'];
    } 
    // if not, continue with the old behavior
    else {
      $oFomattingOptions->answerFormat=$sResponseType;
    }

    $oFomattingOptions->output='file';

....
return base64_encode($sFileData);
}

Call to the function would look like this:
$aFormat = array();
$aFormat['answerFormat']='short';
$aFormat['convertY']=true;
$aFormat['yValue']='1';
$aFormat['convertN']=true;
$aFormat['nValue']='2';

this->export_responses( $sessionKey, $survey_id,'csv','de','all','code',$aFormat);

or shorter:

export_responses( $sessionKey, $survey_id,'csv','de','all','code',array('answerFormat'=>'short', 'convertY'=>true, 'yValue'=>'1', 'convertN'=>true, 'nValue'=>'2'));

TagsNo tags attached.
Bug heat8
Story point estimate
Users affected %

Users monitoring this issue

mfaber

Activities

gabrieljenik

gabrieljenik

2023-01-09 13:50

manager   ~73404

As this is very old, not sure what's the next status or steps for this.

c_schmitz

c_schmitz

2023-01-10 10:50

administrator   ~73409

See https://github.com/LimeSurvey/LimeSurvey/pull/2843

c_schmitz

c_schmitz

2023-01-10 10:51

administrator   ~73410

Last edited: 2023-01-10 10:51

@gabrieljenik Thank you for the code review - can you also test it, please?

gabrieljenik

gabrieljenik

2023-01-11 13:34

manager   ~73434

Added an automatic test case :)

gabrieljenik

gabrieljenik

2023-01-11 13:34

manager   ~73435

I think this is ready

c_schmitz

c_schmitz

2023-01-12 23:44

administrator   ~73455

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=34218

gabrieljenik

gabrieljenik

2023-02-09 14:01

manager   ~73777

@autopoiesis74 said...

But this is what I tried to achieve: Convert answercodes from 'Y' or 'N' to another character with the remote control API-function export_responses and it didn't work out for me.

library(limer)
options(lime_api = 'https://xxx')
options(lime_username = 'xxx')
options(lime_password = 'xxx')
get_session_key()
answers195486 <- call_limer(method = 'export_responses',
params = list(iSurveyID = 195486,
sDocumentType = 'csv',
sLanguageCode= 'en',
sCompletionStatus='all',
sHeadingType='code',
sResponseType='short',
aAdditionalOptions= c('convertY'=TRUE,'yValue'=1,'convertN'=TRUE,'nValue'=0)))
release_session_key()
gabrieljenik

gabrieljenik

2023-02-09 14:02

manager   ~73778

@autopoiesis74 Do you have an LSA so we can reproduce?

gabrieljenik

gabrieljenik

2023-02-09 14:05

manager   ~73779

@autopoiesis74 Just fishing here, but have you tried setting the aFields to null ?

autopoiesis74

autopoiesis74

2023-02-13 09:14

reporter   ~73806

@gabrieljenik: I have tried to set the aFields to null which causes an empty data set. I have attached the lsa file you have requested.

Related Changesets

LimeSurvey: master bf9737c2

2023-01-12 23:44:13

c_schmitz


Committer: GitHub Details Diff
New feature 07641: Options to use Y/N conversion in RemoteControl API export (#2843) Affected Issues
07641
mod - application/helpers/remotecontrol/remotecontrol_handle.php Diff File
add - tests/data/surveys/survey_archive_RemoteControlExportResponses.lsa Diff File
mod - tests/unit/helpers/RemoteControlTest.php Diff File

Issue History

Date Modified Username Field Change
2013-03-06 15:30 alibert New Issue
2013-03-12 14:31 c_schmitz Status new => acknowledged
2013-03-12 14:31 c_schmitz Severity @40@ => feature
2013-03-12 15:04 mfaber Issue Monitored: mfaber
2023-01-09 13:19 c_schmitz Assigned To => gabrieljenik
2023-01-09 13:19 c_schmitz Status acknowledged => assigned
2023-01-09 13:50 gabrieljenik Note Added: 73404
2023-01-09 13:50 gabrieljenik Bug heat 2 => 4
2023-01-10 10:50 c_schmitz Note Added: 73409
2023-01-10 10:50 c_schmitz Bug heat 4 => 6
2023-01-10 10:51 c_schmitz Note Added: 73410
2023-01-10 10:51 c_schmitz Note Edited: 73410
2023-01-11 13:34 gabrieljenik Note Added: 73434
2023-01-11 13:34 gabrieljenik Assigned To gabrieljenik => c_schmitz
2023-01-11 13:34 gabrieljenik Status assigned => ready for merge
2023-01-11 13:34 gabrieljenik Note Added: 73435
2023-01-12 23:44 c_schmitz Changeset attached => LimeSurvey master bf9737c2
2023-01-12 23:44 c_schmitz Note Added: 73455
2023-01-12 23:44 c_schmitz Resolution open => fixed
2023-01-12 23:45 c_schmitz Status ready for merge => resolved
2023-02-09 14:01 gabrieljenik Note Added: 73777
2023-02-09 14:02 gabrieljenik Note Added: 73778
2023-02-09 14:05 gabrieljenik Note Added: 73779
2023-02-09 18:19 gabrieljenik Assigned To c_schmitz => gabrieljenik
2023-02-09 18:19 gabrieljenik Status resolved => feedback
2023-02-09 18:19 gabrieljenik Resolution fixed => reopened
2023-02-13 09:14 autopoiesis74 Note Added: 73806
2023-02-13 09:14 autopoiesis74 File Added: survey_archive_159462.lsa
2023-02-13 09:14 autopoiesis74 Bug heat 6 => 8