Skip to content

Commit

Permalink
Fixed issue #05602: Graphs show wrong counts
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12319 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
ssachdeva committed Feb 2, 2012
1 parent a3aff8e commit fec4454
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -2244,6 +2244,10 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
foreach ($result->readAll() as $row)
{
$row=array_values($row);

//store temporarily value of answer count of question type '5' and 'A'.
$tempcount = -1; //count can't be less han zero

//increase counter
$TotalCompleted += $row[0];

Expand Down Expand Up @@ -2419,6 +2423,8 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,

if($testcounter == 0 ) //add 300 to original value
{
//store the original value!
$tempcount = $row[0];
//HACK: add three times the total number of results to the value
//This way we get a 300 + X percentage which can be checked later
$row[0] += (3*$results);
Expand All @@ -2427,6 +2433,8 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
//the third value should be shown twice later -> mark it
if($testcounter == 2) //add 400 to original value
{
//store the original value!
$tempcount = $row[0];
//HACK: add four times the total number of results to the value
//This way there should be a 400 + X percentage which can be checked later
$row[0] += (4*$results);
Expand All @@ -2435,6 +2443,8 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
//the last value aggregates the data of item 4 + item 5 later
if($testcounter == 4 ) //add 200 to original value
{
//store the original value!
$tempcount = $row[0];
//HACK: add two times the total number of results to the value
//This way there should be a 200 + X percentage which can be checked later
$row[0] += (2*$results);
Expand Down Expand Up @@ -2522,8 +2532,19 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0,
$justcode[]=$al[0];

//edit labels and put them into antoher array
$lbl[] = wordwrap(flattenText("$al[1] ($row[0])"), 25, "\n"); // NMO 2009-03-24
$lblrtl[] = UTF8Strrev(wordwrap(flattenText("$al[1] )$row[0]("), 25, "\n")); // NMO 2009-03-24

//first check if $tempcount is > 0. If yes, $row[0] has been modified and $tempcount has the original count.
if ($tempcount > 0)
{
$lbl[] = wordwrap(FlattenText("$al[1] ($tempcount)"), 25, "\n"); // NMO 2009-03-24
$lblrtl[] = utf8_strrev(wordwrap(FlattenText("$al[1] )$tempcount("), 25, "\n")); // NMO 2009-03-24
}
else
{
$lbl[] = wordwrap(FlattenText("$al[1] ($row[0])"), 25, "\n"); // NMO 2009-03-24
$lblrtl[] = utf8_strrev(wordwrap(FlattenText("$al[1] )$row[0]("), 25, "\n")); // NMO 2009-03-24

}

} //end while -> loop through results

Expand Down

0 comments on commit fec4454

Please sign in to comment.