set_participant_properties

Más
1 año 7 meses antes #162940 por mama0107
I work with version 2.62 of the Limesurvey. I would like to manage my survey with a small Java program. I use jdk1.8.0_91 and RemoteControl with json.


With this function, I export a participant property from a LimeSurvey survey

new StringEntity("{\"method\": \"get_participant_properties\", \"params\": {\"sSessionKey \": \""+sessionKey+"\", \"iSurveyId \": \""+surveyid+"\", \"iTokenId\":\""+participant_id+"\" }, \"id\": 1}");
or

new StringEntity("{\"method\": \"get_participant_properties\", \"params\": [ \""+sessionKey+"\", \""+surveyid+"\", \""+participant_id+"\" ], \"id\": 1}");

result

{"id":1,"result":{"tid":2,"participant_id":null,"firstname":"","lastname":"","email":"","emailstatus":"OK","token":"mB755ZDQfd","language":"de","blacklisted":null,"sent":"N","remindersent":"N","remindercount":0,"completed":"N","usesleft":1,"validfrom":null,"validuntil":null,"mpid":null},"error":null}




If I want to change a properties for a participant, then I only get error messages.

new StringEntity("{\"method\": \"set_participant_properties\", \"params\": [ \""+sessionKey+"\", \""+surveyid+"\", \""+participant_id+"\", \"language\":\"es\" ], \"id\": 94}");

result

{"id":null,"result":null,"error":"unable to decode malformed json"}

or

new StringEntity("{\"method\": \"set_participant_properties\", \"params\": [ \""+sessionKey+"\", \""+surveyid+"\", \""+participant_id+"\", \""+aTokenProperties+"\" ], \"id\": 194}");

result

ERROR StatusCode 500

How can I pass the argument $aTokenData?


Best regards Cornelia

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

LimeSurvey Partners
Más
1 año 7 meses antes #162942 por LouisGac
Respuesta de LouisGac sobre el tema set_participant_properties
The method can be found here:
github.com/LimeSurvey/LimeSurvey/blob/2....ndle.php#L1630-L1674

public function get_participant_properties($sSessionKey, $iSurveyID, $iTokenID, $aTokenProperties)


And as you can see:
github.com/LimeSurvey/LimeSurvey/blob/2....rol_handle.php#L1657
                $result = array_intersect_key($token->attributes, array_flip($aTokenProperties));
 


the param $aTokenProperties is used for a array_flip function
php.net/manual/en/function.array-flip.php

Note that the values of array need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be included in the result.



That doesn't explain why you have an error 500.
I suggest you do some test on the method, maybe you'll find a bug.
Feel free to submit PR to our Git Repository.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 7 meses antes #162945 por mama0107
Respuesta de mama0107 sobre el tema set_participant_properties
Thank you for your prompt reply.

For the argument $aTokenProperties I tried different java data types.
HashMap<String, String>
Hashtable<String, String>
ArrayList<String>


But without success

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 7 meses antes #162948 por LouisGac
Respuesta de LouisGac sobre el tema set_participant_properties
Google: "Java LimeSurvey Remote control"

github.com/Falydoor/limesurvey-rc/blob/m...veyRC.java#L384-L393

LimeSurvey is OpenSource. Most of the time, when you want to do something, someone else already did it. So rather than doing everything from scratch again and again (like in privative software logic), it's always better to use and modify what others did.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 7 meses antes #163040 por mama0107
Respuesta de mama0107 sobre el tema set_participant_properties

That doesn't explain why you have an error 500.
I suggest you do some test on the method, maybe you'll find a bug.
Feel free to submit PR to our Git Repository.



The set_participant_properties function is included in the remotecontrol_handle.php file.
When evaluating $aTokenData, error 500 occurs.

Json is valid
{
"method": "set_participant_properties", "params": ["vkedvegpz6gudave9nyhy9earqb4jcm4",
"479983", "2", "[language, value1]"], "id": 95
}

But I am not a PHP programmer and take too long to fully understand the project.
That is why I do not change source code.

Best regards Cornelia

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 7 meses antes #163041 por LouisGac
Respuesta de LouisGac sobre el tema set_participant_properties
github.com/Falydoor/limesurvey-rc/blob/m...veyRC.java#L384-L393

Seems that this java coder managed to get it working

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
5 meses 21 horas antes #183408 por snakeriot
Respuesta de snakeriot sobre el tema set_participant_properties
This thread is pretty old, but I spent a lot of time searching for the answers on questions asked here, and not found them.
As result, after almost whole day in Lime Survey code and experiments with an API - I have answers:

In order to make this method work - your string should look like this:
"{\"method\": \"set_participant_properties\", \"params\": {\"sSessionKey \": \"{0}\", \"iSurveyID \": \"{1}\", \"aTokenQueryProperties\": {\"token\": \"{2}\"}, \"aTokenData \": {\"sent\": \"Y\"}}, \"id\": \"1\"}"

Where:
* {0} - Session Key
* {1} - Survey ID
* {2} - Token of the participant

Instead of token, in "aTokenQueryProperties" you can use any fields from this documentation (properties section), the only condition is that whole set of fields should point to Only one Participant, in other case you will get "Error: More than 1 result was found based on your attributes.".

Same list of attributes is accepted by "aTokenData" field.

As I can see from the implementation on Lime Survey side - there is no way to update multiple participants using same request:
$tokenCount = Token::model($iSurveyID)->countByAttributes($aTokenQueryProperties);
if($tokenCount == 0){
	return array('status' => 'Error: No results were found based on your attributes.');
}else if($tokenCount > 1){
	return array('status' => 'Error: More than 1 result was found based on your attributes.');
}

Hope that this information will save someone's day :)
El siguiente usuario dijo gracias: tpartner, DivePeak, fellipeguerra1, mama0107

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

¡Comenzar ahora!

Simplemente cree una cuenta y comience a usar LimeSurvey hoy mismo.

Registrarse ahora
¡Únase a nuestro boletín informativo!

Iniciar sesión