Skip to content

Commit

Permalink
Fixed issue #7754: Retrieving list of participants with additional t…
Browse files Browse the repository at this point in the history
…oken information
  • Loading branch information
trougakoss committed Apr 16, 2013
1 parent 7c4b5a1 commit f2e0962
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions application/controllers/admin/remotecontrol.php
Expand Up @@ -2031,21 +2031,22 @@ public function set_participant_properties($sSessionKey, $iSurveyID, $iTokenID,
}



/**
* RPC Routine to return the ids and info of token/participants of a survey.
* if $bUnused is true, user will get the list of not completed tokens (token_return functionality).
* Parameters iStart and ilimit are used to limit the number of results of this call.
* Parameter aAttributes is an optional array containing more attribute that may be requested
*
* @access public
* @param string $sSessionKey Auth credentials
* @param int $iSurveyID Id of the survey to list participants
* @param int $iStart Start id of the token list
* @param int $iLimit Number of participants to return
* @param bool $bUnused If you want unused tokensm, set true
* @param bool|array $aAttributes The extented attributes that we want
* @return array The list of tokens
*/
public function list_participants($sSessionKey, $iSurveyID, $iStart=0, $iLimit=10, $bUnused=false)
public function list_participants($sSessionKey, $iSurveyID, $iStart=0, $iLimit=10, $bUnused=false,$aAttributes=false)
{
if ($this->_checkSessionKey($sSessionKey))
{
Expand All @@ -2066,16 +2067,28 @@ public function list_participants($sSessionKey, $iSurveyID, $iStart=0, $iLimit=1
if(count($oTokens)==0)
return array('status' => 'No Tokens found');

if($aAttributes) {
$aBasicDestinationFields=Tokens_dynamic::model()->tableSchema->columnNames;
$aTokenProperties=array_intersect($aAttributes,$aBasicDestinationFields);
$currentAttributes = array('tid','token','firstname','lastname','email');
$extendedAttributes = array_diff($aTokenProperties, $currentAttributes);
}

foreach ($oTokens as $token)
{
$aData[] = array(
$dataArray = array(
'tid'=>$token->primarykey,
'token'=>$token->attributes['token'],
'participant_info'=>array(
'firstname'=>$token->attributes['firstname'],
'lastname'=>$token->attributes['lastname'],
'email'=>$token->attributes['email'],
));

foreach($extendedAttributes as $sAttribute)
$dataArray[$sAttribute]=$token->attributes[$sAttribute];

$aData[]= $dataArray;
}
return $aData;
}
Expand All @@ -2086,6 +2099,8 @@ public function list_participants($sSessionKey, $iSurveyID, $iStart=0, $iLimit=1
return array('status' => 'Invalid Session Key');
}



/**
* RPC routine to to initialise the survey's collection of tokens where new participant tokens may be later added.
*
Expand Down

0 comments on commit f2e0962

Please sign in to comment.