View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
07641Feature requestsRemoteControlpublic2023-01-12 23:45
Reporteralibert Assigned Toc_schmitz  
PrioritynormalSeverityfeature 
Status resolvedResolutionfixed 
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 heat6

Users monitoring this issue

User List 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

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