View Issue Details

This bug affects 2 person(s).
 18
IDProjectCategoryView StatusLast Update
17647Bug reportsStatisticspublic2022-02-22 22:40
Reportersteffen.moser Assigned ToDenisChenu  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version5.x 
Summary17647: Strange sort order of question groups in simple statistics
Description

The order of the question groups in the statistics feature isn’t the same as the survey question group order itself. This happens only in one survey. Other surveys do not show this behavior. We do not know why this survey is affected.

Maybe it is related to the number of questions in a question group.

Steps To Reproduce

Steps to reproduce

Open an affected survey. We do not know how to reproduce. Maybe it depends on the order of records in the database or on the relation of the number of questions in the question groups.

Expected result

The question groups in the statistics feature should be in the order of the question groups.

Actual result

The question groups are in a different order.

Guess:

The helper function "groupOrderThenQuestionOrder($a, $b)" defined in "application/helpers/common_helper.php" has an "if" clause which is never entered [1], so the sorting algorithm in [2] does not order by question group as the first criteria. It happens due to the fact that the array attribute "group_order" is neither in $a nor in $b (which are $rows).

In contrast to the attribute "question_order", the attribute "group_order" is in a subarray called "$group".

Therefore, the function should be as follows:

function groupOrderThenQuestionOrder($a, $b)
{
    if (isset($a->group['group_order']) && isset($b->group['group_order'])) {
        $GroupResult = strnatcasecmp($a->group['group_order'], $b->group['group_order']);
    } else {
        $GroupResult = "";
    }
    if ($GroupResult == 0) {
        $TitleResult = strnatcasecmp($a["question_order"], $b["qutoestion_order"]);
        return $TitleResult;
    }
    return $GroupResult;
}

When patching the function as mentioned above, the problem is gone. The problem looks the same as the one mentioned in [3].

[1] https://github.com/LimeSurvey/LimeSurvey/blob/master/application/helpers/common_helper.php#L847-L848
[2] https://github.com/LimeSurvey/LimeSurvey/blob/master/application/controllers/admin/statistics.php#L176
[3] https://forums.limesurvey.org/forum/design-issues/122203-statistics-weird-question-group-order-in-statistics-feature

TagsNo tags attached.
Bug heat18
Complete LimeSurvey version number (& build)LimeSurvey Community Edition Version 5.1.14+210927
I will donate to the project if issue is resolvedNo
BrowserFirefox 92.0.1, 64-Bit, Linux (but happens with Chrome on macOS in the same way)
Database type & versionMySQL 5.7.34
Server OS (if known)Oracle Solaris 11.4 SRU 37
Webserver software & version (if known)Apache 2.4.48
PHP VersionPHP 7.4.15

Relationships

parent of 17777 closedDenisChenu PGSQL CDbCommand issue ins statistics 

Users monitoring this issue

DarioRoig

Activities

ollehar

ollehar

2021-10-04 12:18

administrator   ~66739

Can you open a pull request with this change, please?

DenisChenu

DenisChenu

2021-11-12 10:04

developer   ~67268

Last edited: 2021-11-12 15:36

My opinion : we must request by good order by default : https://github.com/LimeSurvey/LimeSurvey/blob/f98ca8b9697e819449a4d7c79f224ca8ce4b2b19/application/models/Question.php#L957

My pinion : request is OK, why update order after ? For group order at 0 ?

Stay must use same order tha n all other.

1st step : find way to reproduce issue (i think update order of group just before activate can be OK).

DenisChenu

DenisChenu

2021-11-12 15:12

developer   ~67279

Last edited: 2021-11-12 15:36

@steffen.moser : can you check the order set for each group for this survey ?
Same order for some Group ? Order set to null or 0 ?

DenisChenu

DenisChenu

2021-11-12 15:36

developer   ~67280

Last edited: 2021-11-12 15:36

Issue in simple statistics

With
Create G1 with G1Q1
Create G2 with G2Q1
Reorder with G2 before G1
Activate
Seems OK but not in simple statitics

DenisChenu

DenisChenu

2021-11-22 17:19

developer   ~67479

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

DarioRoig

DarioRoig

2021-12-01 09:26

reporter   ~67618

Hi Denis, there is a little bug, in postgres group is a reserved word, we can't use group as an table alias.

