Skip to content

Commit

Permalink
Fixed bug - q1 should never be lower than minimum and q3 should never…
Browse files Browse the repository at this point in the history
… be higher than maximum.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@254 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Apr 21, 2003
1 parent 340b5fc commit eb88fa1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions admin/statistics.php
Expand Up @@ -528,6 +528,7 @@
$showem[]=array("Average", $row['average']);
$showem[]=array("Minimum", $row['minimum']);
$maximum=$row['maximum']; //we're going to put this after the quartiles for neatness
$minimum=$row['minimum'];
}

//CALCULATE QUARTILES
Expand All @@ -548,7 +549,9 @@
$query = $querystarter . " ORDER BY $fieldname*1 LIMIT $q1b, 2";
$result=mysql_query($query) or die("1st Quartile query failed<br />".mysql_error());
while ($row=mysql_fetch_array($result)) {$total=$total-$row[$fieldname];}
$showem[]=array("1st Quartile", -$total * $q1diff);
$q1total=-$total*$q1diff;
if ($q1total < $minimum) {$q1total=$minimum;}
$showem[]=array("1st Quartile", $q1total);
}
else
{
Expand Down Expand Up @@ -586,8 +589,10 @@
$q3c=$q3b-2;
$query = $querystarter . " ORDER BY $fieldname*1 LIMIT $q3c, 2";
$result = mysql_query($query) or die("3rd Quartile query failed<br />".mysql_error());
while ($row=mysql_fetch_array($result)) {$total=$total-$row[$fieldname]; echo " ".$row[$fieldname]." - ";}
$showem[]=array("3rd Quartile", -$total * $q3diff);
while ($row=mysql_fetch_array($result)) {$total=$total-$row[$fieldname];}
$q3total=-$total * $q3diff;
if ($q3total > $maximum) {$q3total=$maximum;}
$showem[]=array("3rd Quartile", $q3total);
}
else
{
Expand Down

0 comments on commit eb88fa1

Please sign in to comment.