View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
17916Bug reportsStatisticspublic2022-05-16 11:19
ReporterNilsClark Assigned Toc_schmitz  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version5.2.x 
Summary17916: Sorting of answer options in statistics screen
Description

We use a Net Promoter Score plugin for 10-step Likert scales.
This type of scale requires to add answer options numbered from 0 to 10.

Looking at the results in the statistics, I notice, that the answer options are sorted this way:
0, 1, 10, 2, 3, 4, …

It seems that sorting is done using the default PHP sort function, which leads to this somehow correct but not human readable sorting.

Using natsort() would result in the correct numerical sorting, as well as in a proper sorting with alphanumeric answer options.

Steps To Reproduce

Steps to reproduce

Create a single select question with multiple answer options, e.g. List(dropdown) and add e.g. 5 answer options.
Set answer option codes to:
0 – Test 1
1 – Test 2
2 – Test 3
103 – Test 4
20 – Test 5

Expected result

I would expect to see the answers sorted in the drop down as:

Test 1
Test 2
Test 3
Test 4
Test 5

This works as expected.

I would expect to see the answers sorted in the statistics as:

0 – Test 1
1 – Test 2
2 – Test 3
20 – Test 5
103 – Test 4

sorted by the numeric value (answer option code).

Alternative: I would at least expect them in the original order, because I can sort them in question edit mode:
0 – Test 1
1 – Test 2
2 – Test 3
103 – Test 4
20 – Test 5

sorted by position.

Actual result

0 – Test 1
1 – Test 2
103 – Test 4
2 – Test 3
20 – Test 5

The results are sorted with the default sort php function, which sorts by each digit.

Especially for Likert scales, this is really unexpected and makes the results much harder to read.

Using natsort(); this should result in the correct human readable order. Using natsort(); should work as well for alphanumerical answer codes.

TagsNo tags attached.
Attached Files
Bug heat6
Complete LimeSurvey version number (& build)5.2.14+220214
I will donate to the project if issue is resolvedNo
BrowserBrave (Chromium-based)
Database type & versionMariaDB 10.1.48
Server OS (if known)Ubuntu 18.04
Webserver software & version (if known)Apache
PHP Version7.4.28

Users monitoring this issue

There are no users monitoring this issue.

Activities

gabrieljenik

gabrieljenik

2022-05-09 16:57

manager   ~69525

PR: https://github.com/LimeSurvey/LimeSurvey/pull/2410

Added the correct sorting where it was missing,
Ideally I would add a defaultScope with the default sorting. But I'm not sure if it would have unexpected impact.

c_schmitz

c_schmitz

2022-05-16 10:03

administrator   ~69648

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

LimeBot

LimeBot

2022-05-16 11:19

administrator   ~69659

Fixed in Release 5.3.14+220516

Related Changesets

LimeSurvey: master 50f90622

2022-05-16 10:02:46

c_schmitz

Details Diff
Fixed issue 17916: Sorting of answer options in statistics screen Affected Issues
17916
mod - application/models/Answer.php Diff File

Issue History

Date Modified Username Field Change
2022-02-28 17:30 NilsClark New Issue
2022-02-28 17:30 NilsClark File Added: Screenshot 2022-02-28 at 17.21.42.png
2022-02-28 17:30 NilsClark File Added: Screenshot 2022-02-28 at 17.22.03.png
2022-02-28 17:30 NilsClark File Added: Screenshot 2022-02-28 at 17.22.56.png
2022-04-28 16:31 gabrieljenik Assigned To => gabrieljenik
2022-04-28 16:31 gabrieljenik Status new => assigned
2022-05-09 16:57 gabrieljenik Status assigned => ready for testing
2022-05-09 16:57 gabrieljenik Note Added: 69525
2022-05-09 16:57 gabrieljenik Bug heat 0 => 2
2022-05-16 10:03 c_schmitz Changeset attached => LimeSurvey master 50f90622
2022-05-16 10:03 c_schmitz Note Added: 69648
2022-05-16 10:03 c_schmitz Bug heat 2 => 4
2022-05-16 10:03 c_schmitz Assigned To gabrieljenik => c_schmitz
2022-05-16 10:03 c_schmitz Resolution open => fixed
2022-05-16 10:04 c_schmitz Status ready for testing => closed
2022-05-16 10:04 c_schmitz Status closed => resolved
2022-05-16 11:19 LimeBot Note Added: 69659
2022-05-16 11:19 LimeBot Status resolved => closed
2022-05-16 11:19 LimeBot Bug heat 4 => 6