- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How should the response to a ranking question be sent via RC2?
- mattellen
- Topic Author
- Offline
- New Member
Less
More
6 years 1 month ago #163878
by mattellen
How should the response to a ranking question be sent via RC2? was created by mattellen
I am calling the "add_response" method of RemoteControl2. I'm trying to add an answer to a ranking question. All the other answers are being accepted, but I can't see any documentation on how to structure the ranking answer.
So far I have tried (where S is the survey ID, G is the group ID, and Q is the question ID)
SXGXQ = "A1,A2,A3,A4"
SXGXQ = ["A1", "A2", "A3", "A4"]
SXGXQ = {"A1":1, "A2":2, "A3", "A4":4}
SXGXQ_1 = "A1", SXGXQ_2 = "A2", SXGXQ_3 = "A3", SXGXQ_1 = "A3"
SXGXQA1 = 1, SXGXQA2 = 2, SXGXQA3 = 3, SXGXQA4 = 4
What is the correct structure for this?
So far I have tried (where S is the survey ID, G is the group ID, and Q is the question ID)
SXGXQ = "A1,A2,A3,A4"
SXGXQ = ["A1", "A2", "A3", "A4"]
SXGXQ = {"A1":1, "A2":2, "A3", "A4":4}
SXGXQ_1 = "A1", SXGXQ_2 = "A2", SXGXQ_3 = "A3", SXGXQ_1 = "A3"
SXGXQA1 = 1, SXGXQA2 = 2, SXGXQA3 = 3, SXGXQA4 = 4
What is the correct structure for this?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
6 years 1 month ago #163916
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How should the response to a ranking question be sent via RC2?
Try this:
Here is a working example using RPC:
Code:
SXGXQ1 = 'A1', SXGXQ2 = 'A2', SXGXQ3 = 'A3', SXGXQ4 = 'A4'
Here is a working example using RPC:
Code:
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'http://pathTo/limesurvey/'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); $iSurveyID = 123456; $g1ID = 123; $q1ID = 1234; $q1SGQ = $iSurveyID.'X'.$g1ID.'X'.$q1ID; if(ctype_alnum($iSurveyID) && (strlen($iSurveyID) == 5 || strlen($iSurveyID) == 6)) { // Valid SID format // Instantiate a new RPC client $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' ); // Get a session key $sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD ); if(is_array($sSessionKey)) { // Invalid session echo $sSessionKey['status']; } else if($sSessionKey) { // Valid session // Set a new response $aResponseData = array($q1SGQ.'1'=>'A1', $q1SGQ.'2'=>'A2', $q1SGQ.'3'=>'A3', $q1SGQ.'4'=>'A4'); $newResponse = $myJSONRPCClient->add_response($sSessionKey, $iSurveyID, $aResponseData); } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: mattellen
The topic has been locked.
- mattellen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
6 years 1 month ago #163944
by mattellen
Replied by mattellen on topic How should the response to a ranking question be sent via RC2?
Thanks! That worked.
The topic has been locked.