Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

API doesn't return first scale for Array Dual Scale question

  • Matiasko
  • Matiasko's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #240266 by Matiasko
Please help us help you and fill where relevant:
Your LimeSurvey version: 3.16.1+190314
Own server or LimeSurvey hosting: self-hosted

==================
We're using JSON-RPC and when I use "get_question_properties" method to get the properties of  "Array Dual Scale" type question, the response JSON holds only second scale under "answeroptions". This behavior is the same for two identical or two different scales set for the question.

Could you confirm that you observe the same behavior on your installs?
 

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #240274 by holch
How do you request those scales?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #240275 by holch
Off-topic: You should seriously update your LS3.16.1+190314. It is almost 4 years old and hasn't received any bug or security fixed for the same amount of time. In my opinion, this version should not be accessible via the internet or collect any kind of data anymore.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • Matiasko
  • Matiasko's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago - 1 year 1 month ago #240284 by Matiasko
I use R package "limonaid" which provides "limer_call_limer" function where I can pass method and parameters. So I use:
Code:
limer_call_limer(method = "get_question_properties", params = list(iQuestionID = 65056))
and get a JSON object.
In this JSON I can see that in the "answeroptions" only the 3 items for the second scale are present.
Code:
{
  "qid": "65056",
  "parent_qid": "0",
  "sid": "361177",
  "gid": "4184",
  "type": "1",
  "title": "P26",
  "question": "Tabela dwóch skal",
  "preg": "",
  "help": "",
  "other": "N",
  "mandatory": "N",
  "question_order": "8",
  "language": "pl",
  "scale_id": "0",
  "same_default": "0",
  "relevance": "1",
  "modulename": ,
  "available_answers": {
    "1": "Sub1",
    "2": "Sub2",
    "3": "Sub3"
  },
  "subquestions": {
    "65110": {
      "title": "1",
      "question": "Sub1",
      "scale_id": "0"
    },
    "65111": {
      "title": "2",
      "question": "Sub2",
      "scale_id": "0"
    },
    "65112": {
      "title": "3",
      "question": "Sub3",
      "scale_id": "0"
    }
  },
  "attributes": "No available attributes",
  "attributes_lang": "No available attributes",
  "answeroptions": {
    "1": {
      "answer": "Odp21",
      "assessment_value": "0",
      "scale_id": "1",
      "order": "1"
    },
    "2": {
      "answer": "Odp22",
      "assessment_value": "0",
      "scale_id": "1",
      "order": "2"
    },
    "3": {
      "answer": "Odp23",
      "assessment_value": "0",
      "scale_id": "1",
      "order": "3"
    }
  },
  "defaultvalue":
}
Last edit: 1 year 1 month ago by Matiasko.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #240293 by tpartner
Hmm...it works as expected for me with LS version 5.6.3.

This is what I see as the returned answeroptions[/] array:
 

Code:
Array ( 
  [S11] => Array ( [answer] => Scale 1, answer 1 [assessment_value] => 0 [scale_id] => 0 [order] => 0 ) 
  [S12] => Array ( [answer] => Scale 1, answer 2 [assessment_value] => 0 [scale_id] => 0 [order] => 1 ) 
  [S13] => Array ( [answer] => Scale 1, answer 3 [assessment_value] => 0 [scale_id] => 0 [order] => 2 ) 
  [S21] => Array ( [answer] => Scale 2, answer 1 [assessment_value] => 0 [scale_id] => 1 [order] => 3 ) 
  [S22] => Array ( [answer] => Scale 2, answer 2 [assessment_value] => 0 [scale_id] => 1 [order] => 4 ) 
  [S23] => Array ( [answer] => Scale 2, answer 3 [assessment_value] => 0 [scale_id] => 1 [order] => 5 ) 
)

Using this PHP for the API call:

Code:
<?php
 
  require_once 'jsonRPCClient.php';
 
  define( 'LS_BASEURL', 'http://pathTo/limeSurvey');  
  define( 'LS_USER', 'admin' );
  define( 'LS_PASSWORD', 'password' );
 
  $iSurveyID = 616292;
  $iQuestionID = 8621;
 
  if(ctype_alnum($iSurveyID) &amp;&amp; (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
 
      $questionProperties = $myJSONRPCClient->get_question_properties($sSessionKey, $iQuestionID);
 
      print_r($questionProperties['answeroptions']);
      echo '<br /><br />';
    }
 
    // Release the session key
    $myJSONRPCClient->release_session_key( $sSessionKey );
  }
  else { // Invalid SID format
    die( 'Invalid format!' );
  }
?>

Sample survey attached:

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #240294 by tpartner
...also works in version 3.28.45 .

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: DenisChenu

Please Log in to join the conversation.

  • Matiasko
  • Matiasko's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #240297 by Matiasko
Thank you for checking this.

Is it possible that this is because of older LS version hosted on our own server?

I would guess that API gets updated as part of LS.

If this is the case I will have one more reason for my supervisor to update the software.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #240301 by holch
yes, there is a good chance that this was a bug and is fixed, as Tpartner confirmed that it worked for him.

And what more reasons than 4 years without bug fixes does the supervisor need?????

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • Matiasko
  • Matiasko's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #240452 by Matiasko
Ok I've nailed the cause of this behavior which is the same using the mentioned old and a newer version (5.3.17+220525).

This behavior happens when both scales have one or more of the same answer codes. In this case each element with the same answer code will be overwritten with the one on the second scale.

So the simple solution is to make sure that not a single answer code is present on both scales.

Could you check if you can reproduce this behavior with the newest version?

In my opinion this is quite counterintitive as I don't see a reason why the user shouldn't use the same codes on scales. We often use dual scales to present the very same scale but for two different contexts. Also because when you create a new question of dual-scale type, both scales get prepopulated with the same code like AO01.

Shouldn't the API make sure to return both scales even in case of their answers using one or more same codes?

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #240534 by tpartner
I can confirm that the problem exists in 5.6.5, using the same answer codes for both scales.

Please file a bug report.

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: DenisChenu

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose