set_participant_properties

Mehr
1 Jahr 4 Monate her #162940 von 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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

LimeSurvey Partners
Mehr
1 Jahr 4 Monate her #162942 von LouisGac
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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 4 Monate her #162945 von mama0107
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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 4 Monate her #162948 von LouisGac
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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 4 Monate her #163040 von mama0107

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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 4 Monate her #163041 von LouisGac
github.com/Falydoor/limesurvey-rc/blob/m...veyRC.java#L384-L393

Seems that this java coder managed to get it working

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 3 Tage her #183408 von snakeriot
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 :)
Folgende Benutzer bedankten sich: tpartner, fellipeguerra1, mama0107

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha