View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
12156Bug reportsRemoteControlpublic2017-03-07 11:01
ReporterSorix Assigned Tomfavetti  
PrioritynoneSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.63.x 
Fixed in Version2.64.x 
Summary12156: get_question_properties ordering
Description

get_question_properties RemoteControl's method returns JSON Dictionary with ordering that is not supported by standard.

The only way to get answers order is to call get_question_properties and look to raw JSON reply order, but you are not allowed to use ordering in JSON Dictionaries by standard, so there is no way to get answers ordering.

Steps To Reproduce

You can't get question ordering from that output:

{
"id": 1,
"result": {
"available_answers": "No available answers",
"subquestions": "No available answers",
"attributes": "No available attributes",
"attributes_lang": "No available attributes",
"answeroptions": {
"3": {
"answer": "15",
"assessment_value": "0",
"scale_id": "0"
},
"2": {
"answer": "16",
"assessment_value": "0",
"scale_id": "0"
}
},
"defaultvalue": null
},
"error": null
}

Tagsremote control
Bug heat6
Complete LimeSurvey version number (& build)2.50+ Build 160715
I will donate to the project if issue is resolvedNo
Browser
Database type & versionno matter
Server OS (if known)no matter
Webserver software & version (if known)no matter
PHP Versionno matter

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2017-02-28 12:30

administrator   ~43090

I am sorry but I don't understand the problem. Which ordering are you referring to? Can you explain in more detail what is not standard?

Sorix

Sorix

2017-03-01 11:15

reporter   ~43110

Sorry that I've provided not such detailed description.

I need to get answer options for question and use same answers order as it displays on web version of application. To get answer options I use method get_question_properties and receive JSON reply that was provided above.

But as you can see there is no "answer order" option there, so I can't know correct order of answers.

During my investigations I've found that LimeSurvey sends JSON Dictionary (look at key "answeroptions") with answer options in the same order as it specified in admin panel.

But I can't rely on that because JSON Dictionary is unordered type by standard (so there is no answers order may be specified), so I can't rely on dictionary order (most languages don't support order for default dictionaries, if you iterate through dictionary you may receive key/values in random order).

So to get correct answer order in JSON you need to add some key like "answer_order" or change "answeroptions" key from Dictionary to Array.

In my example I can move answer options with id "3" at the top, or on the bottom, from JSON I can't know how that answer options needed to be ordered.

mfavetti

mfavetti

2017-03-02 23:42

developer   ~43130

https://github.com/LimeSurvey/LimeSurvey/pull/650

c_schmitz

c_schmitz

2017-03-03 15:07

administrator   ~43149

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=22420

c_schmitz

c_schmitz

2017-03-03 15:08

administrator   ~43150

Thank you, mfavetti!

c_schmitz

c_schmitz

2017-03-07 11:01

administrator   ~43177

Version 2.64.0 released

Related Changesets

LimeSurvey: master 983668e7

2017-03-03 15:07:38

mfavetti


Committer: c_schmitz Details Diff
Fixed issue 12156: RemoteControl get_question_properties does not convey answer options order Affected Issues
12156
mod - application/helpers/remotecontrol/remotecontrol_handle.php Diff File

Issue History

Date Modified Username Field Change
2017-02-26 13:00 Sorix New Issue
2017-02-26 13:01 Sorix Tag Attached: remote control
2017-02-28 12:30 c_schmitz Assigned To => c_schmitz
2017-02-28 12:30 c_schmitz Status new => feedback
2017-02-28 12:30 c_schmitz Note Added: 43090
2017-03-01 11:15 Sorix Note Added: 43110
2017-03-01 11:15 Sorix Status feedback => assigned
2017-03-02 23:42 mfavetti Note Added: 43130
2017-03-03 15:07 c_schmitz Changeset attached => LimeSurvey master 983668e7
2017-03-03 15:07 c_schmitz Note Added: 43149
2017-03-03 15:07 c_schmitz Resolution open => fixed
2017-03-03 15:08 c_schmitz Assigned To c_schmitz => mfavetti
2017-03-03 15:08 c_schmitz Status assigned => resolved
2017-03-03 15:08 c_schmitz Fixed in Version => 2.64.x
2017-03-03 15:08 c_schmitz Note Added: 43150
2017-03-07 11:01 c_schmitz Note Added: 43177
2017-03-07 11:01 c_schmitz Status resolved => closed