View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
06931Bug reportsStatisticspublic2012-12-04 13:16
ReporterpfpDave Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version2.00+ 
Fixed in Version2.00+ 
Summary06931: Array questions do not display graphs by default even if set to Yes
Description

Array questions will not display graphs in statsistics outputs even if the question option is yes and graphs is enabled in statistics. I've managed to trace the issue back to application\helpers\common_helper.php in the function getQuestionAttributeValues() ... the function attempts to get the row from the question table but can't so assumes the question doesn't exist.

I'm certain this is because the question is a sub question and the ID being returned is (for example) 3391 where it means question 339 sub question 1. But I'm a little stuck where to go now, here's where the process falls down:

$row = Questions::model()->findByAttributes(array('qid' => $iQID)); //, 'parent_qid' => 0), array('group' => 'type')
if (empty($row)) // Question was deleted while running the survey
{
            $cache[$iQID] = false;
    return false;
}

Any help (if not a fix) would be appreciated.

TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)121115
I will donate to the project if issue is resolvedNo
BrowserIE8
Database type & versionSQL Express 2012
Server OS (if known)Server 2008
Webserver software & version (if known)IIS 7
PHP Version5.4.8

Users monitoring this issue

There are no users monitoring this issue.

Activities

pfpDave

pfpDave

2012-11-22 13:04

reporter   ~22417

I should have added that getQuestionAttributeValues is called by /application/helpers/admin/statistics_helper.php around line 2848:
$aattr = getQuestionAttributeValues($qqid, substr($rt, 0, 1));

the question id (qqid) is derrived from the full question id ie 997138X18X3391 which is passed into the $rt parameter in the buildOutputList function. I'm wondering if somewhere in the function it should try and determine if the question has a parent and if so, pass the parent id to getQuestionAttributeValues instead?

pfpDave

pfpDave

2012-11-22 13:56

reporter   ~22418

Last edited: 2012-11-22 13:56

I believe I have a fix but would appreciate someone checking it, particularly the question types, it seems to work OK for me. Fix follows:

change \application\helpers\admin\statistics_helper.php around line 2849 from:

$aattr = getQuestionAttributeValues($qqid, substr($rt, 0, 1));

to:

    if (strpos("1ABCEFHR:;", $outputs['qtype']) === false) {
                $tmpqqid = $qqid;
            } else {
                $tmpqqid=substr($qqid, 0, strlen($qqid)-1);
            }

$aattr = getQuestionAttributeValues($tmpqqid, substr($rt, 0, 1));
pfpDave

pfpDave

2012-11-22 14:17

reporter   ~22419

Slight amendment but still not a final fix ...
this fix is fine until you have more than 9 sub questions!

    if ($outputs['qtype'] == "R") {
                $tmpqqid=substr($qqid, 0, strpos($qqid, "-")-1);
            } elseif (strpos("1ABCEFH:;", $outputs['qtype']) === false) {
                $tmpqqid = $qqid;
            } else {
                $tmpqqid=substr($qqid, 0, strlen($qqid)-1);
            }
$aattr = getQuestionAttributeValues($tmpqqid, substr($rt, 0, 1));
pfpDave

pfpDave

2012-11-22 15:08

reporter   ~22424

A much better and hopefully, final fix:

change \application\helpers\admin\statistics_helper.php as follows:

Add at line 562:

$qqid = "";

Line 1541 change from:

    return array("alist"=>$alist, "qtitle"=>$qtitle, "qquestion"=>$qquestion, "qtype"=>$qtype, "statisticsoutput"=>$statisticsoutput);

to:

    return array("alist"=>$alist, "qtitle"=>$qtitle, "qquestion"=>$qquestion, "qtype"=>$qtype, "statisticsoutput"=>$statisticsoutput, "parentqid"=>$qqid);

Line 2849 change from:

    $aattr = getQuestionAttributeValues($qqid, substr($rt, 0, 1));

to:

