set_participant_properties

More
5 months 4 weeks ago #162940 by mama0107
mama0107 created the topic: set_participant_properties
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

Please Log in or Create an account to join the conversation.

More
5 months 3 weeks ago #162942 by LouisGac
LouisGac replied the topic: 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.

Please Log in or Create an account to join the conversation.

More
5 months 3 weeks ago #162945 by mama0107
mama0107 replied the topic: 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

Please Log in or Create an account to join the conversation.

More
5 months 3 weeks ago #162948 by LouisGac
LouisGac replied the topic: 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.

Please Log in or Create an account to join the conversation.

More
5 months 3 weeks ago #163040 by mama0107
mama0107 replied the topic: 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

Please Log in or Create an account to join the conversation.

More
5 months 3 weeks ago #163041 by LouisGac
LouisGac replied the topic: set_participant_properties
github.com/Falydoor/limesurvey-rc/blob/m...veyRC.java#L384-L393

Seems that this java coder managed to get it working

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!