/var/www/application/models/Question.php
'condition' => 't.sid=:sid',
'order' => 'group.group_order,question_order',
'params' => array(':sid' => $surveyid)

http://github.com/LimeSurvey/LimeSurvey/commit/7238a601d3c04f2619c0c42a2f4040d9fc74dcee
Regards

DenisChenu

DenisChenu

2021-12-01 11:27

developer   ~67633

@DarioRoig : can you

  1. Open another issue
  2. test with 'order' => 'group_order,question_order', in place of https://github.com/LimeSurvey/LimeSurvey/commit/7238a601d3c04f2619c0c42a2f4040d9fc74dcee#diff-75d3428e7aa3f16b9dc93ef54dfa4d0556c04431cb53510749ded531d549a148R508 ?

Thank you .

LimeBot

LimeBot

2022-01-05 09:35

administrator   ~67911

Fixed in Release 5.2.4+211129

guest

guest

2022-02-22 22:40

viewer   ~68369

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

Related Changesets

LimeSurvey: master 7238a601

2021-11-22 18:19

DenisChenu

Committer: GitHub


Details Diff
Fixed issue 17647: Strange sort order of question groups in statistics (#2143)

Dev: order is already set in request for run
Dev: fix request for simple statistics
Dev: check where function is used to add it in comment
Dev: Some clean up on quick stat logic
Affected Issues
17647
mod - application/controllers/admin/statistics.php Diff File
mod - application/helpers/common_helper.php Diff File
mod - application/helpers/frontend_helper.php Diff File
mod - application/models/Question.php Diff File

LimeSurvey: master 506dd2a4

2022-02-22 23:25

Steffen Moser

Committer: GitHub


Details Diff
Fixed issue 17647: Strange sort order of question groups in statistics Affected Issues
17647
mod - application/helpers/common_helper.php Diff File

Issue History

Date Modified Username Field Change
2021-10-04 02:34 steffen.moser New Issue
2021-10-04 08:23 galads Assigned To => galads
2021-10-04 08:23 galads Status new => assigned
2021-10-04 08:24 galads Assigned To galads => ollehar
2021-10-04 08:24 galads Status assigned => new
2021-10-04 08:24 galads Status new => assigned
2021-10-04 12:18 ollehar Note Added: 66739
2021-10-04 12:18 ollehar Bug heat 0 => 2
2021-10-08 15:34 ollehar Zoho Project Synchronization => |Yes|
2021-11-12 10:04 DenisChenu Note Added: 67268
2021-11-12 10:04 DenisChenu Bug heat 2 => 4
2021-11-12 15:12 DenisChenu Note Added: 67279
2021-11-12 15:36 DenisChenu Note Added: 67280
2021-11-12 15:36 DenisChenu Summary Strange sort order of question groups in statistics => Strange sort order of question groups in simple statistics
2021-11-12 15:36 DenisChenu Zoho Project Synchronization Yes => |Yes|
2021-11-22 17:19 DenisChenu Changeset attached => LimeSurvey master 7238a601
2021-11-22 17:19 DenisChenu Note Added: 67479
2021-11-22 17:19 DenisChenu Assigned To ollehar => DenisChenu
2021-11-22 17:19 DenisChenu Resolution open => fixed
2021-11-22 17:21 ollehar Status assigned => resolved
2021-12-01 09:22 DarioRoig Issue Monitored: DarioRoig
2021-12-01 09:22 DarioRoig Bug heat 4 => 12
2021-12-01 09:26 DarioRoig Note Added: 67618
2021-12-01 09:26 DarioRoig Bug heat 12 => 14
2021-12-01 11:27 DenisChenu Note Added: 67633
2021-12-05 19:01 DenisChenu Relationship added parent of 17777
2022-01-05 09:35 LimeBot Zoho Project Synchronization Yes => |Yes|
2022-01-05 09:35 LimeBot Note Added: 67911
2022-01-05 09:35 LimeBot Status resolved => closed
2022-01-05 09:35 LimeBot Bug heat 14 => 16
2022-02-22 22:40 Changeset attached => LimeSurvey master 506dd2a4
2022-02-22 22:40 guest Note Added: 68369
2022-02-22 22:40 guest Bug heat 16 => 18