$aattr = getQuestionAttributeValues($outputs['parentqid'], substr($rt, 0, 1));
c_schmitz

c_schmitz

2012-11-22 15:20

administrator   ~22426

Your final fix will break the output for non-array question types.

pfpDave

pfpDave

2012-11-22 15:22

reporter   ~22427

They seem to work OK for me?

pfpDave

pfpDave

2012-11-22 15:24

reporter   ~22428

parentqid will always be the Question ID or Parent Question ID where the question doesn't have children

pfpDave

pfpDave

2012-11-26 10:41

reporter   ~22510

Carsten,

I've been using this fix with statistics on a live and dev surveys and all looks ok to me, I've also tested on the latest build '121121' and all seems OK ... I'm not sure why you think it will break non-array Q types?

c_schmitz

c_schmitz

2012-11-30 14:58

administrator   ~22739

Hello pfpDave,

you are right, seems to work fine - sorry for the false assumption.
For us to review a patch like this alot quicker it would be great if you can do gitHub pull-requests. That makes it alot easier :).

pfpDave

pfpDave

2012-11-30 15:00

reporter   ~22740

Sounds good, I'll read up on how to do that and will register with Github.

Cheers

c_schmitz

c_schmitz

2012-11-30 15:07

administrator   ~22741

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

c_schmitz

c_schmitz

2012-11-30 15:09

administrator   ~22742

Thank you!

c_schmitz

c_schmitz

2012-11-30 17:02

administrator   ~22753

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

c_schmitz

c_schmitz

2012-12-04 13:16

administrator   ~22858

LimeSurvey 2.0+ build 121204 released.

Related Changesets

LimeSurvey: master 0bca7c29

2012-11-30 15:05

c_schmitz


Details Diff
Fixed issue 06931: Array questions do not display graphs by default even if set to Yes - patch by pfpDave Affected Issues
06931
mod - application/helpers/admin/statistics_helper.php Diff File

LimeSurvey: 2.1 949a083d

2012-11-30 16:55

c_schmitz


Details Diff
Fixed issue 06931: Array questions do not display graphs by default even if set to Yes - patch by pfpDave Affected Issues
06931
mod - application/helpers/admin/statistics_helper.php Diff File

Issue History

Date Modified Username Field Change
2012-11-22 12:43 pfpDave New Issue
2012-11-22 13:04 pfpDave Note Added: 22417
2012-11-22 13:56 pfpDave Note Added: 22418
2012-11-22 13:56 pfpDave Note Edited: 22418
2012-11-22 13:56 pfpDave Note Edited: 22418
2012-11-22 14:17 pfpDave Note Added: 22419
2012-11-22 15:08 pfpDave Note Added: 22424
2012-11-22 15:16 c_schmitz Assigned To => c_schmitz
2012-11-22 15:16 c_schmitz Status new => assigned
2012-11-22 15:20 c_schmitz Note Added: 22426
2012-11-22 15:22 pfpDave Note Added: 22427
2012-11-22 15:24 pfpDave Note Added: 22428
2012-11-26 10:41 pfpDave Note Added: 22510
2012-11-30 14:58 c_schmitz Note Added: 22739
2012-11-30 15:00 pfpDave Note Added: 22740
2012-11-30 15:07 c_schmitz Changeset attached => LimeSurvey master 0bca7c29
2012-11-30 15:07 c_schmitz Note Added: 22741
2012-11-30 15:07 c_schmitz Resolution open => fixed
2012-11-30 15:09 c_schmitz Note Added: 22742
2012-11-30 15:09 c_schmitz Status assigned => resolved
2012-11-30 15:09 c_schmitz Fixed in Version => 2.00+
2012-11-30 17:02 c_schmitz Changeset attached => LimeSurvey 2.1 949a083d
2012-11-30 17:02 c_schmitz Note Added: 22753
2012-12-04 13:16 c_schmitz Note Added: 22858
2012-12-04 13:16 c_schmitz Status resolved => closed