The database is used to give exams to medical students. Each question in an exam as a discriminator value which is kinda like a performance rating for each question. These values are small and can range from -.9 to .9
What I need is a bar chart of these discriminator values. Each bar in the graph would represent a range like the following:
.60 to .69
.50 to .59
.40 to .49
.30 to .39
.20 to .29
.10 to .19
0.0 to .09
-.1 to -.10
-.11 to -.20
-.21 to -.30
-.31 to -.40
The discriminator can fall anywhere inside these ranges. I will have around 100 values (questions) per exam.
Here is an example array queried from my table.
$chart = $db->sql_query("SELECT `discri`, COUNT(`discri`) AS `occurrence` FROM question_stats WHERE quiz_id = '$qid' GROUP BY `discri` ORDER BY `discri`");
$occurrence = array();
$descri = array();
while( $row = $db->sql_fetchrow($chart)) {
$occurrence[] = $row['occurrence'];
$descri[] = $row['discri'];
Array
(
[0] => 1
[1] => 1
[2] => 1
[3] => 4
[4] => 1
[5] => 1
[6] => 1
[7] => 2
[8] => 1
[9] => 4
[10] => 1
[11] => 2
[12] => 4
[13] => 1
[14] => 4
[15] => 3
[16] => 4
[17] => 4
[18] => 1
[19] => 4
[20] => 3
[21] => 1
[22] => 3
[23] => 6
[24] => 1
[25] => 4
[26] => 2
[27] => 1
[28] => 5
[29] => 2
[30] => 2
[31] => 4
[32] => 1
[33] => 1
[34] => 2
[35] => 1
[36] => 1
[37] => 2
[38] => 1
[39] => 1
[40] => 1
)
Array
(
[0] => -0.09
[1] => -0.06
[2] => -0.03
[3] => 0.00
[4] => 0.02
[5] => 0.03
[6] => 0.05
[7] => 0.09
[8] => 0.10
[9] => 0.11
[10] => 0.12
[11] => 0.13
[12] => 0.14
[13] => 0.16
[14] => 0.18
[15] => 0.19
[16] => 0.20
[17] => 0.21
[18] => 0.22
[19] => 0.23
[20] => 0.24
[21] => 0.25
[22] => 0.26
[23] => 0.27
[24] => 0.28
[25] => 0.29
[26] => 0.30
[27] => 0.31
[28] => 0.32
[29] => 0.33
[30] => 0.34
[31] => 0.35
[32] => 0.36
[33] => 0.38
[34] => 0.40
[35] => 0.41
[36] => 0.42
[37] => 0.44
[38] => 0.46
[39] => 0.49
[40] => 0.50
)
I intend to use Open Flash Chart with JSON to graph these.
One array "Ranges" along the X Axis and the other Discriminator (count) for each range along the Y axis.
What I need are these for example
[3] => 4
[4] => 1
[5] => 1
[6] => 1
[7] => 2
Total would be 9
[3] => 0.00
[4] => 0.02
[5] => 0.03
[6] => 0.05
[7] => 0.09
put into a range 0 to .09
I am modest about my PHP skills and realize I'm more of a novice when it comes to these more advanced methods. What I need is this done the right way as several people at the university will use this information.
Is there a better way to do this?
$range_data = array(
'nP4_nP31' => 0 // -.40 to -.31
,'nP3_nP21' => 0 // -.30 to -.21
,'nP2_nP11' => 0 // -.20 to -.11
,'nP10_P0' => 0 // -.10 to zero
,'P01_P10' => 0 // .01 to point 10
,'P11_P20' => 0 // .11 to point 20
,'P21_P30' => 0 // .21 to point 30
,'P31_P40' => 0 // .31 to point 40
);
Then checking each value
if ($discri >= -.40 AND $discri <= -.31){
$range_data['nP4_nP31'] += 1;
}
elseif ($discri >= -.30 AND $discri <= -.21){ //greater than or equal to -.3 and less or equal to -.21
$range_data['nP3_nP21'] += 1;
}
etc
etc