View Issue Details

IDProjectCategoryView StatusLast Update
15242Feature requestsRemoteControlpublic2019-12-15 23:18
Reporterhealthvision_prod Assigned To 
PrioritynoneSeverityfeature 
Status newResolutionopen 
Summary15242: api to delete response by token
Description

As an enterprise customer I want to be able to delete a participant's response using surveyId and token, so I can meet my privacy rules and delete data as soon as possible.

acceptance criteria:

  • there is a new endpoint in remote control, like delete_response_by_tokens
  • inputs: sSessionKey, iSurveyID, aTokens
  • returns: status, conditionally with error message
Additional Information
/**
* RPC Routine to delete survey responses by token
*
* @access public
* @param string $sSessionKey Auth credentials
* @param int $iSurveyID ID of the Survey that the token belongs to
* @param array $aTokens tokens to delete
* @return array Result of deletion
*/
public function delete_responses_by_token($sSessionKey, $iSurveyID, $aTokens)
{ 
    if (!$this->_checkSessionKey($sSessionKey)) {
        return array('status' => 'Invalid Session Key');
    }
    if (!Permission::model()->hasSurveyPermission($iSurveyID, 'responses','delete')) {
        return array('status' => 'No permission');
    }
    $aResult = array();
    foreach ($aTokens as $sToken) {
        $response = Response::model($iSurveyID)->findByAttributes(array('token'=>$sToken));
        if (!isset($response)) {
            $aResult[$sToken] = 'Invalid token';
        } elseif ($response->delete()) {
            $aResult[$sToken] = 'Deleted';
        } else {
            $aResult[$sToken] = 'Deletion went wrong';
        }
    }
    return $aResult;
}
TagsNo tags attached.

Activities

nakojk

nakojk

2019-12-10 14:13

reporter   ~54991

There is now 3 feature requests (08898 and 09956) for this for 5,75 years and 08898 and this very ticket come along with a working code snippet. Come on, guys!

DenisChenu

DenisChenu

2019-12-11 07:47

developer   ~54998

My opinion : make a clean system to allow add function in remote control is the best way to solve such issues

bismark

bismark

2019-12-15 23:18

reporter   ~55036

Behaviors?
https://github.com/mbischof/LimeSurvey/issues/6

Issue History

Date Modified Username Field Change
2019-09-06 15:21 healthvision_prod New Issue
2019-12-10 14:13 nakojk Note Added: 54991
2019-12-11 07:47 DenisChenu Note Added: 54998
2019-12-15 23:18 bismark Note Added: 55036